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

Not correct support of incremental save

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: Writing
    • Labels:
      None

      Description

      When write code like follows:

      try {
      			PDDocument document = PDDocument.load(new File(SOURCE_PATH));
      			// SOME_OBJECT is not object number of catalog, info dictionary or encrypt
      			COSObjectKey key = new COSObjectKey(SOME_OBJECT, 0);
      			COSObject objectFromPool = document.getDocument().getObjectFromPool(key);
      			COSDictionary object = (COSDictionary) objectFromPool.getObject();
      			object.setItem(COSName.getPDFName("Test"), COSBoolean.TRUE);
      			object.setNeedToBeUpdated(true);
      			OutputStream writer = new BufferedOutputStream(new FileOutputStream(OUTPUT_PATH));
      			document.saveIncremental(writer);
      			writer.close();
      			document.close();
      		} catch (IOException e) {
      			e.printStackTrace();
      		}
      

      in result file I`ve got nothing. It`s related with next problem: when we use PDDocument.save(OutputStream) - OutputStream is real output stream (for example, FileOutputStream or BufferedOutputStream), but incremental save use ByteArrayOutputStream which not store data in some file and only keep it in memory. Also when save is incremental data from source file is not send to result file.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lehmi Andreas Lehmkühler
                Reporter:
                evgeniy.muravitskiy Evgeniy Muravitskiy
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: