[ https://issues.apache.org/jira/browse/PDFBOX-4037?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr closed PDFBOX-4037. ----------------------------------- Resolution: Not A Bug > 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: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org