Annotation seems to be doubling or Creating a weird bold when doing a download externally

PDF.js Express Version

Detailed description of issue
I have been having issues with having a double annoation or a weird bold when downloading a document on a external button click.

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

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

Link to document
{Provide a link to the document in question if possible}

As you can see it seems to be bolded or the annotation got added twice.
Code snippet



 async function _DownloadContracts() {
        try {
            setVisibilityShowen(true);
            const xfdf = await instance?.annotManager.exportAnnotations({});
        
            const fileData = await instance?.docViewer.getDocument().getFileData({});
            
            if (xfdf && fileData) {
                const resp = await pdfUtils.setFile(fileData).setXFDF(xfdf).merge();

                const mergedBlob = await resp.getBlob();
                FileSaver.saveAs(mergedBlob, selectedFile.name);
            }
        } catch (e) {
        } finally {
            setVisibilityShowen(false);
        }
    }

Thanks For the help

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi there,

How are you re-opening the document? Do you see this issue when opening the document in other viewers?

If you are extracting and importing annotations on document load, you need to make sure you are passing the disableFlattenedAnnotations option to the PDF.js Express constructor. Not doing so will result in duplicate annotations like you are seeing.

Thanks,
Logan

No I only see it when i am downloading the document.

If I were to do the disableflattenedAnnotation option wouldn’t that disabled the flattened Annotation for the previewer as well?

Thanks

Unfortunately this does not answer my questions. I need anwsers to these questions before I can diagnose what is going on.

Do you see this issue when opening the document in other viewers?

How are you re-opening the document?

Thanks!
Logan

Do you see this issue when opening the document in other viewers?
No there is no issues when viewing on other previewers.

How are you re-opening the document?

  async function _DownloadContracts() {
        try {
            setVisibilityShowen(true);
            const xfdf = await instance?.annotManager.exportAnnotations({});
     
            const fileData = await instance?.docViewer.getDocument().getFileData({});

            if (xfdf && fileData) {
                const resp = await pdfUtils.setFile(fileData).setXFDF(xfdf).merge();

                const mergedBlob = await resp.getBlob();
                FileSaver.saveAs(mergedBlob, selectedFile.name);
            }
        } catch (e) {
        } finally {
            setVisibilityShowen(false);
        }
    }

This is how i am trying to download the document so first i grab what ever is on the previewer filedata that is on the previewer then re add the annotations. Which i am not to sure thats the right way of doing it.

I hope this answer the question. Sorry for being difficult.

Hi there,

You still have not answered my question about how you are loading the document after its been downloaded. Are you using the rest API to extract and load annotations when a document is loaded? What does your document loading code look like?

The reason this happens is usually because the annotations are being loaded twice - the ones baked into the document from the merge operation that you are doing, and another time when you load the document and extract and import the XFDF.

If you are using the rest API to extract and load annotations, then you need to provide the disableFlattenedAnnotations option.

Thanks,
Logan