java.lang.Object
org.sejda.sambox.output.PDFBodyWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,COSVisitor
- Direct Known Subclasses:
ExistingPagesSizePredictor,IncrementalPDFBodyWriter
Base component providing methods to write the body of a pdf document. This implementation starts from the document
trailer and visits the whole document graph updating the
PDFWriteContext. An
IndirectCOSObjectReference is created by the context for each COSDictionary and
ExistingIndirectCOSObject, if not previously created. Once all the values of a COSDictionary or
COSArray have been explored, the COSDictionary/ COSArray is written as a pdf object, this
allows an async implementation to write objects while the body writer is still performing its algorithm.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PDFWriteContext(package private) PDFBodyObjectsWriterprivate booleanprivate Queue<IndirectCOSObjectReference> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()(package private) PDFWriteContextcontext()(package private) final voidvoidCalled during the visit on the objects graph, when a potential indirect object is met.private booleanshouldBeIndirect(COSBase item) (package private) voidStarts writing whatever has been stackedvoidvoidvisit(COSDictionary value) voidvisit(COSDocument document) voidvoidwrite(COSDocument document) Writes the body of the given documentvoidwrite(IncrementablePDDocument document) Writes the given document
-
Field Details
-
stack
-
context
-
open
private boolean open -
objectsWriter
PDFBodyObjectsWriter objectsWriter
-
-
Constructor Details
-
PDFBodyWriter
PDFBodyWriter(PDFWriteContext context, PDFBodyObjectsWriter objectsWriter)
-
-
Method Details
-
context
PDFWriteContext context() -
write
Writes the given document- Parameters:
document-- Throws:
IOException
-
write
Writes the body of the given document- Parameters:
document-- Throws:
IOException
-
visit
- Specified by:
visitin interfaceCOSVisitor- Throws:
IOException
-
startWriting
Starts writing whatever has been stacked- Throws:
IOException
-
visit
- Specified by:
visitin interfaceCOSVisitor- Throws:
IOException
-
visit
- Specified by:
visitin interfaceCOSVisitor- Throws:
IOException
-
visit
- Specified by:
visitin interfaceCOSVisitor- Throws:
IOException
-
shouldBeIndirect
-
onPotentialIndirectObject
Called during the visit on the objects graph, when a potential indirect object is met. Default implementation creates a new indirect reference for it.- Parameters:
item-- Throws:
IOException
-
createIndirectReferenceIfNeededFor
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-