Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Error: unable to open file

Error: Failed to open PDF File

Input Error, so no output created.

What I have tried:

My Code:
input = "C:\Users\sathishr\Desktop\Small\a_20160310_*.pdf"
output = "C:\Users\sathishr\Desktop\Small\Test_US.pdf"
MergePdf(input, output)

Private Sub MergePdf(ByVal InputFileNames As Object, ByVal OutputFileName As Object)
Try
'Merging the generated pdf files

Dim oProcess As New System.Diagnostics.Process
oProcess.StartInfo.FileName = "pdftk"
oProcess.StartInfo.Arguments = InputFileNames + "output" + OutputFileName
oProcess.Start()
oProcess.WaitForExit()
oProcess.Close()
Catch ex As Exception
Throw ex
End Try
End Sub
Posted
Updated 15-Mar-16 5:06am
v2
Comments
Namith Krishnan E 10-Mar-16 6:09am    
did you opened the file a_20160310_*.pdf in any other application while runing the code???
SathishRam 10-Mar-16 6:29am    
Yes, physically i can open the path in window explorer
BulletVictim 10-Mar-16 9:29am    
I believe Namith Krishnan E question was more directed at if the file is open at the time that the application needs to access it, and not so much if it is a problem with the document being in the wrong format or corrupted.

1 solution

The problem appears to be in the line
C#
oProcess.StartInfo.Arguments = InputFileNames + "output" + OutputFileName

There are no spaces in the argumentsAFAIK the correct syntax for pdftk would be
pdftk C:\Users\sathishr\Desktop\Small\a_20160310_*.pdf cat output C:\Users\sathishr\Desktop\Small\Test_US.pdf
so I think that line should be (note untested)
C#
oProcess.StartInfo.Arguments = InputFileNames + " cat output " + OutputFileName
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900