Convert existing PDF to PNG

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
stewarth
Posts: 7
Joined: Mon Nov 10 2014

Convert existing PDF to PNG

Post by stewarth »

Hi -

I can convert PDFs to jpg pages but would like to convert them to PNG instead - could you advise on the process to perform this in C# please / whether it is possible in Amyuni PDF Converter?

Thanks
stewarth
Posts: 7
Joined: Mon Nov 10 2014

Re: Convert existing PDF to PNG

Post by stewarth »

Can someone from Amyuni please respond to this.

We are now looking at an alternative PDF generator to provide this functionality... and it would seem pointless to pay for two such tools going forward.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Re: Convert existing PDF to PNG

Post by Jose »

Hello,

Unfortunately our ExportToJPeg() method exports to JPEGs and not PNG.
https://www.amyuni.com/WebHelp/Amyuni_P ... Method.htm

Thanks
Get PDF Suite, the expert .NET developer toolkit for PDF conversion, creation and editing - www.amyuni.com/pdfsuite
stewarth
Posts: 7
Joined: Mon Nov 10 2014

Re: Convert existing PDF to PNG

Post by stewarth »

Can i suggest that it might be a good thing to add. PNG format is much better suited as an export format for textual documents than JPG is.
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Convert existing PDF to PNG

Post by Devteam »

Hello Stewarth

When using Amyuni PDF Creator .Net, there is alternate way of rasterizing a PDF file and saving the result as PNG. You can draw each page into a bitmap using the method IacDocument.DrawCurrentPage with the method System.Drawing.Graphics.FromImage. The code in C# should look like this:

Code: Select all

FileStream myFile = new FileStream ("test.pdf", FileMode.Open, FileAccess.Read);
IacDocument doc = new IacDocument(null);
doc.Open(myFile);
doc.CurrentPage = 1;
Image img = new Bitmap(100,100);
Graphics gph = Graphics.FromImage(img);
IntPtr hdc = gph.GetHDC();
doc.DrawCurrentPage(hdc, false);
gph.ReleaseHdc( hdc );

// Then save the image as PNG
img.Save(@"c:\temp\image.png", System.Drawing.Imaging.ImageFormat.Png);
Let us know if you have any questions about using this approach.

Best regards
Amyuni Support
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Post Reply