You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Paulo Mello <pa...@portaldedocumentos.com.br> on 2013/09/27 16:33:59 UTC

Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Can help me with this problem:

 

Set 27, 2013 7:12:24 PM
org.apache.pdfbox.pdmodel.graphics.xobject.PDPixelMap getRGBImage

SEVERE: Something went wrong ... the pixelmap doesn't contain any data.

Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.operator.pagedrawer.Invoke
process

WARNING: getRGBImage returned NULL

Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator

INFO: unsupported/disabled operation: i

 

 

My code:

public static List<BufferedImage> getPdfPagesAsImages(String pdfPath, int i)

                    throws FileNotFoundException, IOException {

             int resolution = 185;

             File f = new File(pdfPath);

             FileInputStream is = null;

             is = new FileInputStream(f);

             System.out.println("PDFUtils: file loaded in directory:"

                           + pdfPath);

             List<BufferedImage> bImages = new ArrayList<BufferedImage>();

             PDDocument pdfDocument = null;

             PDFParser parser = new PDFParser(is);

             parser.parse();

             pdfDocument = parser.getPDDocument();

             if (pdfDocument != null) {

                    @SuppressWarnings("unchecked")

                    List<PDPage> pages = (List<PDPage>) pdfDocument

                                  .getDocumentCatalog().getAllPages();

                    int j = 1;

                    for (PDPage p : pages) {

                           BufferedImage convertedImage = p.convertToImage(

                                        BufferedImage.TYPE_INT_RGB,
resolution);

                           saveImageToRepository(i, j, convertedImage);

                           j++;

                           if (isNegativeImage(convertedImage)) {

 
bImages.add(invertNegativeImage(convertedImage));

                           } else {

                                  bImages.add(convertedImage);

                           }

                    }

             }

             pdfDocument.close();

             return bImages;

       }

 

 

       private static void saveImageToRepository(int i, int j,

                    BufferedImage convertedImage) throws IOException {

             File outputfile = new File("C:/images/pdfpages/" + i + j+
".png");

             ImageIO.write(convertedImage, "png", outputfile);

 

             //PDFImageWriter

 

       }

 

What I can programming to solve this warning.

Because this exception my app stop to work but the imagem was created

 

Thank you in advance for your attention




Paulo Mello
 <ma...@portaldedocumentos.com.br>
paulo.mello@portaldedocumentos.com.br 
Tel: (11) 5591-2100 – Ramal 110
Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
CEP: 04049-040
 <http://www.portaldedocumentos.com.br/> www.portaldedocumentos.com.br 


 

 

 

 


RES: RES: Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Posted by Paulo Mello <pa...@portaldedocumentos.com.br>.
Thank you Andreas
> PDDocument pdfDocument = PDDocument.loadNonSeq(is, null);
Its doesn't  work well. 
I have 10000 pdf to convert to image and about 30% about of this pdf throws
this kind of exception.


