Aspose.Words: Image to PDF- adds blank pages to output PDF document

I am using your sample code, to append an image to an existing PDF document. No errors are thrown, instead “blank” pages are added to the output PDF document. Attached is a sample application demonstrating the problem.

P.S the Aspose license is set via helper methods which will not be available to you. You need to modify the sample to use your own license file.

Please help a.s.a.p

Hi Jason,

Thanks for your inquiry and sorry for the delayed response. We’re checking with this scenario and will get back to you soon.

Best regards,

Hi Jason,

Thanks for your patience. I have tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem as WORDSNET-7674 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Jason,

It is to update you that our development team has finished working on your issue (WORDSNET-7674) and has come to a conclusion that your issue and the behavior you’re observing is actually not a bug in Aspose.Words. So, we’ve closed this issue as ‘Not a Bug’.

If you please open Microsoft Word and try to change the page height/width, you will see that the maximum allowed value is 1584pt. In your case image size is even bigger. So, to resolve this problem please modify ConvertImageToPdf method below:
https://docs.aspose.com/words/net/convert-a-document-to-pdf/

Please change the part of code like the following:

// We want the size of the page to be the same as the size of the image.
// Convert pixels to points to size the page to the actual image size.
PageSetup ps = builder.PageSetup;
// It is maximum allowed page size.
const double maxAllovedPageWidthHeight = 1584;
double width = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);
double height = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);
// It image size is bigger, then just set maximum allowed in this case.
if (width> maxAllovedPageWidthHeight)
    width = maxAllovedPageWidthHeight;
if (height> maxAllovedPageWidthHeight)
    width = maxAllovedPageWidthHeight;
ps.PageWidth = width;
ps.PageHeight = height;
// Insert the image into the document and position it at the top left corner of the page.

If we can help you with anything else, please feel free to ask.

Best regards,

The issues you have found earlier (filed as WORDSNET-7674) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan