mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Annotation] Fix printing/saving for annotations containing some non-ascii chars and with no fonts to handle them (bug 1666824)
- For text fields * when printing, we generate a fake font which contains some widths computed thanks to an OffscreenCanvas and its method measureText. In order to avoid to have to layout the glyphs ourselves, we just render all of them in one call in the showText method in using the system sans-serif/monospace fonts. * when saving, we continue to create the appearance streams if the fonts contain the char but when a char is missing, we just set, in the AcroForm dict, the flag /NeedAppearances to true and remove the appearance stream. This way, we let the different readers handle the rendering of the strings. - For FreeText annotations * when printing, we use the same trick as for text fields. * there is no need to save an appearance since Acrobat is able to infer one from the Content entry.
This commit is contained in:
parent
f7449563ef
commit
3ca03603c2
19 changed files with 1117 additions and 287 deletions
|
@ -479,7 +479,30 @@ class Driver {
|
|||
enableXfa: task.enableXfa,
|
||||
styleElement: xfaStyleElement,
|
||||
});
|
||||
loadingTask.promise.then(
|
||||
let promise = loadingTask.promise;
|
||||
|
||||
if (task.save) {
|
||||
if (!task.annotationStorage) {
|
||||
promise = Promise.reject(
|
||||
new Error("Missing `annotationStorage` entry.")
|
||||
);
|
||||
} else {
|
||||
promise = loadingTask.promise.then(async doc => {
|
||||
for (const [key, value] of Object.entries(
|
||||
task.annotationStorage
|
||||
)) {
|
||||
doc.annotationStorage.setValue(key, value);
|
||||
}
|
||||
const data = await doc.saveDocument();
|
||||
await loadingTask.destroy();
|
||||
delete task.annotationStorage;
|
||||
|
||||
return getDocument(data).promise;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
promise.then(
|
||||
async doc => {
|
||||
if (task.enableXfa) {
|
||||
task.fontRules = "";
|
||||
|
|
2
test/pdfs/.gitignore
vendored
2
test/pdfs/.gitignore
vendored
|
@ -551,3 +551,5 @@
|
|||
!bug1795263.pdf
|
||||
!issue15597.pdf
|
||||
!bug1796741.pdf
|
||||
!textfields.pdf
|
||||
!freetext_no_appearance.pdf
|
||||
|
|
BIN
test/pdfs/freetext_no_appearance.pdf
Executable file
BIN
test/pdfs/freetext_no_appearance.pdf
Executable file
Binary file not shown.
BIN
test/pdfs/textfields.pdf
Executable file
BIN
test/pdfs/textfields.pdf
Executable file
Binary file not shown.
|
@ -6973,5 +6973,225 @@
|
|||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true
|
||||
},
|
||||
{ "id": "ascii_print_textfields",
|
||||
"file": "pdfs/textfields.pdf",
|
||||
"md5": "5f743ca838ff9b7a286dbe52002860b7",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"32R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"35R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"38R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"34R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"37R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"40R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"33R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
},
|
||||
"36R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
},
|
||||
"39R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "arabic_print_textfields",
|
||||
"file": "pdfs/textfields.pdf",
|
||||
"md5": "5f743ca838ff9b7a286dbe52002860b7",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"32R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"35R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"38R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"34R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"37R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"40R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"33R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
},
|
||||
"36R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
},
|
||||
"39R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "ascii_save_print_textfields",
|
||||
"file": "pdfs/textfields.pdf",
|
||||
"md5": "5f743ca838ff9b7a286dbe52002860b7",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"save": true,
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"32R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"35R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"38R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"34R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"37R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"40R": {
|
||||
"value": "Hello World"
|
||||
},
|
||||
"33R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
},
|
||||
"36R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
},
|
||||
"39R": {
|
||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "arabic_save_print_textfields",
|
||||
"file": "pdfs/textfields.pdf",
|
||||
"md5": "5f743ca838ff9b7a286dbe52002860b7",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"save": true,
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"32R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"35R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"38R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"34R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"37R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"40R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
},
|
||||
"33R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
},
|
||||
"36R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
},
|
||||
"39R": {
|
||||
"value": "مرحبا بالعالم\nملاعلاب ابحرم\nمرحبا بالعالم"
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "id": "freetext_no_appearance",
|
||||
"file": "pdfs/freetext_no_appearance.pdf",
|
||||
"md5": "1dc519c06f1dc6f6e594f168080dcde9",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "freetext_print_no_appearance",
|
||||
"file": "pdfs/freetext_no_appearance.pdf",
|
||||
"md5": "1dc519c06f1dc6f6e594f168080dcde9",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true
|
||||
},
|
||||
{
|
||||
"id": "tracemonkey-multi-lang-editors",
|
||||
"file": "pdfs/tracemonkey.pdf",
|
||||
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
|
||||
"rounds": 1,
|
||||
"lastPage": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"pdfjs_internal_editor_0": {
|
||||
"annotationType": 3,
|
||||
"color": [255, 0, 0],
|
||||
"fontSize": 10,
|
||||
"value": "Hello World",
|
||||
"pageIndex": 0,
|
||||
"rect": [67.5, 143, 119, 156.5],
|
||||
"rotation": 0
|
||||
},
|
||||
"pdfjs_internal_editor_1": {
|
||||
"annotationType": 3,
|
||||
"color": [0, 255, 0],
|
||||
"fontSize": 10,
|
||||
"value": "مرحبا بالعالم",
|
||||
"pageIndex": 0,
|
||||
"rect": [67.5, 243, 119, 256.5],
|
||||
"rotation": 0
|
||||
},
|
||||
"pdfjs_internal_editor_2": {
|
||||
"annotationType": 3,
|
||||
"color": [0, 0, 255],
|
||||
"fontSize": 10,
|
||||
"value": "你好世界",
|
||||
"pageIndex": 0,
|
||||
"rect": [67.5, 343, 119, 356.5],
|
||||
"rotation": 0
|
||||
},
|
||||
"pdfjs_internal_editor_3": {
|
||||
"annotationType": 3,
|
||||
"color": [255, 0, 255],
|
||||
"fontSize": 10,
|
||||
"value": "Hello World 你好世界 مرحبا بالعالم",
|
||||
"pageIndex": 0,
|
||||
"rect": [67.5, 443, 222, 456.5],
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "issue12233-arabic-print",
|
||||
"file": "pdfs/issue12233.pdf",
|
||||
"md5": "6099fc695fe018ce444752929d86f9c8",
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"23R": {
|
||||
"value": "مرحبا بالعالم"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -56,6 +56,9 @@ describe("annotation", function () {
|
|||
acroForm: new Dict(),
|
||||
},
|
||||
};
|
||||
this.evaluatorOptions = {
|
||||
isOffscreenCanvasSupported: false,
|
||||
};
|
||||
}
|
||||
|
||||
ensure(obj, prop, args) {
|
||||
|
@ -1611,11 +1614,12 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" +
|
||||
" 2 3.04 Td (test\\\\print) Tj ET Q EMC"
|
||||
" 2 3.07 Td (test\\\\print) Tj ET Q EMC"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1645,13 +1649,14 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
const utf16String =
|
||||
"\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f\x4e\x16\x75\x4c\x30\x6e";
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 0 Tm" +
|
||||
` 2 2 Td (${utf16String}) Tj ET Q EMC`
|
||||
` 2 3.07 Td (${utf16String}) Tj ET Q EMC`
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1728,11 +1733,12 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Helv 5.92 Tf 0 g 1 0 0 1 0 0 Tm" +
|
||||
" 2 3.23 Td (test \\(print\\)) Tj ET Q EMC"
|
||||
" 2 3.07 Td (test \\(print\\)) Tj ET Q EMC"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1762,13 +1768,14 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
const utf16String =
|
||||
"\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f\x4e\x16\x75\x4c\x30\x6e";
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Goth 3.5 Tf 0 g 1 0 0 1 0 0 Tm" +
|
||||
` 2 2 Td (${utf16String}) Tj ET Q EMC`
|
||||
"/Tx BMC q BT /Goth 5.92 Tf 0 g 1 0 0 1 0 0 Tm" +
|
||||
` 2 3.07 Td (${utf16String}) Tj ET Q EMC`
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1795,6 +1802,7 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(null);
|
||||
|
@ -1827,17 +1835,18 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " +
|
||||
"2 -5 Td (a aa aaa ) Tj\n" +
|
||||
"0 -5 Td (aaaa aaaaa ) Tj\n" +
|
||||
"0 -5 Td (aaaaaa ) Tj\n" +
|
||||
"0 -5 Td (pneumonoultr) Tj\n" +
|
||||
"0 -5 Td (amicroscopi) Tj\n" +
|
||||
"0 -5 Td (csilicovolca) Tj\n" +
|
||||
"0 -5 Td (noconiosis) Tj ET Q EMC"
|
||||
"2 -6.93 Td (a aa aaa ) Tj\n" +
|
||||
"0 -8 Td (aaaa aaaaa ) Tj\n" +
|
||||
"0 -8 Td (aaaaaa ) Tj\n" +
|
||||
"0 -8 Td (pneumonoultr) Tj\n" +
|
||||
"0 -8 Td (amicroscopi) Tj\n" +
|
||||
"0 -8 Td (csilicovolca) Tj\n" +
|
||||
"0 -8 Td (noconiosis) Tj ET Q EMC"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1868,12 +1877,13 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 10 Tm " +
|
||||
"2 -5 Td (\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f) Tj\n" +
|
||||
"0 -5 Td (\x4e\x16\x75\x4c\x30\x6e) Tj ET Q EMC"
|
||||
"2 -6.93 Td (\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f) Tj\n" +
|
||||
"0 -8 Td (\x4e\x16\x75\x4c\x30\x6e) Tj ET Q EMC"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1890,25 +1900,25 @@ describe("annotation", function () {
|
|||
partialEvaluator.xref = xref;
|
||||
const expectedAppearance =
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " +
|
||||
"2 -5 Td " +
|
||||
"2 -6.93 Td " +
|
||||
"(Lorem ipsum dolor sit amet, consectetur adipiscing elit.) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(Aliquam vitae felis ac lectus bibendum ultricies quis non) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"( diam.) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(Morbi id porttitor quam, a iaculis dui.) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(Pellentesque habitant morbi tristique senectus et netus ) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(et malesuada fames ac turpis egestas.) Tj\n" +
|
||||
"0 -5 Td () Tj\n" +
|
||||
"0 -5 Td () Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td () Tj\n" +
|
||||
"0 -8 Td () Tj\n" +
|
||||
"0 -8 Td " +
|
||||
"(Nulla consectetur, ligula in tincidunt placerat, velit ) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(augue consectetur orci, sed mattis libero nunc ut massa.) Tj\n" +
|
||||
"0 -5 Td " +
|
||||
"0 -8 Td " +
|
||||
"(Etiam facilisis tempus interdum.) Tj ET Q EMC";
|
||||
|
||||
const annotation = await AnnotationFactory.create(
|
||||
|
@ -1933,8 +1943,10 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
|
||||
expect(appearance).toEqual(expectedAppearance);
|
||||
});
|
||||
|
||||
|
@ -1962,10 +1974,11 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 3.035 Tm" +
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 3.07 Tm" +
|
||||
" (a) Tj 8 0 Td (a) Tj 8 0 Td (\\() Tj" +
|
||||
" 8 0 Td (a) Tj 8 0 Td (a) Tj" +
|
||||
" 8 0 Td (\\)) Tj 8 0 Td (a) Tj" +
|
||||
|
@ -2002,10 +2015,11 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
"/Tx BMC q BT /Goth 5 Tf 1 0 0 1 2 2 Tm" +
|
||||
"/Tx BMC q BT /Goth 5 Tf 1 0 0 1 2 3.07 Tm" +
|
||||
" (\x30\x53) Tj 8 0 Td (\x30\x93) Tj 8 0 Td (\x30\x6b) Tj" +
|
||||
" 8 0 Td (\x30\x61) Tj 8 0 Td (\x30\x6f) Tj" +
|
||||
" 8 0 Td (\x4e\x16) Tj 8 0 Td (\x75\x4c) Tj" +
|
||||
|
@ -2051,7 +2065,7 @@ describe("annotation", function () {
|
|||
expect(newData.data).toEqual(
|
||||
"2 0 obj\n<< /Length 74 /Subtype /Form /Resources " +
|
||||
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10]>> stream\n" +
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 3.04 Td (hello world) Tj " +
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 3.07 Td (hello world) Tj " +
|
||||
"ET Q EMC\nendstream\nendobj\n"
|
||||
);
|
||||
});
|
||||
|
@ -2092,12 +2106,12 @@ describe("annotation", function () {
|
|||
"123 0 obj\n" +
|
||||
"<< /Type /Annot /Subtype /Widget /FT /Tx /DA (/Helv 5 Tf) /DR " +
|
||||
"<< /Font << /Helv 314 0 R>>>> /Rect [0 0 32 10] " +
|
||||
"/V (hello world) /AP << /N 2 0 R>> /M (date) /MK << /R 90>>>>\nendobj\n"
|
||||
"/V (hello world) /MK << /R 90>> /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
||||
);
|
||||
expect(newData.data).toEqual(
|
||||
"2 0 obj\n<< /Length 74 /Subtype /Form /Resources " +
|
||||
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Matrix [0 1 -1 0 32 0]>> stream\n" +
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 3.04 Td (hello world) Tj " +
|
||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 2.94 Td (hello world) Tj " +
|
||||
"ET Q EMC\nendstream\nendobj\n"
|
||||
);
|
||||
});
|
||||
|
@ -2226,9 +2240,9 @@ describe("annotation", function () {
|
|||
`/V (\xfe\xff${utf16String}) /AP << /N 2 0 R>> /M (date)>>\nendobj\n`
|
||||
);
|
||||
expect(newData.data).toEqual(
|
||||
"2 0 obj\n<< /Length 76 /Subtype /Form /Resources " +
|
||||
"2 0 obj\n<< /Length 79 /Subtype /Form /Resources " +
|
||||
"<< /Font << /Helv 314 0 R /Goth 159 0 R>>>> /BBox [0 0 32 10]>> stream\n" +
|
||||
`/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 0 Tm 2 2 Td (${utf16String}) Tj ` +
|
||||
`/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 0 Tm 2 3.07 Td (${utf16String}) Tj ` +
|
||||
"ET Q EMC\nendstream\nendobj\n"
|
||||
);
|
||||
});
|
||||
|
@ -3457,6 +3471,7 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
|
@ -3501,6 +3516,7 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
|
@ -3549,6 +3565,7 @@ describe("annotation", function () {
|
|||
const appearance = await annotation._getAppearance(
|
||||
partialEvaluator,
|
||||
task,
|
||||
RenderingIntentFlag.PRINT,
|
||||
annotationStorage
|
||||
);
|
||||
expect(appearance).toEqual(
|
||||
|
@ -3605,7 +3622,7 @@ describe("annotation", function () {
|
|||
"<< /Type /Annot /Subtype /Widget /FT /Ch /DA (/Helv 5 Tf) /DR " +
|
||||
"<< /Font << /Helv 314 0 R>>>> " +
|
||||
"/Rect [0 0 32 10] /Opt [(A) (B) (C)] /V (C) " +
|
||||
"/AP << /N 2 0 R>> /M (date) /MK << /R 270>>>>\nendobj\n"
|
||||
"/MK << /R 270>> /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
||||
);
|
||||
expect(newData.data).toEqual(
|
||||
[
|
||||
|
@ -4052,7 +4069,6 @@ describe("annotation", function () {
|
|||
"ET\n" +
|
||||
"Q\n" +
|
||||
"endstream\n" +
|
||||
"\n" +
|
||||
"endobj\n"
|
||||
);
|
||||
});
|
||||
|
@ -4245,7 +4261,6 @@ describe("annotation", function () {
|
|||
"922 923 924 925 926 927 c\n" +
|
||||
"S\n" +
|
||||
"endstream\n" +
|
||||
"\n" +
|
||||
"endobj\n"
|
||||
);
|
||||
});
|
||||
|
@ -4309,7 +4324,6 @@ describe("annotation", function () {
|
|||
"922 923 924 925 926 927 c\n" +
|
||||
"S\n" +
|
||||
"endstream\n" +
|
||||
"\n" +
|
||||
"endobj\n"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -66,6 +66,9 @@ describe("document", function () {
|
|||
}
|
||||
return value;
|
||||
},
|
||||
get evaluatorOptions() {
|
||||
return { isOffscreenCanvasSupported: false };
|
||||
},
|
||||
};
|
||||
const pdfDocument = new PDFDocument(pdfManager, stream);
|
||||
pdfDocument.xref = xref;
|
||||
|
|
|
@ -78,7 +78,8 @@ class XRefMock {
|
|||
constructor(array) {
|
||||
this._map = Object.create(null);
|
||||
this.stats = new DocStats({ send: () => {} });
|
||||
this._newRefNum = null;
|
||||
this._newTemporaryRefNum = null;
|
||||
this._newPersistentRefNum = null;
|
||||
this.stream = new NullStream();
|
||||
|
||||
for (const key in array) {
|
||||
|
@ -87,15 +88,24 @@ class XRefMock {
|
|||
}
|
||||
}
|
||||
|
||||
getNewRef() {
|
||||
if (this._newRefNum === null) {
|
||||
this._newRefNum = Object.keys(this._map).length || 1;
|
||||
getNewPersistentRef(obj) {
|
||||
if (this._newPersistentRefNum === null) {
|
||||
this._newPersistentRefNum = Object.keys(this._map).length || 1;
|
||||
}
|
||||
return Ref.get(this._newRefNum++, 0);
|
||||
const ref = Ref.get(this._newPersistentRefNum++, 0);
|
||||
this._map[ref.toString()] = obj;
|
||||
return ref;
|
||||
}
|
||||
|
||||
resetNewRef() {
|
||||
this.newRef = null;
|
||||
getNewTemporaryRef() {
|
||||
if (this._newTemporaryRefNum === null) {
|
||||
this._newTemporaryRefNum = Object.keys(this._map).length || 1;
|
||||
}
|
||||
return Ref.get(this._newTemporaryRefNum++, 0);
|
||||
}
|
||||
|
||||
resetNewTemporaryRef() {
|
||||
this._newTemporaryRefNum = null;
|
||||
}
|
||||
|
||||
fetch(ref) {
|
||||
|
|
|
@ -128,7 +128,7 @@ describe("Writer", function () {
|
|||
"/E (\\(hello\\\\world\\)) /F [1.23 4.5 6] " +
|
||||
"/G << /H 123 /I << /Length 8>> stream\n" +
|
||||
"a stream\n" +
|
||||
"endstream\n>> /J true /K false " +
|
||||
"endstream>> /J true /K false " +
|
||||
"/NullArr [null 10] /NullVal null>>";
|
||||
|
||||
expect(buffer.join("")).toEqual(expected);
|
||||
|
@ -194,6 +194,7 @@ describe("Writer", function () {
|
|||
"\n" +
|
||||
"789 0 obj\n" +
|
||||
"<< /XFA [(preamble) 123 0 R (datasets) 101112 0 R (postamble) 456 0 R]>>\n" +
|
||||
"endobj\n" +
|
||||
"101112 0 obj\n" +
|
||||
"<< /Type /EmbeddedFile /Length 20>>\n" +
|
||||
"stream\n" +
|
||||
|
@ -202,11 +203,11 @@ describe("Writer", function () {
|
|||
"endobj\n" +
|
||||
"131415 0 obj\n" +
|
||||
"<< /Size 131416 /Prev 314 /Type /XRef /Index [0 1 789 1 101112 1 131415 1] /W [1 1 2] /Length 16>> stream\n" +
|
||||
"\u0000\u0001ÿÿ\u0001\u0001\u0000\u0000\u0001T\u0000\u0000\u0001²\u0000\u0000\n" +
|
||||
"\u0000\u0001ÿÿ\u0001\u0001\u0000\u0000\u0001[\u0000\u0000\u0001¹\u0000\u0000\n" +
|
||||
"endstream\n" +
|
||||
"endobj\n" +
|
||||
"startxref\n" +
|
||||
"178\n" +
|
||||
"185\n" +
|
||||
"%%EOF\n";
|
||||
|
||||
expect(data).toEqual(expected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue