Kevin Tabary created PDFBOX-4037:
------------------------------------
Summary: 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, 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]