Skip to content

Journal / Cache issue #191

Description

@xeladotbe

Hi,

I'm trying to render a page twice once I've added and undoing and added again a stamp annotation.

Steps to reproduce:

  • Create stamp annotation with custom image
  • Render page as image (page.toPixmap)
  • Undo all operations in journal
  • Create stamp annotation with custom image
  • Render page as image (page.toPixmap)
    The console shows some warnings/errors
Image

I've written a simple test to reproduce the issue:

    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"),
        );
    });
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions