You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Grant Overby (JIRA)" <ji...@apache.org> on 2010/10/01 22:21:34 UTC
[jira] Created: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
--------------------------------------------------------------------------------------------
Key: PDFBOX-849
URL: https://issues.apache.org/jira/browse/PDFBOX-849
Project: PDFBox
Issue Type: Bug
Components: Writing
Affects Versions: 1.2.1
Environment: Windows XP sp3 x86
Reporter: Grant Overby
I create a buffered image as:
BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
I draw various thing to the graphics of bf .
I then use bf in the following:
PDDocument pdDocument = new PDDocument();
// loop
BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
pdDocument.addPage(pdPage);
// end loop
pdDocument.save(outputStream = new FileOutputStream(file));
The resulting pdf can be downloaded at
http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917068#action_12917068 ]
Andreas Lehmkühler commented on PDFBOX-849:
-------------------------------------------
I think we should add a section to our documention on howto add images to a pdf and/or improve the ImageToPDF example. I will try to find some time at the weekend to do that.
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
> Fix For: 1.2.1
>
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Grant Overby (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917075#action_12917075 ]
Grant Overby commented on PDFBOX-849:
-------------------------------------
>From the example above, as a new user, I was also surprised that when constructing a new PdPageContentStream with appendContent = true throws a NullPointerException when no ContentStream currently exists.
I expected behavior similar to FileOutputStream's append.
A note about this in ImageToPDF might also be helpful to others.
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
> Fix For: 1.2.1
>
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (PDFBOX-849) saved pdf causes "insufficient data for
an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Grant Overby (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Grant Overby closed PDFBOX-849.
-------------------------------
Fix Version/s: 1.2.1
Resolution: Invalid
Issue was due to user error.
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
> Fix For: 1.2.1
>
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Grant Overby (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917053#action_12917053 ]
Grant Overby commented on PDFBOX-849:
-------------------------------------
adding contentStream.close(); doesn't help
contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
contentStream.close();
pdDocument.addPage(pdPage);
It may be worth noting that each page is intended to contain a single image.
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Grant Overby (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917060#action_12917060 ]
Grant Overby commented on PDFBOX-849:
-------------------------------------
I misread your comment. Your recommendation does indeed work.
Thank you.
PDDocument pdDocument = new PDDocument();
// loop
BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
PDJpeg pdJpeg = new PDJpeg(pdDocument,image);
contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
contentStream.drawImage(pdJpeg,border,border);
pdDocument.addPage(pdPage);
// end loop
pdDocument.save(outputStream = new FileOutputStream(file));
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (PDFBOX-849) saved pdf causes "insufficient data
for an image when opened with Adobe Acrobat Reader 9.2.0
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917047#action_12917047 ]
Andreas Lehmkühler commented on PDFBOX-849:
-------------------------------------------
I guess the order of adding the content is the key. You couldn't add images if a content stream is still open.
Try somethinsg like this
...
image1 = new PDJpeg(...)
stream = new PDPageContentStream(...)
stream.drawImage(image1...)
...
stream.close()
image2 = new PDJpeg(...)
stream = new PDPageContentStream(...)
stream.drawImage(image2...)
...
stream.close()
..
> saved pdf causes "insufficient data for an image when opened with Adobe Acrobat Reader 9.2.0
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-849
> URL: https://issues.apache.org/jira/browse/PDFBOX-849
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.2.1
> Environment: Windows XP sp3 x86
> Reporter: Grant Overby
>
> I create a buffered image as:
> BufferedImage bf = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
> I draw various thing to the graphics of bf .
> I then use bf in the following:
> PDDocument pdDocument = new PDDocument();
> // loop
> BufferedImage image = myObject.toBufferedImage(); // returns the bf from above
> PDPage pdPage = new PDPage(new PDRectangle(image.getWidth() + border * 2, image.getHeight() + border * 2));
> pdPage.setRotation(myObject.getRotation()); // getRotation() is an int and a multiple of 90
> contentStream = new PDPageContentStream(pdDocument,pdPage,false,false);
> contentStream.drawImage(new PDJpeg(pdDocument,image),border,border);
> pdDocument.addPage(pdPage);
> // end loop
> pdDocument.save(outputStream = new FileOutputStream(file));
> The resulting pdf can be downloaded at
> http://www.floorsoft.com/grant/pdfbox/TestSave2.pdf
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.