DocumentWriter#

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

CONSTRUCTOR METHODS

DocumentWriter(buffer: Buffer, format: string, options: string)#

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

The output format & options are the same as in the mutool convert command.

Parameters:
  • bufferBuffer. The buffer to output to.

  • formatstring. The file format.

  • optionsstring. The options as key-value pairs.

Returns:

DocumentWriter.

EXAMPLE

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

INSTANCE METHODS

beginPage(mediabox: Rect)#

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

Parameters:

mediaboxRect.

Returns:

Device.

EXAMPLE

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

Finish the page rendering.

EXAMPLE

writer.endPage();
close()#

Finish the document and flush any pending output.

EXAMPLE

writer.close();

Code samples

Code samples are in TypeScript and assume that the following requirements are defined in your TypeScript file header as follows:

import * as fs from "fs"
import * as mupdfjs from "mupdf/mupdfjs"