Welcome Guest Search | Active Topics | Sign In | Register

Create PdfDocument from Byte Array Options
Shah Shaik
Posted: Friday, April 13, 2018 5:15:30 PM
Rank: Newbie
Groups: Member

Joined: 4/13/2018
Posts: 2
Hi,

I am creating new PdfDocument from a Stream using byte array as an input.

document creation is failing with the 'No version info in header' error. And stack trace is below.

at EO.Pdf.Internal.g1.e()
at EO.Pdf.Internal.g1.a(Boolean A_0, PdfDocumentSecurity A_1)
at EO.Pdf.Internal.hf.a(Stream A_0, Boolean A_1)
at EO.Pdf.Internal.hf..ctor(Stream A_0, PdfDocumentSecurity A_1, Boolean A_2)
at EO.Pdf.PdfDocument..ctor(Stream stream)
at DocumentRegenerator.Tasks.CreateDocumentsTask.AddTaskId(Customer customer)

When I used the same byte array input and write to a File and creating PdfDocument works fine.

Please let me know if you need any additional input to reproduce the issue.

Thanks,
Shah.
eo_support
Posted: Friday, April 13, 2018 7:06:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
This usually is caused by the current position of the Stream is at the wrong place when you pass it to the PdfDocument. The PdfDocument reads from the current position of the Stream, not the beginning of the Stream. So if your contents start from the beginning of the Stream, you need to move the Stream's current position to the beginning before you pass it to the PdfDocument.
Shah Shaik
Posted: Monday, April 16, 2018 11:07:36 AM
Rank: Newbie
Groups: Member

Joined: 4/13/2018
Posts: 2
I was initially getting the following error
'Error parsing input stream at offset 95476. Expecting 'New line' but end of the file reached.'

After going thru the below forum suggestion, I set the steam seek begining of the steam
https://www.essentialobjects.com/forum/postst9682_Error-in-downloading-the-pdf-using-Stream.aspx

Both the following statement by Seek or Position didn't worked.
stream.Seek(0, SeekOrigin.Begin);
stream.Position = 0;

The error I am getting now is 'No version info in header'.
eo_support
Posted: Monday, April 16, 2018 12:09:36 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

If you save the same byte array into a physical file and then create PdfDocument from that file and it works fine, then PdfDocument is working correctly. The only difference between a byte array and a physical file is current position of the stream.

If you still have problems, please try to isolate the problem into a small test application that demonstrates the following:

1. Receiving errors when you load PdfDocument from byte array;
2. Working fine when you save the same byte array into a file and PdfDocument loads fine;

Once you have the test app you can send it to us and we will investigate further. See here for more information on how to send the test app to us:

https://www.essentialobjects.com/forum/test_project.aspx

You will need to isolate the portion of your application that gets/generates the byte array and replace it with some other code that we can run it here. For example, you can save the byte array in a file and then load it with File.ReadAllBytes. This is because how your byte array is generated is unrelated to the problem, it's the contents of the byte array and how you use the byte array that can be related to the problem.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.