You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Julie Jacobs <ju...@gmail.com> on 2019/03/04 08:04:09 UTC

insufficient data for an image

Hi,



We have a question regarding the pdfbox. We have a few pdf documents and we
need to convert it to .bmp images and then print them and present them in
bundles of 10. We are using the splitter functionality. The pdf documents
contain 1 small logo in the upper left corner and for the rest just plain
text.



Sometimes when we split the documents, the logo in the upper left corner is
missing. When we try to open the pdf document it says “insufficient data
for an image”.



First we have for example 3 PDF documents which contains 8 pages each à we
use the PDFMergerUtility to append all the documents and make 1 big
document. After checking this document à the logo is still ok.



*private* *PDDocument* *mergePdfDocuments*(List<PDDocument> documentList)
*throws* *IOException*

      {

             *PDFMergerUtility* *pdfMerger* = *new* PDFMergerUtility();

             *PDDocument* *mergedPDDocument* = *new* PDDocument();

             *for* (*PDDocument* *pdfDocument* : documentList)

             {

                   pdfMerger.appendDocument(mergedPDDocument, pdfDocument);

             }

             mergedPDDocument.save("C:\\temp\\MERGED\\1.pdf");

             *return* mergedPDDocument;

      }



After this method we close all the pdfDocuments in the documentList.

After that we split the mergedDocument into bundles (10 pages)  à and keep
them in memory.



*private* List<PDDocument> *splitIntoBundles*(*int* bundleSize, *PDDocument*
pdfDocument) *throws* *IOException*

      {

             *Splitter* *splitter* = *new* Splitter();

             splitter.setSplitAtPage(bundleSize);

             *return* splitter.split(pdfDocument);

      }



After the split into bundles we close the mergedDocument.

After that we split these bundles into pdf documents for every page with
the following code:



*private* List<PDDocument> *splitIntoPages*(*int* pageSize, *PDDocument*
pdfDocument) *throws* *IOException*

      {

             *Splitter* *splitter* = *new* Splitter();

             splitter.setSplitAtPage(pageSize);

             *return* splitter.split(pdfDocument);

      }



If we check these documents we notice that sometimes the logo is completely
missing.

Are we doing something wrong?



Thanks in advance!!



Kind regards,

Julie Jacobs

AW: insufficient data for an image

Posted by Tilman Hausherr <TH...@t-online.de>.
please tell what version you are using, upload your PDF to a sharehoster 
and post any log messages you got (may have to enable logging)

Tilman


------------------------------------------------------------------------
Gesendet mit der Telekom Mail App
<https://kommunikationsdienste.t-online.de/redirects/email_app_android_sendmail_footer>



--- Original-Nachricht ---
Von: Julie Jacobs
Betreff: insufficient data for an image
Datum: 04.03.2019, 9:04 Uhr
An: users@pdfbox.apache.org





Hi,



We have a question regarding the pdfbox. We have a few pdf documents and we
need to convert it to .bmp images and then print them and present them in
bundles of 10. We are using the splitter functionality. The pdf documents
contain 1 small logo in the upper left corner and for the rest just plain
text.



Sometimes when we split the documents, the logo in the upper left corner is
missing. When we try to open the pdf document it says “insufficient data
for an image”.



First we have for example 3 PDF documents which contains 8 pages each à we
use the PDFMergerUtility to append all the documents and make 1 big
document. After checking this document à the logo is still ok.



*private* *PDDocument* *mergePdfDocuments*(List<PDDocument> documentList)
*throws* *IOException*

{

*PDFMergerUtility* *pdfMerger* = *new* PDFMergerUtility();

*PDDocument* *mergedPDDocument* = *new* PDDocument();

*for* (*PDDocument* *pdfDocument* : documentList)

{

pdfMerger.appendDocument(mergedPDDocument, pdfDocument);

}

mergedPDDocument.save("C <http://mergedPDDocument.save("C> 
:\\temp\\MERGED\\1.pdf");

*return* mergedPDDocument;

}



After this method we close all the pdfDocuments in the documentList.

After that we split the mergedDocument into bundles (10 pages) à and keep
them in memory.



*private* List<PDDocument> *splitIntoBundles*(*int* bundleSize, 
*PDDocument*
pdfDocument) *throws* *IOException*

{

*Splitter* *splitter* = *new* Splitter();

splitter.setSplitAtPage(bundleSize
<http://splitter.setSplitAtPage(bundleSize> );

*return* splitter.split(pdfDocument);

}



After the split into bundles we close the mergedDocument.

After that we split these bundles into pdf documents for every page with
the following code:



*private* List<PDDocument> *splitIntoPages*(*int* pageSize, *PDDocument*
pdfDocument) *throws* *IOException*

{

*Splitter* *splitter* = *new* Splitter();

splitter.setSplitAtPage(pageSize <http://splitter.setSplitAtPage(pageSize> 
);

*return* splitter.split(pdfDocument);

}



If we check these documents we notice that sometimes the logo is completely
missing.

Are we doing something wrong?



Thanks in advance!!



Kind regards,

Julie Jacobs