There was end error while parsing the PDF file. The PDF is likely corrupt or invalid.

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Re: There was end error while parsing the PDF file. The PDF is likely corrupt or invalid.

DynamicPDF CoreSuite for .NET (v5) Forum

I keep getting the above error while trying to open a file to a merged PDF.

The code worked in .NET 1.1 and we recently converted the project to .NET 2.0 and now we are getting the error: "There was end error while parsing the PDF file. The PDF is likely corrupt or invalid."
I replaced the ceTe.DynamicPDF.11.dll with the ceTe.DynamicPDF.20.dll file and added the DynamicPDF for .NET(framework 2.0 and 3.0) reference.

No code was changed in the conversion process and I get no errors or warnings when I debug the project. Any ideas?
Posted by a ceTe Software moderator
Hello,

The error you are getting is likely because of some stray HTML getting outputted along with the PDF stream. Please try adding the following line of code right after the DrawToWeb method of the document object and it will likely solve your problem.

    Visible = false;

Thanks,
ceTe Software Support Team
No such luck. I used both

document.DrawToWeb("FormFiller.pdf", Visible = false);
and
document.DrawToWeb("FormFiller.pdf");
                Visible = false;

I still got the same error. If the problem was stray html wouldn't it have given this error in .net 1.1?
Posted by a ceTe Software moderator
Hello,

Sometimes setting Visible to false does not remove the stray HTML. Try using Response.End(); instead an see if that helps.

This could also be being caused by in the HTTP headers coming back from IIS. If the Response.End does not work, please post the header information that is coming back from IIS on the page that is calling the DrawToWeb method. You can use a tool such as ieHTTPHEadersieHTTPHEaders to view this information. You can send this over to support instead, if it contains sensitive information.

Let me know if I can be of further assistance.

Thanks,

ceTe Software Support Team
I can't use the ieHTTPHeaders software because of Network constraints.

I did find this that might help. While stepping thru the process I found the I get the error message after this line is ran
 
MergeDocument document = new MergeDocument(MapPath("PDFForms/2875kf2.pdf"));

so it is not even getting to the DrawToWeb method. And, yes that is the correct path to the pdf.
Posted by a ceTe Software moderator
Maybe you should send the PDF that you are using, the "2875kf2.pdf", directly to us, support@cete.com .  We can then take a look at it and see if we are able to get the same behavior using that PDF. Please send over the exact code you are using as well.

Is the error you are getting a runtime error or is this an error that the PDF reader is throwing when attempting to open the PDF?

Thanks,
ceTe Software Support Team
I'm currently evaluating this control and am having the same problem.  However I've noticed that everythign is fine with Acrobat Reader 9 and am only having a problem with Acrobat Reader 7??
Posted by a ceTe Software moderator
Hello,

Are you having problem in viewing the PDF in Acrobat Reader 7? or are you having problem in merging the PDF document using our product? What exact problem are you having? Please send over the code and the PDF document if you are using any existing PDF to our Support Team so that they can look into it further. Also please send over the full stack trace of the error you are getting.

Thanks,
ceTe Software Support Team.
I'm having this problem too.  This is the code I'm using:
        string file = @"C:\test\untitled.pdf";
        if (File.Exists(file))
        {
                MergeDocument document = new MergeDocument(file);
        }

I just downloaded the eval in the hopes of using this software to fill PDF forms; but I'm not getting very far.


The pdf was created with Acrobat 9 Pro.  This is the exception details:

ceTe.DynamicPDF.Merger.PdfParsingException was unhandled
  Message="There was end error while parsing the input PDF file. The PDF is likely corrupt or invalid."
  Source="ceTe.DynamicPDF.35"
  StackTrace:
       at ceTe.DynamicPDF.Merger.PdfDocument.g()
       at ceTe.DynamicPDF.Merger.PdfDocument..ctor(cc A_0, String A_1)
       at ceTe.DynamicPDF.Merger.PdfDocument..ctor(String filePath)
       at ceTe.DynamicPDF.Merger.MergeDocument..ctor(String filePath)
       at PRI.DynamicPDF.FrontEnd.MainForm.openButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\peter.ritchie\SoDe\PRI.DynamicPDF\PRI.DynamicPDF.FrontEnd\MainForm.cs:line 26
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.
FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at PRI.DynamicPDF.FrontEnd.Program.Main() in C:\Documents and Settings\peter.ritchie\SoDe\PRI.DynamicPDF\PRI.DynamicPDF.FrontEnd\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.NullReferenceException
       Message="Object reference not set to an instance of an object."
       Source="ceTe.DynamicPDF.35"
       StackTrace:
            at zz93.ch.a(i5 A_0)
       InnerException:
