[ 
https://issues.apache.org/jira/browse/PDFBOX-4037?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16298587#comment-16298587
 ] 

Tilman Hausherr commented on PDFBOX-4037:
-----------------------------------------

I created the attached PDF with ImageToPDF utility, the only difference is that 
it draws at x=20 y=20.

Showing it with Adobe Reader at 100% shows it inflated, there are "stairs". I 
suspect this is because my screen is at 125%.

Then I displayed it with IrfanView and with PDFBox (at 72dpi, regardless of the 
screen dpi) and then they have the same sizes.

The content stream has this:
{code}
q
  36 0 0 35 20 20 cm
  /Im1 Do
Q
{code}
36 and 35 are the sizes of the image, which are used for an affine 
transformation. So all is working as expected.

The "inflate" effect can also be observed with PDFDebugger 2.0.4 and older 
(that was fixed in PDFBOX-3665).

> Appending an image to an already existing PDF does not preserve image size
> --------------------------------------------------------------------------
>
>                 Key: PDFBOX-4037
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4037
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.8
>            Reporter: Kevin Tabary
>         Attachments: after_rendering.PNG, result.pdf, screenshot.png, 
> signature.png
>
>
> Given an already existing document on which I want to append a small image at 
> position (0;0) on the first page, when saving the PDF, the image appears 
> somehow bigger than its original size.
> Please find below the code I am using:
> {code}
>       public void mergePdfWithImages(MultipartFile pdf, MultipartFile image) 
> throws Exception {
>               PDDocument pdfDocument = PDDocument.load(pdf.getInputStream());
>               PDPage pdfPage = pdfDocument.getPage(0);
>               PDImageXObject pdfImage = 
> PDImageXObject.createFromByteArray(pdfDocument, image.getBytes(), null);
>               PDPageContentStream pageContentStream = new 
> PDPageContentStream(pdfDocument, pdfPage, 
> PDPageContentStream.AppendMode.APPEND, true, true);
>               pageContentStream.drawImage(pdfImage, 0, 0);
>               pageContentStream.close();
>               pdfDocument.save("C:\\Data\\result.pdf");
>               pdfDocument.close();
>       }
> {code}
> I tried to set the flag compress / resetContext to any combination of 
> true/false without any success. Please find the image (signature.png) I am 
> using as well as the comparison after the PDF is rendered 
> (afrer_rendering.png): the image appended on it is clearly bigger than its 
> original size, is there any way to  preserve original size ?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to