Class PdfSmartCopy

All Implemented Interfaces:
DocListener, ElementListener, PdfAnnotations, PdfDocumentActions, PdfEncryptionSettings, PdfPageActions, PdfRunDirection, PdfVersion, PdfViewerPreferences, PdfXConformance, AutoCloseable, EventListener
Direct Known Subclasses:
UnembedFontPdfSmartCopy

public class PdfSmartCopy extends PdfCopy
PdfSmartCopy has the same functionality as PdfCopy, but when resources (such as fonts, images,...) are encountered, a reference to these resources is saved in a cache, so that they can be reused. This requires more memory, but reduces the file size of the resulting PDF document.
  • Field Details

  • Constructor Details

  • Method Details

    • copyIndirect

      Translate a PRIndirectReference to a PdfIndirectReference In addition, translates the object numbers, and copies the referenced object to the output file if it wasn't available in the cache yet. If it's in the cache, the reference to the already used stream is returned.

      NB: PRIndirectReferences (and PRIndirectObjects) really need to know what file they came from, because each file has its own namespace. The translation we do from their namespace to ours is *at best* heuristic, and guaranteed to fail under some circumstances.

      Overrides:
      copyIndirect in class PdfCopy
      Parameters:
      in - the PRIndirectReference to translate
      Returns:
      the translated PRIndirectReference
      Throws:
      IOException - on error
      BadPdfFormatException - on error with the Pdf format