1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[Editor] Add support for printing newly added FreeText annotations

This commit is contained in:
Calixte Denizet 2022-06-22 11:46:02 +02:00
parent eca939d904
commit 30c63eb0ec
3 changed files with 125 additions and 79 deletions

View file

@ -4069,6 +4069,50 @@ describe("annotation", function () {
"endobj\n"
);
});
it("should render an added FreeText annotation for printing", async function () {
partialEvaluator.xref = new XRefMock();
const task = new WorkerTask("test FreeText printing");
const freetextAnnotation = (
await AnnotationFactory.printNewAnnotations(partialEvaluator, task, [
{
annotationType: AnnotationEditorType.FREETEXT,
rect: [12, 34, 56, 78],
fontSize: 10,
color: [0, 0, 0],
value: "A",
},
])
)[0];
const operatorList = await freetextAnnotation.getOperatorList(
partialEvaluator,
task,
RenderingIntentFlag.PRINT,
false,
null
);
expect(operatorList.fnArray.length).toEqual(16);
expect(operatorList.fnArray).toEqual([
OPS.beginAnnotation,
OPS.save,
OPS.constructPath,
OPS.clip,
OPS.endPath,
OPS.beginText,
OPS.setTextMatrix,
OPS.setCharSpacing,
OPS.setFillRGBColor,
OPS.dependency,
OPS.setFont,
OPS.moveText,
OPS.showText,
OPS.endText,
OPS.restore,
OPS.endAnnotation,
]);
});
});
describe("InkAnnotation", function () {

View file

@ -13,12 +13,12 @@
* limitations under the License.
*/
import { NullStream, StringStream } from "../../src/core/stream.js";
import { Page, PDFDocument } from "../../src/core/document.js";
import { assert } from "../../src/shared/util.js";
import { DocStats } from "../../src/core/core_utils.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { Ref } from "../../src/core/primitives.js";
import { StringStream } from "../../src/core/stream.js";
const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
@ -79,6 +79,7 @@ class XRefMock {
this._map = Object.create(null);
this.stats = new DocStats({ send: () => {} });
this._newRefNum = null;
this.stream = new NullStream();
for (const key in array) {
const obj = array[key];