Posted by a ceTe Software moderator
Hello,

Can you please send over the code and the PDF document you are merging to our Support Team so that they can look into it further?

What kind of application is it? Is it a web, console or windows form application?

Thanks,
ceTe Sowftware Support Team
I am having the same problem.  I have a .net console application that merges various PDF documents.  It works fine with Dynamic PDF 4, but when I upgraded to version 5 I started to see this error for nearly every file I try to merge, and adding elements to the files also seems to corrupt them.
Posted by a ceTe Software moderator
Hello,

We have fixed this issue. Can you please send over a mail to our Support Team so that they can send you the latest dll which will work for you.

Thanks,
ceTe Software Support Team.
I am evaluating your product and getting the same error.  Just downloaded and installed.
Posted by a ceTe Software moderator
Hello,

The error you are getting is likely because of some stray HTML getting outputted along with the PDF stream. Please try adding the following line of code right after the DrawToWeb method of the document object and it will likely solve your problem.

    Visible = false;

Thanks,
ceTe Software Support Team
I still see this error sometimes even with the updated dll.  The fix doesn't work for me as I do not call the drawToWeb method-- just Draw.
Posted by a ceTe Software moderator
Hello,

Can you please send over the PDF documents and the code you are using to merge them to our Support Team so that they can look into it further to troubleshoot the problem?

Thanks,
ceTe Software Support Team.
I'm afraid the document in question is confidential, so I can't send it.  I will look for a non-confidential document that has the same problem and will then forward it. Thank you.
We are getting the same error on some of our documents. I have a console app so I am not calling the drawToWeb method. Most of our pdfs merge ok, just a few get this error.  I am not able to send a sample because the documents are confidential.

Is there a patch or fix for this problem?
Posted by a ceTe Software moderator
Hello,

We may need to look at the PDF documents that are throwing this exception. The problem could also be within the PDF document that you are trying to merge. You can send the documents to our Support Team

We do not have any patch or fixes available that can directly solve this. The exception you are getting is a more generic exception.

Thanks,
ceTe Software Support Team
Hello,

i encountered an exception while merging 2 pdfs using merge() function. The exception details is given below.

An unhandled exception of type 'ceTe.DynamicPDF.Merger.PdfParsingException' occurred in ceTe.DynamicPDF.35.dll

Additional information: Invalid PDF File. Cross-reference table not found.

I have licensed version for server. But need to check locally if it works. 
Posted by a ceTe Software moderator
Hello,

Please make sure that you are using latest DynamicPDF product dll file in your application and see if it works for you. You can download latest dll files by logging into our CustomerArea: http://www.DynamicPDF.com/CustomerArea using your product serial number. Remove reference for the old dll file and reference the latest dll file in your application.

If you continue getting error even after using the latest dll file in your application then please send over the full stack trace of error message, all input PDF documents with which you are getting error and sample code which you are using to our support team at: support@cete.com so that they can look into it.

Thanks,
ceTe Software Support Team.
yes,i got the latest exe and installed on the server as you mentioned in your response mail. But need a demo exe to test on, So that i can confirm that it would be working fine on the remote.

thanks

Arun
Posted by a ceTe Software moderator
Hello Arun,

You can use the downloaded installer to install the product on your remote server as well. We do not have separate demo exe.

Also please note that the product MSI will place all the files in your system. You need not have to do any changes to your working code. You will need to remove reference for the old dll file and reference the latest downloaded dll file in your application.

Thanks,
ceTe Software Support Team.
Well, i got your point. but have a question - can i use that downloaded exe in my local machine without using the serial key which you mentioned to include in app config(No matter i have watermark in my pdf). Is this affect the server licensing.

thanks

Arun
Posted by a ceTe Software moderator
Hello Arun,

You can use DynamicPDF dll file in any of your application to generate PDF documents. The Server licensing is not affected by this. 

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 11:34 PM.