We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

"Failed to load PDF document" and "File does not begin with '%PDF-'." errors


When trying to package a combination of PDF’s, I have received the following errors:

- Failed to load PDF document

- File does not begin with ‘%PDF-’.

The files causing the former are attached in “PDF Files 1”, and the files that cause the latter are in “PDF Files 2” and “PDF Files 3”. You will need to package each .zip file separately, not together.

We have just recently switched from Aspose.PDF.Kit to Aspose.PDF; prior to the switch we did not receive these error.


Hi Cody,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for using Aspose.Pdf for .NET.

Are you facing the issue in concatenation of the attached PDF files? It would be better if you can share the code segment which is causing the problem with us. This will help us figure out the issue soon and rectify it accordingly.

Sorry for the inconvenience,

Yes, the issue is occurring when concatenating the attached files.

The problem is that we don’t know what could be causing this issue.

When we updated to Aspose.PDF from Aspose.PDF.Kit, we implemented the “KeepFieldsUnique” property. Other than that, there was no change in the code.

Here is the code that was added:

<span style=“font-size:7.5pt;
font-family:“Helvetica”,“sans-serif”;color:#519807”>//Instantiate PdfFileEditor

PdfFileEditor fileEditor = new PdfFileEditor();

//To keep unique field Id for all the fields

fileEditor.KeepFieldsUnique = true;

//Format of the suffix which is added to field name to make it unique when forms are concatenated.

fileEditor.UniqueSuffix = "_%NUM%";

//Call Concatenate method of PdfFileEditor object to concatenate all input streams into a single output stream

bool merged = fileEditor.Concatenate(InputFiles, OutputFile);

Hi Cody,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample code and template file.

I tested your scenario with the latest version of Aspose.Pdf for .NET v6.4.2 and the error I get for “Aspose PDF files.zip” and “Aspose PDF files 3.zip” is “Object Reference Not set to an instance of the Object”. Whereas, “Aspose PDF files 2.zip” concatenates fine. I have attached the resultant output file for your reference. Please download and try the latest version and let us know if your results are similar to mine. Also, I have registered the above mentioned issue in our issue tracking system with issue id: PDFNEWNET-32521. You will be notified via this forum thread regarding any updates against your issue.

Sorry for the inconvenience,

We are currently using v6.4.2 in our Production environment.

Is there any other way that I can track the issue id?

This is in production and we are receiving complaints from our customers.

Hi Cody,

Thanks for your patience. I am pleased to share that the issue reported earlier has been fixed and its resolution will be included in our next release version of Aspose.Pdf for .NET. As soon as the new version becomes available, we would be more than happy to update you with the status of correction. Your patience and comprehension is greatly appreciated in this regard. We apologize for your inconvenience.

Thank you for the information.

When can I expect the next release?

Hi Cody,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Well, as per our release plan, our next official release will be in January 2012 (Hopefully in first half of the month). As soon as the new release is available for download, we will update you via this forum thread.

Thank You & Best Regards,

The issues you have found earlier (filed as PDFNEWNET-32521) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.