Page 1 of 1

ByteArray to PDF

Posted: Wed Sep 29, 2021 2:59 am
by Dylan
Hey,

I am trying to use the byte array from an uploaded pdf, to just print the pdf. Essentially the same issue that was listed in this post https://gdpicture.com/forum/viewtopic.php?t=1721

Did this ever get a solution? I specifically am wanting to print a pdf without first loading it into ImageViewer. I have the byte array, just need a way to print it or make a usable imageId out of it.

Thank you

Re: ByteArray to PDF

Posted: Wed Sep 29, 2021 9:48 am
by Fabio
Hello Dylan,

Could you elaborate on your issue, please?
Does the oGdPictureImaging.CreateGdPictureImageFromByteArray() returns a 0?

Just to avoid any issue that was already corrected, could you update your GdPicture SDK to the latest version and tell me if the issue remains?

With best,
Fabio

Re: ByteArray to PDF

Posted: Wed Sep 29, 2021 3:20 pm
by Dylan
Yes, oGdPictureImaging.CreateGdPictureImageFromByteArray() returns a zero. The byte array represents a pdf that I am wanting to print, still as a pdf. I am using a version 14.0.0.7, where the post I linked was using 6.6. Has this functionality been added since then? Or does anyway exist to print a pdf without loading it into the viewer using a byte array?

Re: ByteArray to PDF

Posted: Thu Sep 30, 2021 4:50 pm
by Fabio
Hello Dylan,

This is expected that the oGdPictureImaging.CreateGdPictureImageFromByteArray() returns a zero if you give it a PDF as input.
The GdPictureImaging class is for raster images and GdPicturePDF for PDF.

Here is a code snippet I made for loading a byte array into a GdPicturePDF object:

Code: Select all

byte[] bytes = System.IO.File.ReadAllBytes(@"D:\Filesample.pdf");
GdPicturePDF oPdf = new GdPicturePDF();
MemoryStream ms = new MemoryStream(bytes);
oPdf.LoadFromStream(ms);
//oPdf.GetStat();
And you will find all the information about the print process with a GdPicturePDF object here: https://www.gdpicture.com/guides/gdpict ... Print.html

By the way, it is recommended to update your GdPicture SDK (your current version was released the June 16th, 2017) if you face any issue, just to avoid old corrected bugs.

With best,
Fabio

Re: ByteArray to PDF

Posted: Tue Oct 05, 2021 11:23 pm
by Dylan
Fabio wrote:
Thu Sep 30, 2021 4:50 pm
Hello Dylan,

This is expected that the oGdPictureImaging.CreateGdPictureImageFromByteArray() returns a zero if you give it a PDF as input.
The GdPictureImaging class is for raster images and GdPicturePDF for PDF.

Here is a code snippet I made for loading a byte array into a GdPicturePDF object:

Code: Select all

byte[] bytes = System.IO.File.ReadAllBytes(@"D:\Filesample.pdf");
GdPicturePDF oPdf = new GdPicturePDF();
MemoryStream ms = new MemoryStream(bytes);
oPdf.LoadFromStream(ms);
//oPdf.GetStat();
And you will find all the information about the print process with a GdPicturePDF object here: https://www.gdpicture.com/guides/gdpict ... Print.html

By the way, it is recommended to update your GdPicture SDK (your current version was released the June 16th, 2017) if you face any issue, just to avoid old corrected bugs.

With best,
Fabio
Thanks Fabio! That code worked perfectly. I'll try to work on getting version updated for both of our sakes lol

Re: ByteArray to PDF

Posted: Wed Oct 06, 2021 10:35 am
by Fabio
Hi Dylan,

I'm glad it suits you :)

Have a nice day,
Fabio