"Incorrect file header"

After the attached document is uploaded to the system, “Incorrect file header” error is encountered.
Test project is attached
AsposeTestProject.zip (645.6 KB)

@srmbimser

The file present in the shared archive is not a valid PDF document. It has the size of 0KB. Could you please check and share a valid PDF document so that we can test the scenario in our environment and address it accordingly. Also, the Adobe Reader is unable to open it.

Error received document is attached
YG14920.pdf (453.5 KB)

@srmbimser

We did not notice any issue while loading the document which you shared using the API. Furthermore, we observed the below code in your shared application:

Document doc = new Document("original_doc.pdf");
FileStream file = new FileStream("original_doc.pdf", FileMode.Create);
doc.Save();

We were unable to understand what is the purpose of creating a new PDF using FileStream when it is already present in the system? Is it part of some other functionality that you are performing? Please elaborate a bit more about it so that we can better understand and test the scenario again at our end.

Document “object reference” error is encountered when saved with aspose.
YG14920_TestApp.zip (1.1 MB)

@srmbimser

The right way to use incremental saving approach is to initialize a Document with a Stream that has Read/Write permissions like in the below code:

Document doc2 = new Document(new FileStream(dataDir + "YG14920.pdf", FileMode.Open, FileAccess.ReadWrite));
doc2.Save();

We tested using the above code with 21.5 version of the API and were able to replicate the Exception of “object reference…”. Therefore, we have logged an issue as PDFNET-50056 in our issue tracking system. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi,
Any progress on PDFNET-50056?

@srmbimser

We regret to inform that the ticket could not get resolved due to other issues in the queue logged prior to it. However, we will surely inform you as soon as we make some definite progress towards ticket resolution or have any news about its fix ETA.

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFNET-50056) have been fixed in Aspose.PDF for .NET 22.8.