mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-25 17:45:48 +02:00
Merge pull request #21051 from Snuffleupagus/writePDF-stringToBytes
Use the `stringToBytes` helper in the `PDFEditor.prototype.writePDF` method
This commit is contained in:
commit
f8d7c20a1a
@ -27,7 +27,11 @@ import {
|
|||||||
stringToAsciiOrUTF16BE,
|
stringToAsciiOrUTF16BE,
|
||||||
} from "../core_utils.js";
|
} from "../core_utils.js";
|
||||||
import { Dict, isName, Name, Ref, RefSet, RefSetCache } from "../primitives.js";
|
import { Dict, isName, Name, Ref, RefSet, RefSetCache } from "../primitives.js";
|
||||||
import { getModificationDate, stringToPDFString } from "../../shared/util.js";
|
import {
|
||||||
|
getModificationDate,
|
||||||
|
stringToBytes,
|
||||||
|
stringToPDFString,
|
||||||
|
} from "../../shared/util.js";
|
||||||
import { incrementalUpdate, writeValue } from "../writer.js";
|
import { incrementalUpdate, writeValue } from "../writer.js";
|
||||||
import { NameTree, NumberTree } from "../name_number_tree.js";
|
import { NameTree, NumberTree } from "../name_number_tree.js";
|
||||||
import { AnnotationFactory } from "../annotation.js";
|
import { AnnotationFactory } from "../annotation.js";
|
||||||
@ -2458,15 +2462,10 @@ class PDFEditor {
|
|||||||
// PDF version must be in the range 1.0 to 1.7 inclusive.
|
// PDF version must be in the range 1.0 to 1.7 inclusive.
|
||||||
// We add a binary comment line to ensure that the file is treated
|
// We add a binary comment line to ensure that the file is treated
|
||||||
// as a binary file by applications that open it.
|
// as a binary file by applications that open it.
|
||||||
const header = [
|
const header = stringToBytes(`%PDF-${this.version}\n%\xfa\xde\xfa\xce`);
|
||||||
...`%PDF-${this.version}\n%`.split("").map(c => c.charCodeAt(0)),
|
|
||||||
0xfa,
|
|
||||||
0xde,
|
|
||||||
0xfa,
|
|
||||||
0xce,
|
|
||||||
];
|
|
||||||
return incrementalUpdate({
|
return incrementalUpdate({
|
||||||
originalData: new Uint8Array(header),
|
originalData: header,
|
||||||
changes,
|
changes,
|
||||||
xrefInfo: {
|
xrefInfo: {
|
||||||
startXRef: null,
|
startXRef: null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user