mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Merge pull request #12395 from calixteman/checks
Render not displayed annotations in using normal appearance when printing
This commit is contained in:
commit
ea4d88a330
6 changed files with 204 additions and 6 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -107,6 +107,7 @@
|
|||
!bug766086.pdf
|
||||
!bug793632.pdf
|
||||
!bug1020858.pdf
|
||||
!prefilled_f1040.pdf
|
||||
!bug1050040.pdf
|
||||
!bug1200096.pdf
|
||||
!bug1068432.pdf
|
||||
|
|
BIN
test/pdfs/prefilled_f1040.pdf
Normal file
BIN
test/pdfs/prefilled_f1040.pdf
Normal file
Binary file not shown.
|
@ -3668,6 +3668,16 @@
|
|||
"type": "eq",
|
||||
"about": "CFF font that is drawn with clipping."
|
||||
},
|
||||
{ "id": "prefilled_f1040",
|
||||
"file": "pdfs/prefilled_f1040.pdf",
|
||||
"md5": "2335da66fb7c2c3b84971597f27785e2",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"1605R": true
|
||||
}
|
||||
},
|
||||
{ "id": "clippath",
|
||||
"file": "pdfs/clippath.pdf",
|
||||
"md5": "7ab95c0f106dccd90d6569f241fe8771",
|
||||
|
|
|
@ -1611,6 +1611,55 @@ describe("annotation", function () {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should render regular text for printing using normal appearance", function (done) {
|
||||
const textWidgetRef = Ref.get(271, 0);
|
||||
|
||||
const appearanceStatesDict = new Dict();
|
||||
const normalAppearanceDict = new Dict();
|
||||
|
||||
const normalAppearanceStream = new StringStream("0.1 0.2 0.3 rg");
|
||||
normalAppearanceStream.dict = normalAppearanceDict;
|
||||
|
||||
appearanceStatesDict.set("N", normalAppearanceStream);
|
||||
textWidgetDict.set("AP", appearanceStatesDict);
|
||||
|
||||
const xref = new XRefMock([
|
||||
{ ref: textWidgetRef, data: textWidgetDict },
|
||||
fontRefObj,
|
||||
]);
|
||||
const task = new WorkerTask("test print");
|
||||
partialEvaluator.xref = xref;
|
||||
|
||||
AnnotationFactory.create(
|
||||
xref,
|
||||
textWidgetRef,
|
||||
pdfManagerMock,
|
||||
idFactoryMock
|
||||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
false,
|
||||
annotationStorage
|
||||
);
|
||||
})
|
||||
.then(opList => {
|
||||
expect(opList.argsArray.length).toEqual(3);
|
||||
expect(opList.fnArray).toEqual([
|
||||
OPS.beginAnnotation,
|
||||
OPS.setFillRGBColor,
|
||||
OPS.endAnnotation,
|
||||
]);
|
||||
expect(opList.argsArray[1]).toEqual(
|
||||
new Uint8ClampedArray([26, 51, 76])
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("should render auto-sized text for printing", function (done) {
|
||||
textWidgetDict.set("DA", "/Helv 0 Tf");
|
||||
|
||||
|
@ -2278,6 +2327,64 @@ describe("annotation", function () {
|
|||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("should render checkboxes for printing using normal appearance", function (done) {
|
||||
const appearanceStatesDict = new Dict();
|
||||
const normalAppearanceDict = new Dict();
|
||||
const checkedAppearanceDict = new Dict();
|
||||
const uncheckedAppearanceDict = new Dict();
|
||||
|
||||
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
||||
checkedStream.dict = checkedAppearanceDict;
|
||||
|
||||
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
||||
uncheckedStream.dict = uncheckedAppearanceDict;
|
||||
|
||||
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
||||
checkedAppearanceDict.set("FormType", 1);
|
||||
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
||||
normalAppearanceDict.set("Checked", checkedStream);
|
||||
normalAppearanceDict.set("Off", uncheckedStream);
|
||||
appearanceStatesDict.set("N", normalAppearanceDict);
|
||||
|
||||
buttonWidgetDict.set("AP", appearanceStatesDict);
|
||||
buttonWidgetDict.set("AS", Name.get("Checked"));
|
||||
|
||||
const buttonWidgetRef = Ref.get(124, 0);
|
||||
const xref = new XRefMock([
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
||||
]);
|
||||
const task = new WorkerTask("test print");
|
||||
|
||||
AnnotationFactory.create(
|
||||
xref,
|
||||
buttonWidgetRef,
|
||||
pdfManagerMock,
|
||||
idFactoryMock
|
||||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
false,
|
||||
annotationStorage
|
||||
);
|
||||
})
|
||||
.then(opList => {
|
||||
expect(opList.argsArray.length).toEqual(3);
|
||||
expect(opList.fnArray).toEqual([
|
||||
OPS.beginAnnotation,
|
||||
OPS.setFillRGBColor,
|
||||
OPS.endAnnotation,
|
||||
]);
|
||||
expect(opList.argsArray[1]).toEqual(
|
||||
new Uint8ClampedArray([26, 51, 76])
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("should save checkboxes", function (done) {
|
||||
const appearanceStatesDict = new Dict();
|
||||
const normalAppearanceDict = new Dict();
|
||||
|
@ -2513,6 +2620,65 @@ describe("annotation", function () {
|
|||
}, done.fail);
|
||||
});
|
||||
|
||||
it("should render radio buttons for printing using normal appearance", function (done) {
|
||||
const appearanceStatesDict = new Dict();
|
||||
const normalAppearanceDict = new Dict();
|
||||
const checkedAppearanceDict = new Dict();
|
||||
const uncheckedAppearanceDict = new Dict();
|
||||
|
||||
const checkedStream = new StringStream("0.1 0.2 0.3 rg");
|
||||
checkedStream.dict = checkedAppearanceDict;
|
||||
|
||||
const uncheckedStream = new StringStream("0.3 0.2 0.1 rg");
|
||||
uncheckedStream.dict = uncheckedAppearanceDict;
|
||||
|
||||
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
||||
checkedAppearanceDict.set("FormType", 1);
|
||||
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
||||
normalAppearanceDict.set("Checked", checkedStream);
|
||||
normalAppearanceDict.set("Off", uncheckedStream);
|
||||
appearanceStatesDict.set("N", normalAppearanceDict);
|
||||
|
||||
buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO);
|
||||
buttonWidgetDict.set("AP", appearanceStatesDict);
|
||||
buttonWidgetDict.set("AS", Name.get("Off"));
|
||||
|
||||
const buttonWidgetRef = Ref.get(124, 0);
|
||||
const xref = new XRefMock([
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict },
|
||||
]);
|
||||
const task = new WorkerTask("test print");
|
||||
|
||||
AnnotationFactory.create(
|
||||
xref,
|
||||
buttonWidgetRef,
|
||||
pdfManagerMock,
|
||||
idFactoryMock
|
||||
)
|
||||
.then(annotation => {
|
||||
const annotationStorage = {};
|
||||
return annotation.getOperatorList(
|
||||
partialEvaluator,
|
||||
task,
|
||||
false,
|
||||
annotationStorage
|
||||
);
|
||||
})
|
||||
.then(opList => {
|
||||
expect(opList.argsArray.length).toEqual(3);
|
||||
expect(opList.fnArray).toEqual([
|
||||
OPS.beginAnnotation,
|
||||
OPS.setFillRGBColor,
|
||||
OPS.endAnnotation,
|
||||
]);
|
||||
expect(opList.argsArray[1]).toEqual(
|
||||
new Uint8ClampedArray([76, 51, 26])
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
});
|
||||
|
||||
it("should save radio buttons", function (done) {
|
||||
const appearanceStatesDict = new Dict();
|
||||
const normalAppearanceDict = new Dict();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue