Merge pull request #16020 from calixteman/bug1815476
[Annotation] Avoid to encrypt the appearance stream two times (bug 1815476)
This commit is contained in:
commit
ecd86ccffc
@ -1894,13 +1894,11 @@ class WidgetAnnotation extends Annotation {
|
|||||||
let newTransform = null;
|
let newTransform = null;
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
|
newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
|
||||||
appearance = newTransform.encryptString(appearance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const resources = this._getSaveFieldResources(xref);
|
const resources = this._getSaveFieldResources(xref);
|
||||||
const appearanceStream = new StringStream(appearance);
|
const appearanceStream = new StringStream(appearance);
|
||||||
const appearanceDict = (appearanceStream.dict = new Dict(xref));
|
const appearanceDict = (appearanceStream.dict = new Dict(xref));
|
||||||
appearanceDict.set("Length", appearance.length);
|
|
||||||
appearanceDict.set("Subtype", Name.get("Form"));
|
appearanceDict.set("Subtype", Name.get("Form"));
|
||||||
appearanceDict.set("Resources", resources);
|
appearanceDict.set("Resources", resources);
|
||||||
appearanceDict.set("BBox", [
|
appearanceDict.set("BBox", [
|
||||||
@ -3669,7 +3667,6 @@ class FreeTextAnnotation extends MarkupAnnotation {
|
|||||||
appearanceStreamDict.set("Subtype", Name.get("Form"));
|
appearanceStreamDict.set("Subtype", Name.get("Form"));
|
||||||
appearanceStreamDict.set("Type", Name.get("XObject"));
|
appearanceStreamDict.set("Type", Name.get("XObject"));
|
||||||
appearanceStreamDict.set("BBox", [0, 0, w, h]);
|
appearanceStreamDict.set("BBox", [0, 0, w, h]);
|
||||||
appearanceStreamDict.set("Length", appearance.length);
|
|
||||||
appearanceStreamDict.set("Resources", resources);
|
appearanceStreamDict.set("Resources", resources);
|
||||||
|
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
|
@ -45,13 +45,13 @@ function writeDict(dict, buffer, transform) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function writeStream(stream, buffer, transform) {
|
function writeStream(stream, buffer, transform) {
|
||||||
writeDict(stream.dict, buffer, transform);
|
|
||||||
buffer.push(" stream\n");
|
|
||||||
let string = stream.getString();
|
let string = stream.getString();
|
||||||
if (transform !== null) {
|
if (transform !== null) {
|
||||||
string = transform.encryptString(string);
|
string = transform.encryptString(string);
|
||||||
}
|
}
|
||||||
buffer.push(string, "\nendstream");
|
stream.dict.set("Length", string.length);
|
||||||
|
writeDict(stream.dict, buffer, transform);
|
||||||
|
buffer.push(" stream\n", string, "\nendstream");
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeArray(array, buffer, transform) {
|
function writeArray(array, buffer, transform) {
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -571,3 +571,4 @@
|
|||||||
!autoprint.pdf
|
!autoprint.pdf
|
||||||
!bug1811694.pdf
|
!bug1811694.pdf
|
||||||
!bug1811510.pdf
|
!bug1811510.pdf
|
||||||
|
!bug1815476.pdf
|
||||||
|
BIN
test/pdfs/bug1815476.pdf
Executable file
BIN
test/pdfs/bug1815476.pdf
Executable file
Binary file not shown.
@ -7332,5 +7332,22 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bug1815476-save-print",
|
||||||
|
"file": "pdfs/bug1815476.pdf",
|
||||||
|
"md5": "476f77da5f9422ef86ea5f4531602e93",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"save": true,
|
||||||
|
"print": true,
|
||||||
|
"annotationStorage": {
|
||||||
|
"88R": {
|
||||||
|
"value": "foo"
|
||||||
|
},
|
||||||
|
"87R": {
|
||||||
|
"value": "bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -2062,8 +2062,8 @@ describe("annotation", function () {
|
|||||||
"/V (hello world) /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
"/V (hello world) /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
||||||
);
|
);
|
||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
"2 0 obj\n<< /Length 74 /Subtype /Form /Resources " +
|
"2 0 obj\n<< /Subtype /Form /Resources " +
|
||||||
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10]>> stream\n" +
|
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Length 74>> stream\n" +
|
||||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 3.07 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"
|
"ET Q EMC\nendstream\nendobj\n"
|
||||||
);
|
);
|
||||||
@ -2108,8 +2108,8 @@ describe("annotation", function () {
|
|||||||
"/V (hello world) /MK << /R 90>> /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
"/V (hello world) /MK << /R 90>> /AP << /N 2 0 R>> /M (date)>>\nendobj\n"
|
||||||
);
|
);
|
||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
"2 0 obj\n<< /Length 74 /Subtype /Form /Resources " +
|
"2 0 obj\n<< /Subtype /Form /Resources " +
|
||||||
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Matrix [0 1 -1 0 32 0]>> stream\n" +
|
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Matrix [0 1 -1 0 32 0] /Length 74>> stream\n" +
|
||||||
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 2.94 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"
|
"ET Q EMC\nendstream\nendobj\n"
|
||||||
);
|
);
|
||||||
@ -2239,8 +2239,8 @@ describe("annotation", function () {
|
|||||||
`/V (\xfe\xff${utf16String}) /AP << /N 2 0 R>> /M (date)>>\nendobj\n`
|
`/V (\xfe\xff${utf16String}) /AP << /N 2 0 R>> /M (date)>>\nendobj\n`
|
||||||
);
|
);
|
||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
"2 0 obj\n<< /Length 79 /Subtype /Form /Resources " +
|
"2 0 obj\n<< /Subtype /Form /Resources " +
|
||||||
"<< /Font << /Helv 314 0 R /Goth 159 0 R>>>> /BBox [0 0 32 10]>> stream\n" +
|
"<< /Font << /Helv 314 0 R /Goth 159 0 R>>>> /BBox [0 0 32 10] /Length 79>> stream\n" +
|
||||||
`/Tx BMC q BT /Goth 5 Tf 1 0 0 1 0 0 Tm 2 3.07 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"
|
"ET Q EMC\nendstream\nendobj\n"
|
||||||
);
|
);
|
||||||
@ -3626,8 +3626,8 @@ describe("annotation", function () {
|
|||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
[
|
[
|
||||||
"2 0 obj",
|
"2 0 obj",
|
||||||
"<< /Length 170 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
"<< /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
||||||
"/BBox [0 0 32 10] /Matrix [0 -1 1 0 0 10]>> stream",
|
"/BBox [0 0 32 10] /Matrix [0 -1 1 0 0 10] /Length 170>> stream",
|
||||||
"/Tx BMC q",
|
"/Tx BMC q",
|
||||||
"1 1 10 32 re W n",
|
"1 1 10 32 re W n",
|
||||||
"0.600006 0.756866 0.854904 rg",
|
"0.600006 0.756866 0.854904 rg",
|
||||||
@ -3687,8 +3687,8 @@ describe("annotation", function () {
|
|||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
[
|
[
|
||||||
"2 0 obj",
|
"2 0 obj",
|
||||||
"<< /Length 133 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
"<< /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
||||||
"/BBox [0 0 32 10]>> stream",
|
"/BBox [0 0 32 10] /Length 133>> stream",
|
||||||
"/Tx BMC q",
|
"/Tx BMC q",
|
||||||
"1 1 32 10 re W n",
|
"1 1 32 10 re W n",
|
||||||
"0.600006 0.756866 0.854904 rg",
|
"0.600006 0.756866 0.854904 rg",
|
||||||
@ -3753,8 +3753,8 @@ describe("annotation", function () {
|
|||||||
expect(newData.data).toEqual(
|
expect(newData.data).toEqual(
|
||||||
[
|
[
|
||||||
"2 0 obj",
|
"2 0 obj",
|
||||||
"<< /Length 171 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
"<< /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
|
||||||
"/BBox [0 0 32 10]>> stream",
|
"/BBox [0 0 32 10] /Length 171>> stream",
|
||||||
"/Tx BMC q",
|
"/Tx BMC q",
|
||||||
"1 1 32 10 re W n",
|
"1 1 32 10 re W n",
|
||||||
"0.600006 0.756866 0.854904 rg",
|
"0.600006 0.756866 0.854904 rg",
|
||||||
@ -4058,7 +4058,7 @@ describe("annotation", function () {
|
|||||||
expect(appearance).toEqual(
|
expect(appearance).toEqual(
|
||||||
"3 0 obj\n" +
|
"3 0 obj\n" +
|
||||||
"<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] " +
|
"<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] " +
|
||||||
"/Length 101 /Resources << /Font << /Helv 1 0 R>>>>>> stream\n" +
|
"/Resources << /Font << /Helv 1 0 R>>>> /Length 101>> stream\n" +
|
||||||
"q\n" +
|
"q\n" +
|
||||||
"0 0 44 44 re W n\n" +
|
"0 0 44 44 re W n\n" +
|
||||||
"BT\n" +
|
"BT\n" +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user