()
| 43 | } |
| 44 | |
| 45 | finalize() { |
| 46 | this.offset = this.document._offset; |
| 47 | |
| 48 | const encryptFn = this.document._security |
| 49 | ? this.document._security.getEncryptFn(this.id, this.gen) |
| 50 | : null; |
| 51 | |
| 52 | if (this.buffer.length) { |
| 53 | this.buffer = Buffer.concat(this.buffer); |
| 54 | if (this.compress) { |
| 55 | this.buffer = zlib.deflateSync(this.buffer); |
| 56 | } |
| 57 | |
| 58 | if (encryptFn) { |
| 59 | this.buffer = encryptFn(this.buffer); |
| 60 | } |
| 61 | |
| 62 | this.data.Length = this.buffer.length; |
| 63 | } |
| 64 | |
| 65 | this.document._write(`${this.id} ${this.gen} obj`); |
| 66 | this.document._write(PDFObject.convert(this.data, encryptFn)); |
| 67 | |
| 68 | if (this.buffer.length) { |
| 69 | this.document._write('stream'); |
| 70 | this.document._write(this.buffer); |
| 71 | |
| 72 | this.buffer = []; // free up memory |
| 73 | this.document._write('\nendstream'); |
| 74 | } |
| 75 | |
| 76 | this.document._write('endobj'); |
| 77 | this.document._refEnd(this); |
| 78 | } |
| 79 | toString() { |
| 80 | return `${this.id} ${this.gen} R`; |
| 81 | } |
no test coverage detected