[jira] [Commented] (PDFBOX-4177) PDFBox seems to scale up image while it should not

2018-04-02 Thread Tilman Hausherr (JIRA)

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

Tilman Hausherr commented on PDFBOX-4177:
-

What happens is also a misunderstanding that is difficult to explain. 1 unit is 
1/72 inch. So your image would look good if the PDF would be displayed at 
72dpi, which is what PDFDebugger does but Adobe doesn't (and neither does the 
windows default viewer, but IrfanView does). If you want your image to be small 
at the display resolution of your screen, you'll have to transform the current 
tranaformation matrix before showing your image. See the source Code comment in 
ImageToPDF:
{code:java}
// draw the image at full size at (x=20, y=20)
contents.drawImage(pdImage, 20, 20);

// to draw the image at half size at (x=20, y=20) use
// contents.drawImage(pdImage, 20, 20, pdImage.getWidth() / 2, 
pdImage.getHeight() / 2); 
{code}

> 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: comparison-tilman.png, comparison.png, test.jpg, test.pdf
>
>
> 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-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-4177) PDFBox seems to scale up image while it should not

2018-04-02 Thread Tilman Hausherr (JIRA)

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

Tilman Hausherr commented on PDFBOX-4177:
-

It's like I wrote, Adobe claims 100% but it isn't. Even my 100% are not the 
same as your 100%. Try displaying the file with PDFDebugger.

> 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: comparison-tilman.png, comparison.png, test.jpg, test.pdf
>
>
> 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-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-4177) PDFBox seems to scale up image while it should not

2018-04-02 Thread Kamil (JIRA)

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

Kamil commented on PDFBOX-4177:
---

I uploaded a screenshot showing how it looks on my machine.

I think, that both should be equal...

> 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: comparison.png, 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-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-4177) PDFBox seems to scale up image while it should not

2018-04-02 Thread Tilman Hausherr (JIRA)

[ 
https://issues.apache.org/jira/browse/PDFBOX-4177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org