You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2018/04/02 11:17:00 UTC
[jira] [Commented] (PDFBOX-4177) PDFBox seems to scale up image
while it should not
[ https://issues.apache.org/jira/browse/PDFBOX-4177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16422143#comment-16422143 ]
Tilman Hausherr commented on PDFBOX-4177:
-----------------------------------------
I tried it and the image looks the same if it is displayed at the same size as the original. I think that Adobe Reader is misleading, when it claims "100%" on an enlarged image.
> PDFBox seems to scale up image while it should not
> --------------------------------------------------
>
> Key: PDFBOX-4177
> URL: https://issues.apache.org/jira/browse/PDFBOX-4177
> Project: PDFBox
> Issue Type: Bug
> Reporter: Kamil
> Priority: Major
> Attachments: test.jpg
>
>
> I have a test image (in attachment) and the following code:
> {code:java}
> public static void main(String[] args) {
> final String filename = "test.jpg";
> try (
> final PDDocument doc = new PDDocument();
> final FileInputStream input = new FileInputStream(new File(filename));
> final ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
> final FileOutputStream output = new FileOutputStream("test.pdf")
> ) {
> final PDImageXObject jpeg = PDImageXObject.createFromByteArray(doc, IOUtils.toByteArray(input), filename);
> final PDPage page = new PDPage(new PDRectangle(jpeg.getWidth(), jpeg.getHeight()));
> doc.addPage(page);
> try (final PDPageContentStream contents = new PDPageContentStream(doc, page)) {
> contents.drawImage(jpeg, 0, 0);
> }
> doc.save(pdfOut);
> pdfOut.flush();
> IOUtils.write(pdfOut.toByteArray(), output);
> }catch (Exception e) {
> e.printStackTrace();
> }
> }
> {code}
> The image in test.pdf is double sized (and quality is worse) than in original image
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org