Problem converting PDF to PNG

Hi,

I use Aspose PDF to convert PDF to PNG using a regular code like this:

//Create Resolution object
Resolution resolution = new Resolution(300);

//create PNG device with specified attributes
PngDevice pngDevice = new PngDevice(resolution);

//Convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);

I works well except with attached “A4-300dpi.pdf” file for which output png file is too small (as a thumbnail).
Here is the output file: https://dl.dropboxusercontent.com/u/30379575/output.png

Aspose.Pdf.dll version: 8.9.0.0 (2014.02.07)

Is it a bug in Aspose Pdf?

Hi Christophe,

Thanks for your inquiry. While testing the scenario with your shared document, we have managed to reproduce the issue with latest version of Aspose.Pdf for .NET 9.6.0. We have logged a ticket PDFNEWNET-37527 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tital,

Do you have any update regarding this issue?

Best regards,

Hi Christophe,


Thanks for your inquiry. I am afraid your reported issue is still pending for investigation due to other priority tasks. However, we have requested our development team to complete the investigation and share an ETA at their earliest. We will update you as soon as we get a feedback.

We are sorry for the inconvenience caused.

Best Regards
Hi Tital,

Do you have any update regarding this issue?

The issue with this PDF is probably that "Media Box" size corresponds to A4 and "Crop Box" size corresponds to A0.

Best Regards,

Christophe

Hi Christophe,


Thanks for your inquiry and patience. You are right, issue cause is difference in Media Box and Crop Box size. So please use following code snippet to rectify the issue. Hopefully it will help you to accomplish the task.

Document pdfDocument = new Document(myDir

  • “A4-300dpi.pdf”);<o:p></o:p>

for (int pageCount = 1; pageCount <= 1; pageCount++)

{

string outputImageFile = myDir+"37527.png";

using (FileStream imageStream = new FileStream(outputImageFile, FileMode.Create))

{

Resolution resolution = new Resolution(300);

PngDevice pngDevice = new PngDevice(resolution);

if (!pdfDocument.Pages[pageCount].CropBox.Equals(pdfDocument.Pages[pageCount].MediaBox))

{

pngDevice.CoordinateType = PageCoordinateType.MediaBox;

}

//convert a particular page and save the image to stream

pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);

//close stream

imageStream.Close();

}

}

Please feel free to contact us for any further assistance.


Best Regards,

That seems to work

Thank you

Hi Christophe,


We are glad to hear that your problem is resolved. Please continue using our API and in the event of any further query, please feel free to contact.

The issues you have found earlier (filed as PDFNEWNET-37527) have been fixed in Aspose.Pdf for .NET 9.9.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.