System.IO.IOException: An attempt was made to move the file pointer before the beginning of the file

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v3 and older)  /  Re: System.IO.IOException: An attempt was made to move the file pointer before the beginning of the file

DynamicPDF Merger for .NET (v3 and older) Forum

I'm trying to merge documents who's paths are found in a ListBox control.  When I tried to append to the merge document, I get this error.  Any ideas on why this is happening?
As if that's not bad enough, when I try this code:

Dim doc As MergeDocument = MergeDocument.Merge("C:\Inetpub\wwwroot\intranet\submittals\documents\Items Sent With All Submittals\Company Information Sheet.pdf", "C:\Inetpub\wwwroot\intranet\submittals\documents\Items Sent With All Submittals\Company Information Sheet.pdf")

I get an adobe error that says the file is damaged and can't be fixed.  What's the deal?
Posted by a ceTe Software moderator
It looks like some of the PDFs that you are attempting to merge in are invalid or corrupt.  can you send over the PDF documents that you are using ("Company Information Sheet.pdf" and which ever PDF you are using to create the error above) to support@cete.com.  From there we can take a look at them and see if we can determine the problem.  Also in your email can you include the stack trace for the Exception above?

Thanks,
ceTe Software Support Team
I solved the problem with the IO exception.  Somehow a .doc file got placed in the directory and I unknowingly was adding it to the list repeatedly.

The issue with the damaged file not opening only occurs when I use the DrawToWeb method.  When I just use Draw and specify a file path, it saves the file perfectly and I can open it just fine.
Posted by a ceTe Software moderator
Hello,

The most likely reason you are getting the damaged file not opening error is because there might some HTML being output after the PDF corrupting the PDF output stream. The easiest solution would be to add a Response.End() immediately after the DrawToWeb() method and that should fix your problem.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 12:44 AM.