MCPcopy Index your code
hub / github.com/diegomura/react-pdf / _finalize

Method _finalize

packages/pdfkit/src/document.js:258–286  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

256 }
257
258 _finalize(fn) {
259 // generate xref
260 const xRefOffset = this._offset;
261 this._write('xref');
262 this._write(`0 ${this._offsets.length + 1}`);
263 this._write('0000000000 65535 f ');
264
265 for (let offset of Array.from(this._offsets)) {
266 offset = `0000000000${offset}`.slice(-10);
267 this._write(offset + ' 00000 n ');
268 }
269
270 // trailer
271 this._write('trailer');
272 this._write(
273 PDFObject.convert({
274 Size: this._offsets.length + 1,
275 Root: this._root,
276 Info: this._info
277 })
278 );
279
280 this._write('startxref');
281 this._write(`${xRefOffset}`);
282 this._write('%%EOF');
283
284 // end the stream
285 return this.push(null);
286 }
287
288 toString() {
289 return '[object PDFDocument]';

Callers 2

_refEndMethod · 0.95
endMethod · 0.95

Calls 4

_writeMethod · 0.95
sliceMethod · 0.80
convertMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected