Copying And Modification
createWriterToModify opens a PDF for incremental modification, either from a
file path or compatible input/output streams. Use PDFPageModifier to add
content to an existing page.
appendPDFPagesFromPDF, mergePDFPagesToPage, and createFormXObjectsFromPDF
provide writer-level document composition. createPDFCopyingContext creates a
DocumentCopyingContext for page-level append/merge, form creation, source
reader access, and advanced object copying.
mergePDFPagesToPage invokes its optional callback synchronously with no
arguments and the global object (globalThis) as this, including for strict
functions. Bound functions retain their bound receiver; arrow functions retain
their lexical this.
Advanced copying methods include copyObject, copyDirectObjectWithDeepCopy,
copyNewObjectsForDirectObject, and replaceSourceObjects.
Page append and source-page indexes in the low-level copying API are zero-based.
Always finish a copying context with end() after its final operation. Form
creation from a source page returns an object ID, not a placeable form object.
var writer = muhammara.createWriter("combined.pdf");
writer.appendPDFPagesFromPDF("source.pdf");
writer.end();
See Copy And Embed PDFs and Modify Existing PDFs for workflows.