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

NullPointerException when doing overlay

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.15, 2.0.11
    • Fix Version/s: 1.8.16, 2.0.12, 3.0.0 PDFBox
    • Component/s: Utilities
    • Labels:
      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. pdf2.pdf
          29 kB
          Mikita Geer
        2. NPE.pdf
          13 kB
          Mikita Geer

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: