简体   繁体   中英

NullPointerException while PDF to image conversion

While I was playing around with pdfbox 1.7.0 (apache) I came across a NullPointerException . I can't figure out what the hack is wrong with my code. You can see the full stacktrace of the Exception at http://pastebin.com/XEuv7VmU and the code here: http://pastebin.com/vJYBwWtq .

I just want to convert every page of a PDF into an image ( BufferedImage ).

Either I am missing something obvious or there is a bug in the library. Type3StreamParser extending PDFStreamEngine has the following method:

public Image createImage( COSStream type3Stream ) throws IOException
{
    processStream( null, null, type3Stream );
    return image.createImage();
}

it calls processStream() in the base class defined as follows:

public void processStream( PDPage aPage, PDResources resources, COSStream cosStream ) throws IOException
{
    graphicsState = new PDGraphicsState(aPage.findCropBox());
    //...
}

Clearly this code will always throw NPE. If you aren't misusing the API somehow, consider reporting an issue .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM