Serializes a PaperForge.Document into a valid PDF binary.
The writer is responsible for:
- writing the PDF header;
- serializing indirect objects;
- calculating byte offsets;
- generating the cross-reference table;
- generating the trailer;
- writing
startxrefand the EOF marker.
Summary
Functions
Converts a document into a complete PDF binary.
Writes a document incrementally and atomically to a filesystem path.
Functions
@spec to_binary(PaperForge.Document.t()) :: binary()
Converts a document into a complete PDF binary.
Example
binary =
PaperForge.Writer.to_binary(document)
File.write!(
"document.pdf",
binary
)
@spec write_to_file(PaperForge.Document.t(), Path.t()) :: :ok | {:error, File.posix() | term()}
Writes a document incrementally and atomically to a filesystem path.
PDF objects are serialized one at a time to a temporary file in the target directory. The completed file is renamed into place only after the xref and trailer have been written successfully.