I tried many types of exceptions similar on the internet but seems to have
no connection with the problem I'm having.
:(



Paulo Mello
paulo.mello@portaldedocumentos.com.br 
Tel: (11) 5591-2100 – Ramal 110
Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
CEP: 04049-040
www.portaldedocumentos.com.br 




-----Mensagem original-----
De: Andreas Lehmkuehler [mailto:andreas@lehmi.de] 
Enviada em: sexta-feira, 27 de setembro de 2013 14:08
Para: users@pdfbox.apache.org
Assunto: Re: RES: Problem with PDPixelMap getRGBImage - Something went wrong
... the pixelmap doesn't contain any data

Hi,

Am 27.09.2013 18:57, schrieb Paulo Mello:
> Thanks Andreas, but  get the PDDocument during a parser()
>
> 		File f = new File(pdfPath);
> 		FileInputStream is = null;
> 		is = new FileInputStream(f);
>
> 		PDDocument pdfDocument = null;
> 		PDFParser parser = new PDFParser(is);
> 		parser.parse();
> 		pdfDocument = parser.getPDDocument();
>
>
> I dont use more the load method.
That's suboptimal ...

> I dont understand why this exception occurs.
> PS: I had not received the answer of my old question. sorry about that
OK, no problem

> Can you help me with my way in this situation?
Without the pdf i question I can only guess.

Try the non-sequential parser instead of your code:

PDDocument pdfDocument = PDDocument.loadNonSeq(is, null);

> Thank you a lot.
>
> My oldest question i did not received
> Paulo Mello
> paulo.mello@portaldedocumentos.com.br
> Tel: (11) 5591-2100 – Ramal 110
> Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
> CEP: 04049-040
> www.portaldedocumentos.com.br
>
>SNIP


BR
Andreas Lehmkühler





RES: RES: Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Posted by Paulo Mello <pa...@portaldedocumentos.com.br>.
Hi.
Thank you again.

I sended the pdf file for you.
Can you check if the problem is my file?
thanks


Paulo Mello
paulo.mello@portaldedocumentos.com.br 
Tel: (11) 5591-2100 – Ramal 110
Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
CEP: 04049-040
www.portaldedocumentos.com.br 




-----Mensagem original-----
De: Andreas Lehmkuehler [mailto:andreas@lehmi.de] 
Enviada em: sexta-feira, 27 de setembro de 2013 14:08
Para: users@pdfbox.apache.org
Assunto: Re: RES: Problem with PDPixelMap getRGBImage - Something went wrong
... the pixelmap doesn't contain any data

Hi,

Am 27.09.2013 18:57, schrieb Paulo Mello:
> Thanks Andreas, but  get the PDDocument during a parser()
>
> 		File f = new File(pdfPath);
> 		FileInputStream is = null;
> 		is = new FileInputStream(f);
>
> 		PDDocument pdfDocument = null;
> 		PDFParser parser = new PDFParser(is);
> 		parser.parse();
> 		pdfDocument = parser.getPDDocument();
>
>
> I dont use more the load method.
That's suboptimal ...

> I dont understand why this exception occurs.
> PS: I had not received the answer of my old question. sorry about that
OK, no problem

> Can you help me with my way in this situation?
Without the pdf i question I can only guess.

Try the non-sequential parser instead of your code:

PDDocument pdfDocument = PDDocument.loadNonSeq(is, null);

> Thank you a lot.
>
> My oldest question i did not received
> Paulo Mello
> paulo.mello@portaldedocumentos.com.br
> Tel: (11) 5591-2100 – Ramal 110
> Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
> CEP: 04049-040
> www.portaldedocumentos.com.br
>
>SNIP


BR
Andreas Lehmkühler





Re: RES: Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 27.09.2013 18:57, schrieb Paulo Mello:
> Thanks Andreas, but  get the PDDocument during a parser()
>
> 		File f = new File(pdfPath);
> 		FileInputStream is = null;
> 		is = new FileInputStream(f);
>
> 		PDDocument pdfDocument = null;
> 		PDFParser parser = new PDFParser(is);
> 		parser.parse();
> 		pdfDocument = parser.getPDDocument();
>
>
> I dont use more the load method.
That's suboptimal ...

> I dont understand why this exception occurs.
> PS: I had not received the answer of my old question. sorry about that
OK, no problem

> Can you help me with my way in this situation?
Without the pdf i question I can only guess.

Try the non-sequential parser instead of your code:

PDDocument pdfDocument = PDDocument.loadNonSeq(is, null);

> Thank you a lot.
>
> My oldest question i did not received
> Paulo Mello
> paulo.mello@portaldedocumentos.com.br
> Tel: (11) 5591-2100 – Ramal 110
> Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
> CEP: 04049-040
> www.portaldedocumentos.com.br
>
>SNIP


BR
Andreas Lehmkühler


RES: Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Posted by Paulo Mello <pa...@portaldedocumentos.com.br>.
Thanks Andreas, but  get the PDDocument during a parser()

		File f = new File(pdfPath);
		FileInputStream is = null;
		is = new FileInputStream(f);

		PDDocument pdfDocument = null;
		PDFParser parser = new PDFParser(is);
		parser.parse();
		pdfDocument = parser.getPDDocument();


I dont use more the load method. 
I dont understand why this exception occurs. 
PS: I had not received the answer of my old question. sorry about that

Can you help me with my way in this situation?

Thank you a lot.

My oldest question i did not received
Paulo Mello
paulo.mello@portaldedocumentos.com.br 
Tel: (11) 5591-2100 – Ramal 110
Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
CEP: 04049-040
www.portaldedocumentos.com.br 




-----Mensagem original-----
De: Andreas Lehmkuehler [mailto:andreas@lehmi.de] 
Enviada em: sexta-feira, 27 de setembro de 2013 12:19
Para: users@pdfbox.apache.org
Assunto: Re: Problem with PDPixelMap getRGBImage - Something went wrong ...
the pixelmap doesn't contain any data

Hi,

I already answered your question here [1]

BR
Andreas Lehmkühler

[1] http://apache.markmail.org/thread/v57skp4vlts5nzyi

Am 27.09.2013 16:33, schrieb Paulo Mello:
> Can help me with this problem:
>
> Set 27, 2013 7:12:24 PM
org.apache.pdfbox.pdmodel.graphics.xobject.PDPixelMap
> getRGBImage
>
> SEVERE: Something went wrong ... the pixelmap doesn't contain any data.
>
> Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.operator.pagedrawer.Invoke
process
>
> WARNING: getRGBImage returned NULL
>
> Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator
>
> INFO: unsupported/disabled operation: i
>
> My code:
>
> *public**static*List<BufferedImage> getPdfPagesAsImages(String pdfPath,
*int*i)
>
> *throws*FileNotFoundException, IOException {
>
> *int*resolution = 185;
>
>               File f = *new*File(pdfPath);
>
>               FileInputStream is = *null*;
>
>               is = *new*FileInputStream(f);
>
>               System./out/.println("PDFUtils: file loaded in directory:"
>
>                             + pdfPath);
>
>               List<BufferedImage> bImages =
*new*ArrayList<BufferedImage>();
>
>               PDDocument pdfDocument = *null*;
>
>               PDFParser parser = *new*PDFParser(is);
>
> _parser_.parse();
>
>               pdfDocument = parser.getPDDocument();
>
> *if*(pdfDocument != *null*) {
>
> @SuppressWarnings("unchecked")
>
>                      List<PDPage> pages = (List<PDPage>) pdfDocument
>
>                                    .getDocumentCatalog().getAllPages();
>
> *int*j = 1;
>
> *for*(PDPage p : pages) {
>
>                             BufferedImage convertedImage =
p.convertToImage(
>
>                                          BufferedImage./TYPE_INT_RGB/,
resolution);
>
> /saveImageToRepository/(i, j, convertedImage);
>
>                             j++;
>
> *if*(/isNegativeImage/(convertedImage)) {
>
>
> bImages.add(/invertNegativeImage/(convertedImage));
>
>                             } *else*{
>
>                                    bImages.add(convertedImage);
>
>                             }
>
>                      }
>
>               }
>
>               pdfDocument.close();
>
> *return*bImages;
>
>         }
>
> *private**static**void*saveImageToRepository(*int*i, *int*j,
>
>                      BufferedImage convertedImage) *throws*IOException {
>
>               File outputfile = *new*File("C:/images/pdfpages/"+ i + j+
".png");
>
>               ImageIO./write/(convertedImage, "png", outputfile);
>
> //PDFImageWriter
>
>         }
>
> What I can programming to solve this warning.
>
> Because this exception my app stop to work but the imagem was created
>
> Thank you in advance for your attention
>
> cid:image003.png@01CEB971.9F63E490
>
> 	
>
> *Paulo Mello*
> paulo.mello@portaldedocumentos.com.br
> <ma...@portaldedocumentos.com.br>
> Tel: (11) 5591-2100 – Ramal 110
> Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
> CEP: 04049-040
> www.portaldedocumentos.com.br <http://www.portaldedocumentos.com.br/>
>
> 	
>
> **
>





Re: Problem with PDPixelMap getRGBImage - Something went wrong ... the pixelmap doesn't contain any data

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

I already answered your question here [1]

BR
Andreas Lehmkühler

[1] http://apache.markmail.org/thread/v57skp4vlts5nzyi

Am 27.09.2013 16:33, schrieb Paulo Mello:
> Can help me with this problem:
>
> Set 27, 2013 7:12:24 PM org.apache.pdfbox.pdmodel.graphics.xobject.PDPixelMap
> getRGBImage
>
> SEVERE: Something went wrong ... the pixelmap doesn't contain any data.
>
> Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.operator.pagedrawer.Invoke process
>
> WARNING: getRGBImage returned NULL
>
> Set 27, 2013 7:12:24 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
>
> INFO: unsupported/disabled operation: i
>
> My code:
>
> *public**static*List<BufferedImage> getPdfPagesAsImages(String pdfPath, *int*i)
>
> *throws*FileNotFoundException, IOException {
>
> *int*resolution = 185;
>
>               File f = *new*File(pdfPath);
>
>               FileInputStream is = *null*;
>
>               is = *new*FileInputStream(f);
>
>               System./out/.println("PDFUtils: file loaded in directory:"
>
>                             + pdfPath);
>
>               List<BufferedImage> bImages = *new*ArrayList<BufferedImage>();
>
>               PDDocument pdfDocument = *null*;
>
>               PDFParser parser = *new*PDFParser(is);
>
> _parser_.parse();
>
>               pdfDocument = parser.getPDDocument();
>
> *if*(pdfDocument != *null*) {
>
> @SuppressWarnings("unchecked")
>
>                      List<PDPage> pages = (List<PDPage>) pdfDocument
>
>                                    .getDocumentCatalog().getAllPages();
>
> *int*j = 1;
>
> *for*(PDPage p : pages) {
>
>                             BufferedImage convertedImage = p.convertToImage(
>
>                                          BufferedImage./TYPE_INT_RGB/, resolution);
>
> /saveImageToRepository/(i, j, convertedImage);
>
>                             j++;
>
> *if*(/isNegativeImage/(convertedImage)) {
>
>
> bImages.add(/invertNegativeImage/(convertedImage));
>
>                             } *else*{
>
>                                    bImages.add(convertedImage);
>
>                             }
>
>                      }
>
>               }
>
>               pdfDocument.close();
>
> *return*bImages;
>
>         }
>
> *private**static**void*saveImageToRepository(*int*i, *int*j,
>
>                      BufferedImage convertedImage) *throws*IOException {
>
>               File outputfile = *new*File("C:/images/pdfpages/"+ i + j+ ".png");
>
>               ImageIO./write/(convertedImage, "png", outputfile);
>
> //PDFImageWriter
>
>         }
>
> What I can programming to solve this warning.
>
> Because this exception my app stop to work but the imagem was created
>
> Thank you in advance for your attention
>
> cid:image003.png@01CEB971.9F63E490
>
> 	
>
> *Paulo Mello*
> paulo.mello@portaldedocumentos.com.br
> <ma...@portaldedocumentos.com.br>
> Tel: (11) 5591-2100 – Ramal 110
> Rua dos Íris, 150 - Mirandópolis - São Paulo - SP
> CEP: 04049-040
> www.portaldedocumentos.com.br <http://www.portaldedocumentos.com.br/>
>
> 	
>
> **
>