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

NullPointerException when doing overlay

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.15, 2.0.11
    • 1.8.16, 2.0.12, 3.0.0 PDFBox
    • Utilities
    • None

    Description

      When input pdf file for overlay contains empty page (with contents == null) like NPE.pdf file we get NullPointerException in Overlay.addOriginalContent method. It occurres even if we overlay over other than this empty page.

      Here's some sample code to reproduce the problem:

      Overlay overlayObj = new Overlay();
      File file1 = new File("NPE.pdf");
      PDDocument originalDoc = PDDocument.load(file1);
      overlayObj.setOverlayPosition(Overlay.Position.FOREGROUND);
      overlayObj.setInputPDF(originalDoc);
      Map<Integer, String> ovmap = new HashMap<>();
      File file2 = new File("pdf2.pdf");
      ovmap.put(2, file2.getPath());
      overlayObj.overlay(ovmap);
      originalDoc.save("test__result.pdf");
      

      Attachments

        1. NPE.pdf
          13 kB
          Mikita Geer
        2. pdf2.pdf
          29 kB
          Mikita Geer

        Activity

          People

            tilman Tilman Hausherr
            mikita.geer Mikita Geer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: