...master 2026-11-12 (1037e2069+unstaged)

DocumentWriter

DocumentWriter objects are used to create new documents in several formats.

Constructors

class DocumentWriter(buffer, format, options)

class DocumentWriter(filename, format, options)

Create a new document writer to create a document with the specified format and output options. If format is null it is inferred from the filename. The options argument is a comma-separated list of flags and key-value pairs.

For supported output format values and options see Document Writer Options.

var writer = new mupdf.DocumentWriter(buffer, "PDF", "")

Instance methods

DocumentWriter.prototype.beginPage(mediabox)

Begin rendering a new page. Returns a Device that can be used to render the page graphics.

var device = writer.beginPage([0, 0, 100, 100])

DocumentWriter.prototype.endPage()

Finish the page rendering.

writer.endPage()

DocumentWriter.prototype.close()

Finish the document and flush any pending output. It is a requirement to make this call to ensure that the output file is complete.

writer.close()