We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding image to pdf does not display in correct size

I am following the guidelines provided from: http://www.aspose.com/docs/display/pdfnet/Add+Image+to+Existing+PDF+File


Running through the same code for 2 different PDF’s, adding the same image with the same dimensions, I am getting two completely separate results. I’ve attached the two output pdf’s. The “goodOutput.pdf” displays how I would expect. “badOutput.pdf” has the image scaled down.

My initial thought was that the pdf’s had different dimensions or sizes, but comparing all of the document properties, they appear identical. Is there some setting, scaling or property that I am missing?

Thanks for any help,
Bryan

Hi Bryan,


Thanks for using our API’s.

Can you please share the resource input files, on which images are being placed, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Absolutely, thank you for the response. I’ve attached a “GoodForm.pdf” and “BadForm.pdf” which are the originals that I am using for this repro.


I should also mention that I am using the most recent version I saw available of Aspose.pdf. Version 11.5.0

I did notice something else. I believe there is something different or wrong on the original forms that I am trying to add the images to, or some property or setting is changed during the Document.Save() method.


If I take the original form, add an image and then save that PDF, it will appear incorrectly. If I then take that saved PDF that I had previously added an image to, and add another image, the subsequent image is displayed correctly. Is something being changed or set differently in the Document.Save() method?

Hi Bryan,


Thanks for sharing the resource files.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNEWNET-40732 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
bwadams:
I did notice something else. I believe there is something different or wrong on the original forms that I am trying to add the images to, or some property or setting is changed during the Document.Save() method.

If I take the original form, add an image and then save that PDF, it will appear incorrectly. If I then take that saved PDF that I had previously added an image to, and add another image, the subsequent image is displayed correctly. Is something being changed or set differently in the Document.Save() method?
Hi Bryan,

Thanks for sharing the feedback. The information has been associated with recently logged PDFNEWNET-40732 and product team will surely consider it during the resolution of this problem. As soon as we have some definite updates regarding its resolution, we will let you know.

Thank you for logging this into your system. While trying to find a work around on my end, I ran across something else I’d like to mention. The above solution I mentioned, where you can save the pdf and the saved version will be corrected will only work when there is no license being used.


Once I add in our license, this workflow is no longer correct and the saved pdf will still have the issue.

EDIT:
Going along with this, it appears that when you add in text onto a page, such as what is done with the evaluation message that is added when not using a license, it fixes the issue for that specific page within the document. It appears that this alters the page information, but I’m not sure what exactly it is changing on the original pdf.

var pdfPage = document.Pages[1];
var textFragment = new TextFragment("");
textFragment.Position = new Position(0, 0);
var textBuilder = new TextBuilder(pdfPage);
textBuilder.AppendText(textFragment);
bwadams:
Thank you for logging this into your system. While trying to find a work around on my end, I ran across something else I'd like to mention. The above solution I mentioned, where you can save the pdf and the saved version will be corrected will only work when there is no license being used.

Once I add in our license, this workflow is no longer correct and the saved pdf will still have the issue.

EDIT:
Going along with this, it appears that when you add in text onto a page, such as what is done with the evaluation message that is added when not using a license, it fixes the issue for that specific page within the document. It appears that this alters the page information, but I'm not sure what exactly it is changing on the original pdf.

var pdfPage = document.Pages[1];
var textFragment = new TextFragment("");
textFragment.Position = new Position(0, 0);
var textBuilder = new TextBuilder(pdfPage);
textBuilder.AppendText(textFragment);
Hi Bryan,

Thanks for sharing the details.

The information has been associated with earlier reported issue and we will surely consider these scenarios while resolving this problem. As soon as we have some further updates, we will let you know.