MCPcopy Create free account
hub / github.com/foliojs/pdfkit / constructor

Method constructor

lib/document.js:28–142  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

26
27class PDFDocument extends stream.Readable {
28 constructor(options = {}) {
29 super(options);
30 this.options = options;
31
32 // PDF version
33 switch (options.pdfVersion) {
34 case '1.4':
35 this.version = 1.4;
36 break;
37 case '1.5':
38 this.version = 1.5;
39 break;
40 case '1.6':
41 this.version = 1.6;
42 break;
43 case '1.7':
44 case '1.7ext3':
45 this.version = 1.7;
46 break;
47 default:
48 this.version = 1.3;
49 break;
50 }
51
52 // Whether streams should be compressed
53 this.compress =
54 this.options.compress != null ? this.options.compress : true;
55
56 this._pageBuffer = [];
57 this._pageBufferStart = 0;
58
59 // The PDF object store
60 this._offsets = [];
61 this._waiting = 0;
62 this._ended = false;
63 this._offset = 0;
64 const Pages = this.ref({
65 Type: 'Pages',
66 Count: 0,
67 Kids: [],
68 });
69
70 const Names = this.ref({
71 Dests: new PDFNameTree(),
72 });
73
74 this._root = this.ref({
75 Type: 'Catalog',
76 Pages,
77 Names,
78 });
79
80 if (this.options.lang) {
81 this._root.data.Lang = new String(this.options.lang);
82 }
83
84 if (this.options.pageLayout) {
85 const layout = this.options.pageLayout;

Callers

nothing calls this directly

Calls 6

refMethod · 0.95
_writeMethod · 0.95
addPageMethod · 0.95
sliceMethod · 0.80
generateFileIDMethod · 0.80
createMethod · 0.80

Tested by

no test coverage detected