PdfFileInfo Class Problems

I’ve been experiencing a problems with the PdfFileInfo class, but it’s been challenging for me to narrow down the exact problem in a smaller context, however I have been able to getting the same error message as in the much larger context that I am working with. I figure this would be a good starting information and I can provide more information if you need it.

Here is the code that generates the error:

PdfFileEditor pdfEditor = new PdfFileEditor();
Stream newPDF = new MemoryStream();
Pdf pdf = new Pdf();
pdf.Save(newPDF);

//Test PdfFileInfo Class
PdfFileInfo fileInfo = new PdfFileInfo(newPDF);

PdfFileInfo throws "Invalid pdf format:pdf head signature is not found!"

In the larger context I speak of, I split a file into an array of memory streams by using PdfFileEditor’s SplitToPages() method and then I load the individual stream in PdfFileInfo. For some reason it works the first time, but when I load the same individual memory stream a second time, it throws the same error I mention above, however I haven’t been able to replicate this at a smaller level for whatever reason.

This leads me to confusion. My main goal from loading individual pages into the PdfFileInfo class is to use the GetPageWidth() and GetPageHeight()

Hi Lewis,

Please try to move the memory streams to starting position before using it with the PdfFileInfo class. Please add the following line of code to move the stream to the starting position:


newPDF.Seek(0, SeekOrigin.Begin);

I hope this helps. If you still find any issues or further questions, please do let us know.
Regards,

Thank you, this worked.