Colours on Drawn Signatures not saving

Which product are you using?

PDF.js Express Plus

PDF.js Express Version

UI version ‘8.7.0’
Core version ‘8.7.5’

Detailed description of issue
I’m saving signatures that the user draws. If the user creates a signature using first the blue colour and then a second using red, then the signatures will be shown in the drop down using the correct colour.

However, if I save the signatures and then try to import the signatures again then both of the signatures in the drop down will be red instead of blue and red.

You can see in the example below that the Blue signature was originally saved as blue and added to the PDF. When I opened the editor later the signature was still blue in the PDF but it had changed to red in the drop down menu.

Expected behaviour
I would expect the colour of the signature to be saved with each entry in the drop down.

Is this a bug or expected behaviour?

Does your issue happen with every document, or just one?
Every document

Link to document
N/A

Code snippet

Hello tomc,

How are you importing and exporting the signatures for the tool?

Best regards,
Tyler

@tgordon

We save the signatures as a string and use the string to import them later on.

Export Signatures

function sendSignaturesToTheApp(typeName) {
    signatureTool.exportSignatures().then((signatures) => {
        if (signatures === null || signatures === undefined) {
            writeErrorMessage('Signatures JSON is null or undefined');
            return;
        }

        const stringValue = JSON.stringify(signatures);
        const jsonValue = JSON.parse(stringValue);
        const deepClonedSignatures = JSON.parse(JSON.stringify(signatures));
        const valToSend = JSON.stringify(deepClonedSignatures);

        window.top.postMessage({
            type: typeName,
            signatures: JSON.parse(valToSend)
        }, getUrl());

    });
}

Import Signatures

const parsedString = JSON.parse(signatureString);
signatureTool.importSignatures(parsedString).then(() => { });

Hello tomc,

exportSignatures only exports the freehand paths, a list of points. The colour is tied to the annotation or tool, which is not included with the path data. So when you import the paths for the signatures it defaults to the tool’s current colour.

I would instead use saveSignatures() and getSavedSignatures() which returns the annotation data in XFDF which will save the colour.

Let me know if that works for you!

Best regards,
Tyler