|
@@ -1423,7 +1423,7 @@ describe("annotation", function () {
|
|
value: "test\\print"
|
|
value: "test\\print"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" + " 2.00 3.04 Td (test\\\\print) Tj ET Q EMC");
|
|
|
|
|
|
+ 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");
|
|
});
|
|
});
|
|
it("should render regular text in Japanese for printing", async function () {
|
|
it("should render regular text in Japanese for printing", async function () {
|
|
textWidgetDict.get("DR").get("Font").set("Goth", gothRefObj.ref);
|
|
textWidgetDict.get("DR").get("Font").set("Goth", gothRefObj.ref);
|
|
@@ -1444,7 +1444,7 @@ describe("annotation", function () {
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const utf16String = "\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f\x4e\x16\x75\x4c\x30\x6e";
|
|
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.00 2.00 Td (${utf16String}) Tj ET Q EMC`);
|
|
|
|
|
|
+ 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`);
|
|
});
|
|
});
|
|
it("should render regular text for printing using normal appearance", async function () {
|
|
it("should render regular text for printing using normal appearance", async function () {
|
|
const textWidgetRef = _primitives.Ref.get(271, 0);
|
|
const textWidgetRef = _primitives.Ref.get(271, 0);
|
|
@@ -1463,11 +1463,13 @@ describe("annotation", function () {
|
|
partialEvaluator.xref = xref;
|
|
partialEvaluator.xref = xref;
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotationStorage = new Map();
|
|
const annotationStorage = new Map();
|
|
- const operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["271R", [0, 0, 32, 10], [32, 0, 0, 10, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[0]).toEqual(["271R", [0, 0, 32, 10], [32, 0, 0, 10, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
});
|
|
});
|
|
it("should render auto-sized text for printing", async function () {
|
|
it("should render auto-sized text for printing", async function () {
|
|
textWidgetDict.set("DA", "/Helv 0 Tf");
|
|
textWidgetDict.set("DA", "/Helv 0 Tf");
|
|
@@ -1486,7 +1488,7 @@ describe("annotation", function () {
|
|
value: "test (print)"
|
|
value: "test (print)"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Helv 5.92 Tf 0 g 1 0 0 1 0 0 Tm" + " 2.00 3.23 Td (test \\(print\\)) Tj ET Q EMC");
|
|
|
|
|
|
+ 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");
|
|
});
|
|
});
|
|
it("should render auto-sized text in Japanese for printing", async function () {
|
|
it("should render auto-sized text in Japanese for printing", async function () {
|
|
textWidgetDict.get("DR").get("Font").set("Goth", gothRefObj.ref);
|
|
textWidgetDict.get("DR").get("Font").set("Goth", gothRefObj.ref);
|
|
@@ -1507,7 +1509,7 @@ describe("annotation", function () {
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const utf16String = "\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f\x4e\x16\x75\x4c\x30\x6e";
|
|
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.00 2.00 Td (${utf16String}) Tj ET Q EMC`);
|
|
|
|
|
|
+ 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`);
|
|
});
|
|
});
|
|
it("should not render a password for printing", async function () {
|
|
it("should not render a password for printing", async function () {
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.PASSWORD);
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.PASSWORD);
|
|
@@ -1545,7 +1547,7 @@ describe("annotation", function () {
|
|
value: "a aa aaa aaaa aaaaa aaaaaa " + "pneumonoultramicroscopicsilicovolcanoconiosis"
|
|
value: "a aa aaa aaaa aaaaa aaaaaa " + "pneumonoultramicroscopicsilicovolcanoconiosis"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " + "2.00 -5.00 Td (a aa aaa ) Tj\n" + "0.00 -5.00 Td (aaaa aaaaa ) Tj\n" + "0.00 -5.00 Td (aaaaaa ) Tj\n" + "0.00 -5.00 Td (pneumonoultr) Tj\n" + "0.00 -5.00 Td (amicroscopi) Tj\n" + "0.00 -5.00 Td (csilicovolca) Tj\n" + "0.00 -5.00 Td (noconiosis) Tj ET Q EMC");
|
|
|
|
|
|
+ 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");
|
|
});
|
|
});
|
|
it("should render multiline text in Japanese for printing", async function () {
|
|
it("should render multiline text in Japanese for printing", async function () {
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
|
@@ -1566,7 +1568,7 @@ describe("annotation", function () {
|
|
value: "こんにちは世界の"
|
|
value: "こんにちは世界の"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 10 Tm " + "2.00 -5.00 Td (\x30\x53\x30\x93\x30\x6b\x30\x61\x30\x6f) Tj\n" + "0.00 -5.00 Td (\x4e\x16\x75\x4c\x30\x6e) Tj ET Q EMC");
|
|
|
|
|
|
+ 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");
|
|
});
|
|
});
|
|
it("should render multiline text with various EOL for printing", async function () {
|
|
it("should render multiline text with various EOL for printing", async function () {
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
|
@@ -1580,7 +1582,7 @@ describe("annotation", function () {
|
|
}, helvRefObj]);
|
|
}, helvRefObj]);
|
|
const task = new _worker.WorkerTask("test print");
|
|
const task = new _worker.WorkerTask("test print");
|
|
partialEvaluator.xref = xref;
|
|
partialEvaluator.xref = xref;
|
|
- const expectedAppearance = "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " + "2.00 -5.00 Td " + "(Lorem ipsum dolor sit amet, consectetur adipiscing elit.) Tj\n" + "0.00 -5.00 Td " + "(Aliquam vitae felis ac lectus bibendum ultricies quis non) Tj\n" + "0.00 -5.00 Td " + "( diam.) Tj\n" + "0.00 -5.00 Td " + "(Morbi id porttitor quam, a iaculis dui.) Tj\n" + "0.00 -5.00 Td " + "(Pellentesque habitant morbi tristique senectus et netus ) Tj\n" + "0.00 -5.00 Td " + "(et malesuada fames ac turpis egestas.) Tj\n" + "0.00 -5.00 Td () Tj\n" + "0.00 -5.00 Td () Tj\n" + "0.00 -5.00 Td " + "(Nulla consectetur, ligula in tincidunt placerat, velit ) Tj\n" + "0.00 -5.00 Td " + "(augue consectetur orci, sed mattis libero nunc ut massa.) Tj\n" + "0.00 -5.00 Td " + "(Etiam facilisis tempus interdum.) Tj ET Q EMC";
|
|
|
|
|
|
+ const expectedAppearance = "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " + "2 -5 Td " + "(Lorem ipsum dolor sit amet, consectetur adipiscing elit.) Tj\n" + "0 -5 Td " + "(Aliquam vitae felis ac lectus bibendum ultricies quis non) Tj\n" + "0 -5 Td " + "( diam.) Tj\n" + "0 -5 Td " + "(Morbi id porttitor quam, a iaculis dui.) Tj\n" + "0 -5 Td " + "(Pellentesque habitant morbi tristique senectus et netus ) Tj\n" + "0 -5 Td " + "(et malesuada fames ac turpis egestas.) Tj\n" + "0 -5 Td () Tj\n" + "0 -5 Td () Tj\n" + "0 -5 Td " + "(Nulla consectetur, ligula in tincidunt placerat, velit ) Tj\n" + "0 -5 Td " + "(augue consectetur orci, sed mattis libero nunc ut massa.) Tj\n" + "0 -5 Td " + "(Etiam facilisis tempus interdum.) Tj ET Q EMC";
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotationStorage = new Map();
|
|
const annotationStorage = new Map();
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
@@ -1607,7 +1609,7 @@ describe("annotation", function () {
|
|
value: "aa(aa)a\\"
|
|
value: "aa(aa)a\\"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 3.035 Tm" + " (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (\\() Tj" + " 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj" + " 8.00 0 Td (\\)) Tj 8.00 0 Td (a) Tj" + " 8.00 0 Td (\\\\) Tj ET Q EMC");
|
|
|
|
|
|
+ expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 3.035 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" + " 8 0 Td (\\\\) Tj ET Q EMC");
|
|
});
|
|
});
|
|
it("should render comb with Japanese text for printing", async function () {
|
|
it("should render comb with Japanese text for printing", async function () {
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
|
|
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
|
|
@@ -1630,7 +1632,7 @@ describe("annotation", function () {
|
|
value: "こんにちは世界の"
|
|
value: "こんにちは世界の"
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual("/Tx BMC q BT /Goth 5 Tf 1 0 0 1 2 2 Tm" + " (\x30\x53) Tj 8.00 0 Td (\x30\x93) Tj 8.00 0 Td (\x30\x6b) Tj" + " 8.00 0 Td (\x30\x61) Tj 8.00 0 Td (\x30\x6f) Tj" + " 8.00 0 Td (\x4e\x16) Tj 8.00 0 Td (\x75\x4c) Tj" + " 8.00 0 Td (\x30\x6e) Tj ET Q EMC");
|
|
|
|
|
|
+ expect(appearance).toEqual("/Tx BMC q BT /Goth 5 Tf 1 0 0 1 2 2 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" + " 8 0 Td (\x30\x6e) Tj ET Q EMC");
|
|
});
|
|
});
|
|
it("should save text", async function () {
|
|
it("should save text", async function () {
|
|
const textWidgetRef = _primitives.Ref.get(123, 0);
|
|
const textWidgetRef = _primitives.Ref.get(123, 0);
|
|
@@ -1653,7 +1655,31 @@ describe("annotation", function () {
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
expect(oldData.data).toEqual("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)>>\nendobj\n");
|
|
expect(oldData.data).toEqual("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)>>\nendobj\n");
|
|
- expect(newData.data).toEqual("2 0 obj\n<< /Length 77 /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.00 3.04 Td (hello world) Tj " + "ET Q EMC\nendstream\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]>> stream\n" + "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 3.04 Td (hello world) Tj " + "ET Q EMC\nendstream\nendobj\n");
|
|
|
|
+ });
|
|
|
|
+ it("should save rotated text", async function () {
|
|
|
|
+ const textWidgetRef = _primitives.Ref.get(123, 0);
|
|
|
|
+
|
|
|
|
+ const xref = new _test_utils.XRefMock([{
|
|
|
|
+ ref: textWidgetRef,
|
|
|
|
+ data: textWidgetDict
|
|
|
|
+ }, helvRefObj]);
|
|
|
|
+ partialEvaluator.xref = xref;
|
|
|
|
+ const task = new _worker.WorkerTask("test save");
|
|
|
|
+ const annotation = await _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock);
|
|
|
|
+ const annotationStorage = new Map();
|
|
|
|
+ annotationStorage.set(annotation.data.id, {
|
|
|
|
+ value: "hello world",
|
|
|
|
+ rotation: 90
|
|
|
|
+ });
|
|
|
|
+ const data = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
+ expect(data.length).toEqual(2);
|
|
|
|
+ const [oldData, newData] = data;
|
|
|
|
+ expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
|
|
|
+ expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
|
|
+ oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(oldData.data).toEqual("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");
|
|
|
|
+ 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 " + "ET Q EMC\nendstream\nendobj\n");
|
|
});
|
|
});
|
|
it("should get field object for usage in JS sandbox", async function () {
|
|
it("should get field object for usage in JS sandbox", async function () {
|
|
const textWidgetRef = _primitives.Ref.get(123, 0);
|
|
const textWidgetRef = _primitives.Ref.get(123, 0);
|
|
@@ -1759,7 +1785,7 @@ describe("annotation", function () {
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Tx /DA (/Goth 5 Tf) /DR " + "<< /Font << /Helv 314 0 R /Goth 159 0 R>>>> /Rect [0 0 32 10] " + `/V (\xfe\xff${utf16String}) /AP << /N 2 0 R>> /M (date)>>\nendobj\n`);
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Tx /DA (/Goth 5 Tf) /DR " + "<< /Font << /Helv 314 0 R /Goth 159 0 R>>>> /Rect [0 0 32 10] " + `/V (\xfe\xff${utf16String}) /AP << /N 2 0 R>> /M (date)>>\nendobj\n`);
|
|
- expect(newData.data).toEqual("2 0 obj\n<< /Length 82 /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.00 2.00 Td (${utf16String}) Tj ` + "ET Q EMC\nendstream\nendobj\n");
|
|
|
|
|
|
+ expect(newData.data).toEqual("2 0 obj\n<< /Length 76 /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 ` + "ET Q EMC\nendstream\nendobj\n");
|
|
});
|
|
});
|
|
});
|
|
});
|
|
describe("ButtonWidgetAnnotation", function () {
|
|
describe("ButtonWidgetAnnotation", function () {
|
|
@@ -1875,11 +1901,13 @@ describe("annotation", function () {
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: true
|
|
value: true
|
|
});
|
|
});
|
|
- const operatorList = await annotation.getOperatorList(checkboxEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(5);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.dependency, _util.OPS.setFont, _util.OPS.showText, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[3][0][0].unicode).toEqual("4");
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await annotation.getOperatorList(checkboxEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(5);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.dependency, _util.OPS.setFont, _util.OPS.showText, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList.argsArray[3][0][0].unicode).toEqual("4");
|
|
});
|
|
});
|
|
it("should render checkboxes for printing", async function () {
|
|
it("should render checkboxes for printing", async function () {
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
@@ -1910,19 +1938,23 @@ describe("annotation", function () {
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: true
|
|
value: true
|
|
});
|
|
});
|
|
- let operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList: opList1
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList1.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList1.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList1.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList1.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: false
|
|
value: false
|
|
});
|
|
});
|
|
- operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList: opList2
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList2.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList2.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList2.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList2.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
});
|
|
});
|
|
it("should render checkboxes for printing twice", async function () {
|
|
it("should render checkboxes for printing twice", async function () {
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
@@ -1956,11 +1988,13 @@ describe("annotation", function () {
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: true
|
|
value: true
|
|
});
|
|
});
|
|
- const operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["1249R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[0]).toEqual(["1249R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
it("should render checkboxes for printing using normal appearance", async function () {
|
|
it("should render checkboxes for printing using normal appearance", async function () {
|
|
@@ -1990,11 +2024,13 @@ describe("annotation", function () {
|
|
const task = new _worker.WorkerTask("test print");
|
|
const task = new _worker.WorkerTask("test print");
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotationStorage = new Map();
|
|
const annotationStorage = new Map();
|
|
- const operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
});
|
|
});
|
|
it("should save checkboxes", async function () {
|
|
it("should save checkboxes", async function () {
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
@@ -2028,6 +2064,39 @@ describe("annotation", function () {
|
|
const data = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
const data = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
expect(data).toEqual(null);
|
|
expect(data).toEqual(null);
|
|
});
|
|
});
|
|
|
|
+ it("should save rotated checkboxes", async function () {
|
|
|
|
+ const appearanceStatesDict = new _primitives.Dict();
|
|
|
|
+ const normalAppearanceDict = new _primitives.Dict();
|
|
|
|
+ normalAppearanceDict.set("Checked", _primitives.Ref.get(314, 0));
|
|
|
|
+ normalAppearanceDict.set("Off", _primitives.Ref.get(271, 0));
|
|
|
|
+ appearanceStatesDict.set("N", normalAppearanceDict);
|
|
|
|
+ buttonWidgetDict.set("AP", appearanceStatesDict);
|
|
|
|
+ buttonWidgetDict.set("V", _primitives.Name.get("Off"));
|
|
|
|
+
|
|
|
|
+ const buttonWidgetRef = _primitives.Ref.get(123, 0);
|
|
|
|
+
|
|
|
|
+ const xref = new _test_utils.XRefMock([{
|
|
|
|
+ ref: buttonWidgetRef,
|
|
|
|
+ data: buttonWidgetDict
|
|
|
|
+ }]);
|
|
|
|
+ partialEvaluator.xref = xref;
|
|
|
|
+ const task = new _worker.WorkerTask("test save");
|
|
|
|
+ const annotation = await _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock);
|
|
|
|
+ const annotationStorage = new Map();
|
|
|
|
+ annotationStorage.set(annotation.data.id, {
|
|
|
|
+ value: true,
|
|
|
|
+ rotation: 180
|
|
|
|
+ });
|
|
|
|
+ const [oldData] = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
+ oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
|
|
|
+ expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Btn " + "/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " + "/V /Checked /AS /Checked /M (date) /MK << /R 180>>>>\nendobj\n");
|
|
|
|
+ annotationStorage.set(annotation.data.id, {
|
|
|
|
+ value: false
|
|
|
|
+ });
|
|
|
|
+ const data = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
+ expect(data).toEqual(null);
|
|
|
|
+ });
|
|
it("should handle radio buttons with a field value", async function () {
|
|
it("should handle radio buttons with a field value", async function () {
|
|
const parentDict = new _primitives.Dict();
|
|
const parentDict = new _primitives.Dict();
|
|
parentDict.set("V", _primitives.Name.get("1"));
|
|
parentDict.set("V", _primitives.Name.get("1"));
|
|
@@ -2133,19 +2202,23 @@ describe("annotation", function () {
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: true
|
|
value: true
|
|
});
|
|
});
|
|
- let operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList: opList1
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList1.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList1.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList1.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList1.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
|
annotationStorage.set(annotation.data.id, {
|
|
annotationStorage.set(annotation.data.id, {
|
|
value: false
|
|
value: false
|
|
});
|
|
});
|
|
- operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList: opList2
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList2.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList2.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList2.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList2.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
});
|
|
});
|
|
it("should render radio buttons for printing using normal appearance", async function () {
|
|
it("should render radio buttons for printing using normal appearance", async function () {
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
@@ -2175,11 +2248,13 @@ describe("annotation", function () {
|
|
const task = new _worker.WorkerTask("test print");
|
|
const task = new _worker.WorkerTask("test print");
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotation = await _annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock);
|
|
const annotationStorage = new Map();
|
|
const annotationStorage = new Map();
|
|
- const operatorList = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
- expect(operatorList.argsArray.length).toEqual(3);
|
|
|
|
- expect(operatorList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
- expect(operatorList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
- expect(operatorList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await annotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, annotationStorage);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(3);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[0]).toEqual(["124R", [0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], false]);
|
|
|
|
+ expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
|
});
|
|
});
|
|
it("should save radio buttons", async function () {
|
|
it("should save radio buttons", async function () {
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
const appearanceStatesDict = new _primitives.Dict();
|
|
@@ -2624,7 +2699,7 @@ describe("annotation", function () {
|
|
value: ["A", "C"]
|
|
value: ["A", "C"]
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual(["/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2.00 -5.88 Td (a) Tj", "0.00 -6.75 Td (b) Tj", "ET Q EMC"].join("\n"));
|
|
|
|
|
|
+ expect(appearance).toEqual(["/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2 -5.88 Td (a) Tj", "0 -6.75 Td (b) Tj", "ET Q EMC"].join("\n"));
|
|
});
|
|
});
|
|
it("should render choice with multiple selections for printing", async function () {
|
|
it("should render choice with multiple selections for printing", async function () {
|
|
choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTISELECT);
|
|
choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTISELECT);
|
|
@@ -2645,7 +2720,34 @@ describe("annotation", function () {
|
|
value: ["B", "C"]
|
|
value: ["B", "C"]
|
|
});
|
|
});
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
const appearance = await annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
|
- expect(appearance).toEqual(["/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "1 -3.5 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2.00 -5.88 Td (b) Tj", "0.00 -6.75 Td (c) Tj", "ET Q EMC"].join("\n"));
|
|
|
|
|
|
+ expect(appearance).toEqual(["/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "1 -3.5 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2 -5.88 Td (b) Tj", "0 -6.75 Td (c) Tj", "ET Q EMC"].join("\n"));
|
|
|
|
+ });
|
|
|
|
+ it("should save rotated choice", async function () {
|
|
|
|
+ choiceWidgetDict.set("Opt", ["A", "B", "C"]);
|
|
|
|
+ choiceWidgetDict.set("V", "A");
|
|
|
|
+
|
|
|
|
+ const choiceWidgetRef = _primitives.Ref.get(123, 0);
|
|
|
|
+
|
|
|
|
+ const xref = new _test_utils.XRefMock([{
|
|
|
|
+ ref: choiceWidgetRef,
|
|
|
|
+ data: choiceWidgetDict
|
|
|
|
+ }, fontRefObj]);
|
|
|
|
+ partialEvaluator.xref = xref;
|
|
|
|
+ const task = new _worker.WorkerTask("test save");
|
|
|
|
+ const annotation = await _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock);
|
|
|
|
+ const annotationStorage = new Map();
|
|
|
|
+ annotationStorage.set(annotation.data.id, {
|
|
|
|
+ value: "C",
|
|
|
|
+ rotation: 270
|
|
|
|
+ });
|
|
|
|
+ const data = await annotation.save(partialEvaluator, task, annotationStorage);
|
|
|
|
+ expect(data.length).toEqual(2);
|
|
|
|
+ const [oldData, newData] = data;
|
|
|
|
+ expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
|
|
|
+ expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
|
|
+ oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(oldData.data).toEqual("123 0 obj\n" + "<< /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");
|
|
|
|
+ expect(newData.data).toEqual(["2 0 obj", "<< /Length 170 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10] /Matrix [0 -1 1 0 0 10]>> stream", "/Tx BMC q", "1 1 10 32 re W n", "0.600006 0.756866 0.854904 rg", "1 11.75 10 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 32 Tm", "2 -5.88 Td (A) Tj", "0 -6.75 Td (B) Tj", "0 -6.75 Td (C) Tj", "ET Q EMC", "endstream", "endobj\n"].join("\n"));
|
|
});
|
|
});
|
|
it("should save choice", async function () {
|
|
it("should save choice", async function () {
|
|
choiceWidgetDict.set("Opt", ["A", "B", "C"]);
|
|
choiceWidgetDict.set("Opt", ["A", "B", "C"]);
|
|
@@ -2671,7 +2773,7 @@ describe("annotation", function () {
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /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)>>\nendobj\n");
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /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)>>\nendobj\n");
|
|
- expect(newData.data).toEqual(["2 0 obj", "<< /Length 136 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10]>> stream", "/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2.00 -5.88 Td (C) Tj", "ET Q EMC", "endstream", "endobj\n"].join("\n"));
|
|
|
|
|
|
+ expect(newData.data).toEqual(["2 0 obj", "<< /Length 133 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10]>> stream", "/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2 -5.88 Td (C) Tj", "ET Q EMC", "endstream", "endobj\n"].join("\n"));
|
|
});
|
|
});
|
|
it("should save choice with multiple selections", async function () {
|
|
it("should save choice with multiple selections", async function () {
|
|
choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTISELECT);
|
|
choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTISELECT);
|
|
@@ -2698,7 +2800,7 @@ describe("annotation", function () {
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
expect(newData.ref).toEqual(_primitives.Ref.get(2, 0));
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
oldData.data = oldData.data.replace(/\(D:\d+\)/, "(date)");
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Ch /DA (/Helv 5 Tf) /DR " + "<< /Font << /Helv 314 0 R>>>> /Rect [0 0 32 10] /Ff 2097152 /Opt " + "[[(A) (a)] [(B) (b)] [(C) (c)] [(D) (d)]] /V [(B) (C)] /AP " + "<< /N 2 0 R>> /M (date)>>\nendobj\n");
|
|
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Ch /DA (/Helv 5 Tf) /DR " + "<< /Font << /Helv 314 0 R>>>> /Rect [0 0 32 10] /Ff 2097152 /Opt " + "[[(A) (a)] [(B) (b)] [(C) (c)] [(D) (d)]] /V [(B) (C)] /AP " + "<< /N 2 0 R>> /M (date)>>\nendobj\n");
|
|
- expect(newData.data).toEqual(["2 0 obj", "<< /Length 177 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10]>> stream", "/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "1 -3.5 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2.00 -5.88 Td (b) Tj", "0.00 -6.75 Td (c) Tj", "ET Q EMC", "endstream", "endobj\n"].join("\n"));
|
|
|
|
|
|
+ expect(newData.data).toEqual(["2 0 obj", "<< /Length 171 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10]>> stream", "/Tx BMC q", "1 1 32 10 re W n", "0.600006 0.756866 0.854904 rg", "1 3.25 32 6.75 re f", "1 -3.5 32 6.75 re f", "BT", "/Helv 5 Tf", "1 0 0 1 0 10 Tm", "2 -5.88 Td (b) Tj", "0 -6.75 Td (c) Tj", "ET Q EMC", "endstream", "endobj\n"].join("\n"));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
describe("LineAnnotation", function () {
|
|
describe("LineAnnotation", function () {
|
|
@@ -2929,6 +3031,43 @@ describe("annotation", function () {
|
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ describe("FreeTextAnnotation", () => {
|
|
|
|
+ it("should create a new FreeText annotation", async () => {
|
|
|
|
+ partialEvaluator.xref = new _test_utils.XRefMock();
|
|
|
|
+ const task = new _worker.WorkerTask("test FreeText creation");
|
|
|
|
+ const data = await _annotation.AnnotationFactory.saveNewAnnotations(partialEvaluator, task, [{
|
|
|
|
+ annotationType: _util.AnnotationEditorType.FREETEXT,
|
|
|
|
+ rect: [12, 34, 56, 78],
|
|
|
|
+ rotation: 0,
|
|
|
|
+ fontSize: 10,
|
|
|
|
+ color: [0, 0, 0],
|
|
|
|
+ value: "Hello PDF.js World!"
|
|
|
|
+ }]);
|
|
|
|
+ const base = data.annotations[0].data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(base).toEqual("2 0 obj\n" + "<< /Type /Annot /Subtype /FreeText /CreationDate (date) " + "/Rect [12 34 56 78] /DA (/Helv 10 Tf 0 g) /Contents (Hello PDF.js World!) " + "/F 4 /Border [0 0 0] /Rotate 0 /AP << /N 3 0 R>>>>\n" + "endobj\n");
|
|
|
|
+ const font = data.dependencies[0].data;
|
|
|
|
+ expect(font).toEqual("1 0 obj\n" + "<< /BaseFont /Helvetica /Type /Font /Subtype /Type1 /Encoding " + "/WinAnsiEncoding>>\n" + "endobj\n");
|
|
|
|
+ const appearance = data.dependencies[1].data;
|
|
|
|
+ expect(appearance).toEqual("3 0 obj\n" + "<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] " + "/Length 101 /Resources << /Font << /Helv 1 0 R>>>>>> stream\n" + "q\n" + "0 0 44 44 re W n\n" + "BT\n" + "1 0 0 1 0 47.5 Tm 0 Tc 0 g\n" + "/Helv 10 Tf\n" + "0 -13.5 Td (Hello PDF.js World!) Tj\n" + "ET\n" + "Q\n" + "endstream\n" + "\n" + "endobj\n");
|
|
|
|
+ });
|
|
|
|
+ it("should render an added FreeText annotation for printing", async function () {
|
|
|
|
+ partialEvaluator.xref = new _test_utils.XRefMock();
|
|
|
|
+ const task = new _worker.WorkerTask("test FreeText printing");
|
|
|
|
+ const freetextAnnotation = (await _annotation.AnnotationFactory.printNewAnnotations(partialEvaluator, task, [{
|
|
|
|
+ annotationType: _util.AnnotationEditorType.FREETEXT,
|
|
|
|
+ rect: [12, 34, 56, 78],
|
|
|
|
+ rotation: 0,
|
|
|
|
+ fontSize: 10,
|
|
|
|
+ color: [0, 0, 0],
|
|
|
|
+ value: "A"
|
|
|
|
+ }]))[0];
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await freetextAnnotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, null);
|
|
|
|
+ expect(opList.fnArray.length).toEqual(16);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.save, _util.OPS.constructPath, _util.OPS.clip, _util.OPS.endPath, _util.OPS.beginText, _util.OPS.setTextMatrix, _util.OPS.setCharSpacing, _util.OPS.setFillRGBColor, _util.OPS.dependency, _util.OPS.setFont, _util.OPS.moveText, _util.OPS.showText, _util.OPS.endText, _util.OPS.restore, _util.OPS.endAnnotation]);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
describe("InkAnnotation", function () {
|
|
describe("InkAnnotation", function () {
|
|
it("should handle a single ink list", async function () {
|
|
it("should handle a single ink list", async function () {
|
|
const inkDict = new _primitives.Dict();
|
|
const inkDict = new _primitives.Dict();
|
|
@@ -2993,6 +3132,80 @@ describe("annotation", function () {
|
|
y: 5
|
|
y: 5
|
|
}]);
|
|
}]);
|
|
});
|
|
});
|
|
|
|
+ it("should create a new Ink annotation", async function () {
|
|
|
|
+ partialEvaluator.xref = new _test_utils.XRefMock();
|
|
|
|
+ const task = new _worker.WorkerTask("test Ink creation");
|
|
|
|
+ const data = await _annotation.AnnotationFactory.saveNewAnnotations(partialEvaluator, task, [{
|
|
|
|
+ annotationType: _util.AnnotationEditorType.INK,
|
|
|
|
+ rect: [12, 34, 56, 78],
|
|
|
|
+ rotation: 0,
|
|
|
|
+ thickness: 1,
|
|
|
|
+ opacity: 1,
|
|
|
|
+ color: [0, 0, 0],
|
|
|
|
+ paths: [{
|
|
|
|
+ bezier: [10, 11, 12, 13, 14, 15, 16, 17, 22, 23, 24, 25, 26, 27],
|
|
|
|
+ points: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
+ }, {
|
|
|
|
+ bezier: [910, 911, 912, 913, 914, 915, 916, 917, 922, 923, 924, 925, 926, 927],
|
|
|
|
+ points: [91, 92, 93, 94, 95, 96, 97, 98]
|
|
|
|
+ }]
|
|
|
|
+ }]);
|
|
|
|
+ const base = data.annotations[0].data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(base).toEqual("1 0 obj\n" + "<< /Type /Annot /Subtype /Ink /CreationDate (date) /Rect [12 34 56 78] " + "/InkList [[1 2 3 4 5 6 7 8] [91 92 93 94 95 96 97 98]] /F 4 /Border [0 0 0] " + "/Rotate 0 /AP << /N 2 0 R>>>>\n" + "endobj\n");
|
|
|
|
+ const appearance = data.dependencies[0].data;
|
|
|
|
+ expect(appearance).toEqual("2 0 obj\n" + "<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] /Length 129>> stream\n" + "1 w 1 J 1 j\n" + "0 G\n" + "10 11 m\n" + "12 13 14 15 16 17 c\n" + "22 23 24 25 26 27 c\n" + "S\n" + "910 911 m\n" + "912 913 914 915 916 917 c\n" + "922 923 924 925 926 927 c\n" + "S\n" + "endstream\n" + "\n" + "endobj\n");
|
|
|
|
+ });
|
|
|
|
+ it("should create a new Ink annotation with some transparency", async function () {
|
|
|
|
+ partialEvaluator.xref = new _test_utils.XRefMock();
|
|
|
|
+ const task = new _worker.WorkerTask("test Ink creation");
|
|
|
|
+ const data = await _annotation.AnnotationFactory.saveNewAnnotations(partialEvaluator, task, [{
|
|
|
|
+ annotationType: _util.AnnotationEditorType.INK,
|
|
|
|
+ rect: [12, 34, 56, 78],
|
|
|
|
+ rotation: 0,
|
|
|
|
+ thickness: 1,
|
|
|
|
+ opacity: 0.12,
|
|
|
|
+ color: [0, 0, 0],
|
|
|
|
+ paths: [{
|
|
|
|
+ bezier: [10, 11, 12, 13, 14, 15, 16, 17, 22, 23, 24, 25, 26, 27],
|
|
|
|
+ points: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
+ }, {
|
|
|
|
+ bezier: [910, 911, 912, 913, 914, 915, 916, 917, 922, 923, 924, 925, 926, 927],
|
|
|
|
+ points: [91, 92, 93, 94, 95, 96, 97, 98]
|
|
|
|
+ }]
|
|
|
|
+ }]);
|
|
|
|
+ const base = data.annotations[0].data.replace(/\(D:\d+\)/, "(date)");
|
|
|
|
+ expect(base).toEqual("1 0 obj\n" + "<< /Type /Annot /Subtype /Ink /CreationDate (date) /Rect [12 34 56 78] " + "/InkList [[1 2 3 4 5 6 7 8] [91 92 93 94 95 96 97 98]] /F 4 /Border [0 0 0] " + "/Rotate 0 /AP << /N 2 0 R>>>>\n" + "endobj\n");
|
|
|
|
+ const appearance = data.dependencies[0].data;
|
|
|
|
+ expect(appearance).toEqual("2 0 obj\n" + "<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] /Length 136 /Resources " + "<< /ExtGState << /R0 << /CA 0.12 /Type /ExtGState>>>>>>>> stream\n" + "1 w 1 J 1 j\n" + "0 G\n" + "/R0 gs\n" + "10 11 m\n" + "12 13 14 15 16 17 c\n" + "22 23 24 25 26 27 c\n" + "S\n" + "910 911 m\n" + "912 913 914 915 916 917 c\n" + "922 923 924 925 926 927 c\n" + "S\n" + "endstream\n" + "\n" + "endobj\n");
|
|
|
|
+ });
|
|
|
|
+ it("should render an added Ink annotation for printing", async function () {
|
|
|
|
+ partialEvaluator.xref = new _test_utils.XRefMock();
|
|
|
|
+ const task = new _worker.WorkerTask("test Ink printing");
|
|
|
|
+ const inkAnnotation = (await _annotation.AnnotationFactory.printNewAnnotations(partialEvaluator, task, [{
|
|
|
|
+ annotationType: _util.AnnotationEditorType.INK,
|
|
|
|
+ rect: [12, 34, 56, 78],
|
|
|
|
+ rotation: 0,
|
|
|
|
+ thickness: 3,
|
|
|
|
+ opacity: 1,
|
|
|
|
+ color: [0, 255, 0],
|
|
|
|
+ paths: [{
|
|
|
|
+ bezier: [1, 2, 3, 4, 5, 6, 7, 8],
|
|
|
|
+ points: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
+ }]
|
|
|
|
+ }]))[0];
|
|
|
|
+ const {
|
|
|
|
+ opList
|
|
|
|
+ } = await inkAnnotation.getOperatorList(partialEvaluator, task, _util.RenderingIntentFlag.PRINT, false, null);
|
|
|
|
+ expect(opList.argsArray.length).toEqual(8);
|
|
|
|
+ expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setLineWidth, _util.OPS.setLineCap, _util.OPS.setLineJoin, _util.OPS.setStrokeRGBColor, _util.OPS.constructPath, _util.OPS.stroke, _util.OPS.endAnnotation]);
|
|
|
|
+ expect(opList.argsArray[1]).toEqual([3]);
|
|
|
|
+ expect(opList.argsArray[2]).toEqual([1]);
|
|
|
|
+ expect(opList.argsArray[3]).toEqual([1]);
|
|
|
|
+ expect(opList.argsArray[4]).toEqual(new Uint8ClampedArray([0, 255, 0]));
|
|
|
|
+ expect(opList.argsArray[5][0]).toEqual([_util.OPS.moveTo, _util.OPS.curveTo]);
|
|
|
|
+ expect(opList.argsArray[5][1]).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
|
|
+ expect(opList.argsArray[5][2]).toEqual([1, 1, 2, 2]);
|
|
|
|
+ });
|
|
});
|
|
});
|
|
describe("HightlightAnnotation", function () {
|
|
describe("HightlightAnnotation", function () {
|
|
it("should set quadpoints to null if not defined", async function () {
|
|
it("should set quadpoints to null if not defined", async function () {
|