File: DocumentWriter.rst

package info (click to toggle)
mupdf 1.27.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,224 kB
  • sloc: ansic: 335,320; python: 20,906; java: 7,520; javascript: 2,213; makefile: 1,152; xml: 675; cpp: 639; sh: 513; cs: 307; awk: 10; sed: 7; lisp: 3
file content (62 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.. default-domain:: js

.. highlight:: javascript

DocumentWriter
===================

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

Constructors
------------

.. class::
	DocumentWriter(buffer, format, options)
	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
	:doc:`/reference/common/document-writer-options`.

	:param Buffer buffer: The buffer to output to.
	:param Buffer filename: The file name to output to.
	:param string format: The file format.
	:param string options: The options as key-value pairs.

	.. code-block::

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

Instance methods
----------------

.. method:: DocumentWriter.prototype.beginPage(mediabox)

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

	:param Rect mediaBox: The page size.

	:returns: `Device`

	.. code-block::

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

.. method:: DocumentWriter.prototype.endPage()

	Finish the page rendering.

	.. code-block::

		writer.endPage()

.. method:: 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.

	.. code-block::

		writer.close()