Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1601

java.lang.IllegalArgumentException: Width (4032) and height (-2880) cannot be <= 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.1
    • 1.8.2
    • None
    • None
    • Centos 6

    Description

      We're using pdfbox-1.8.1.jar to convert PDF to JPGs.
      Below is part of a stacktrace we see when converting a PDF of size 500Kb

      java.lang.IllegalArgumentException: Width (4032) and height (-2880) cannot be <= 0
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
      at java.awt.image.BufferedImage.<init>(Unknown Source)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:752)
      at org.apache.pdfbox.util.PDFImageWriter.writeImage(PDFImageWriter.java:115)

      We use PDDocument.load(File). As suggested, we tried with loadNonSeq and also the non sequential form of load as below. Also tried it with a FileInputStream and File. All these forms of load gave us the same error.

      raf = new RandomAccessFile(new File("/tmp/nonSeqPdfFile"), "rw");
      document = PDDocument.load(new FileInputStream(inputFile), raf);
      PDFImageWriter imageWriter = new PDFImageWriter();
      success = imageWriter.writeImage(document, imageFormat, password, startPage, endPage, pdfWorkFilePrefix, imageType, resolution);

      Attachments

        1. failingtoload.pdf
          448 kB
          Asmita Joshi
        2. try1.pdf
          53 kB
          Keith Fernandez

        Activity

          People

            lehmi Andreas Lehmkühler
            asmitaj Asmita Joshi
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: