I'm trying to render a page twice once I've added and undoing and added again a stamp annotation.
const createAnnotation = (page: mupdf.PDFPage) => {
const annotation = page.createAnnotation("Stamp");
const stampImage = new mupdf.Image(
fs.readFileSync(
path.resolve(
__dirname,
"./resources/unterschrift-max-mustermann.png",
),
).buffer as any,
);
annotation.setIcon("signature");
annotation.setStampImage(stampImage);
};
it("should create image from pixmap", () => {
createAnnotation(document.loadPage(0));
const firstCall = document
.loadPage(0)
.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceBGR);
fs.writeFileSync("./first-call.png", firstCall.asPNG());
// remove the next two lines and the test will pass
while (document.canUndo()) document.undo();
createAnnotation(document.loadPage(0));
const secondCall = document
.loadPage(0)
.toPixmap(mupdf.Matrix.identity, mupdf.ColorSpace.DeviceBGR);
fs.writeFileSync("./second-call.png", secondCall.asPNG());
// remove the expect to see the warnings/errors in the console
expect(
Buffer.from(
toArrayBuffer(firstCall.asPNG().slice(0, 100)),
).toString("base64"),
).toStrictEqual(
Buffer.from(
toArrayBuffer(secondCall.asPNG().slice(0, 100)),
).toString("base64"),
);
});
Hi,
I'm trying to render a page twice once I've added and undoing and added again a stamp annotation.
Steps to reproduce:
The console shows some warnings/errors
I've written a simple test to reproduce the issue: