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 2014/08/06 21:38:12 UTC

[jira] [Comment Edited] (PDFBOX-2260) Null Pointer Exception when writing an image

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

Tilman Hausherr edited comment on PDFBOX-2260 at 8/6/14 7:37 PM:
-----------------------------------------------------------------

1) You didn't tell what version you are using
2) Correct code is
{code}
PDDocument pdf = PDDocument.load (file);
{code}
or better:
{code}
PDDocument pdf = PDDocument.loadNonSeq (new File(file), null);
{code}

PS: tell "Prasanna" (from whom I suspect you got this code) that he should update from 0.7.3 to 1.8.6.


was (Author: tilman):
1) You didn't tell what version you are using
2) Correct code is
{code}
PDDocument pdf = PDDocument.load (file);
{code}
or better:
{code}
PDDocument pdf = PDDocument.loadNonSeq (file, null);
{code}

PS: tell "Prasanna" (from whom I suspect you got this code) that he should update from 0.7.3 to 1.8.6.

> Null Pointer Exception when writing an image
> --------------------------------------------
>
>                 Key: PDFBOX-2260
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2260
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>         Environment: Windows 7 64-bit
>            Reporter: Michael Deck
>            Priority: Blocker
>
> java.lang.NullPointerException 
> at org.apache.pdfbox.pdmodel.pddocument.getdocumentcatalog(pddocument.java:764) 
> at org.apache.pdfbox.util.pdfimagewriter.writeimage(pdfimagewriter.java:125)
> at myfile(26)
> My File:
> 21: File f = new File(file);
> 22: InputStream in = new FileInputStream(f);
> 23: BaseParser bp = new PDFParser(in);
> 24: PDDocument pdf = new PDDocument(new COSDocument(), bp);
> 25: PDFImageWriter writer = new PDFImageWriter();
> 26: writer.writeImage(pdf, "png", "", 1, 1, ".pdf", BufferedImage.TYPE_INT_RGB, 300);
> I am not sure why I am getting a null pointer exception. The pdf I am getting the image from has data in it.



--
This message was sent by Atlassian JIRA
(v6.2#6252)