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

Infinite loop after splitting and saving PDF / giant result files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.31, 3.0.2 PDFBox
    • 2.0.32, 3.0.3 PDFBox, 4.0.0
    • Utilities
    • None

    Description

      I use PDFBox to split hundreds of PDFs per day, generally, everything works flawlessly but I just received a PDF that generates an infinite loop when I try to split it.

       

      I used this Java code to reproduce it using PDFBox 3.0.2 (haven't tried other versions):

      private static void splitPdf(File fileToSplit) {
        try (PDDocument document = Loader.loadPDF(fileToSplit)) {
          int documentPages = document.getNumberOfPages();
          Splitter splitter = new Splitter();
          List<PDDocument> Pages = splitter.split(document);
          Iterator<PDDocument> iterator = Pages.listIterator();
          while (iterator.hasNext()) {
            PDDocument pd = iterator.next();
            pd.save(fileToSplit.getName() + "-" + Pages.indexOf(pd) + ".pdf");
            pd.close();
          }
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      } 

      The PDF file is attached to the issue

      Attachments

        1. screenshot-1.png
          28 kB
          Tilman Hausherr
        2. cbc0018b-5659-4ae3-9887-0e0a2d9a62a7.pdf
          52.81 MB
          Joan Fisbein
        3. 706213.pdf
          25 kB
          Tilman Hausherr

        Activity

          People

            Unassigned Unassigned
            jfisbein-clarity Joan Fisbein
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: