Cannot lock pdf

PDF.js Express Version

Detailed description of issue
I want to be able to lock the generated pdf when I save the uploaded template

Expected behavior
I want to be able to lock the generated pdf when I save the uploaded template. If i open with a pdf tool in mac os, Linux, or Adobe, I can still edit the downloaded version of pdf even if i set all the items on read-only.

Does your issue happen with every document, or just one?
This happens to all the templates I have uploaded.

Code snippet

// On Save event
const list = instance.annotManager.getAnnotationsList();

        list.forEach(item => {
                item.ReadOnly = true
        })

        instance.annotManager.setReadOnly(true);

         // Get the annotations and the documents data
        const xfdf = await instance.annotManager.exportAnnotations({});
        const fileData = await instance.docViewer.getDocument().getFileData({});

        // Set the annotations and document into the Utility SDK, then merge them together
        const resp = await utils
                          .setFile(fileData)
                          .setXFDF(xfdf)
                          .merge();

       // Get the resulting blob from the merge operation
       const mergedBlob = await resp.getBlob();

       // trigger a download for the user!
       FileSaver.saveAs(mergedBlob, 'myfile.pdf')

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 Dejvis,

Some further information would help get to the route of your issue. What annotations are not becoming read-only? Is it all annotation or just form fields? Could you possibly share the PDF file you are testing this code snippet on?

I did notice your code actually didn’t set form fields to read-only so you can try adding this to your loop to see if it helps.

        list.forEach(item => {
                item.ReadOnly = true
                if(item.fieldFlags){
                  item.fieldFlags.set('ReadOnly', true);
                }
        })

Further, this line is not need instance.annotManager.setReadOnly(true); As it only sets the local viewer to read-only mode and does not lock the file.

Cheers,
Dustin