ByteArray to PDF

Discussions about image processing and document imaging.
Post Reply
Dylan
Posts: 5
Joined: Wed Sep 29, 2021 2:51 am

ByteArray to PDF

Post by Dylan » Wed Sep 29, 2021 2:59 am

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

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: ByteArray to PDF

Post by Fabio » Wed Sep 29, 2021 9:48 am

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

Dylan
Posts: 5
Joined: Wed Sep 29, 2021 2:51 am

Re: ByteArray to PDF

Post by Dylan » Wed Sep 29, 2021 3:20 pm

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?

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: ByteArray to PDF

Post by Fabio » 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

Dylan
Posts: 5
Joined: Wed Sep 29, 2021 2:51 am

Re: ByteArray to PDF

Post by Dylan » Tue Oct 05, 2021 11:23 pm

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

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: ByteArray to PDF

Post by Fabio » Wed Oct 06, 2021 10:35 am

Hi Dylan,

I'm glad it suits you :)

Have a nice day,
Fabio

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 1 guest