Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
copyBytesInto = (buffer: Uint8Array): Uint8Array => {
this.validateDictionary();
let remaining = this.dictionary.copyBytesInto(buffer);
remaining = addStringToBuffer('\nstream\n', remaining);
remaining.set(this.content, 0);
remaining = remaining.subarray(this.content.length);
remaining = addStringToBuffer('\nendstream', remaining);
return remaining;
};
}
private copyContentBytesInto = (buffer: Uint8Array): Uint8Array => {
const remaining = addStringToBuffer(this.leadingIntegerPairsStr(), buffer);
return this.objects.reduce(
(remBytes, obj) =>
addStringToBuffer('\n', obj.pdfObject.copyBytesInto(remBytes)),
remaining,
);
};
copyBytesInto = (buffer: Uint8Array): Uint8Array => {
let remaining = addStringToBuffer('BT\n', buffer);
remaining = this.operators
.filter(Boolean)
.reduce(
(remBytes: Uint8Array, op: PDFOperator) => op.copyBytesInto(remBytes),
remaining,
);
remaining = addStringToBuffer('ET\n', remaining);
return remaining;
};
}
copyBytesInto = (buffer: Uint8Array): Uint8Array => {
const remaining = addStringToBuffer(
`%PDF-${this.major}.${this.minor}\n`,
buffer,
);
remaining.set([charCode('%'), 130, 130, 130, 130, charCode('\n')], 0);
return remaining.subarray(6);
};
}
this.array.forEach((e, idx) => {
if (e instanceof PDFIndirectObject) {
remaining = addStringToBuffer(e.toReference(), remaining);
} else if (e instanceof PDFObject) {
remaining = e.copyBytesInto(remaining);
} else {
error(`Not a PDFObject: ${e}`);
}
remaining = addStringToBuffer(' ', remaining);
});