Selectively Flattening Fields w/ getFileData()

WebViewer Version: 7.3.0

Do you have an issue with a specific file(s)? No.
Can you reproduce using one of our samples or online demos? No.
Are you using the WebViewer server? No.
Does the issue only happen on certain browsers? No.
Is your issue related to a front-end framework? No.
Is your issue related to annotations? Yes.

Please give a brief summary of your issue:
I’m unable to download a PDF file that both (1) selectively disables annotations (flattens, sets ReadOnly, etc), while (2) continuing to allow users to select the annotation text in the downloaded document.

Please describe your issue and provide steps to reproduce it:
I’ve tried three approaches to this problem, with mixed success:

  • [Not Successful] Using getFileData() per the docs here. While getFileData() has a flatten option, I don’t see any options to specify that only some fields should be flattened.
  • [Not Successful] Setting the LockedContents flag here on the desired annotations to true, then calling getFileData(). However, annotations in the downloaded file are still editable.
  • [Partial Success] Setting the ReadOnly flag on the desired annotations to true, then calling getFileData(). This method successfully disabled editing the annotations in the downloaded document, but also prevents users from selecting text in the downloaded document. This is problematic for users who need to copy-paste information out of the PDF.

Any advice on how to achieve this goal?

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:

Hello Tim,

Welcome to the PDFTron community forum!

Have you tried the .Locked property? It prevents editing and deleting but you can still select the annotation and text under the annotation.
https://www.pdftron.com/api/web/Core.Annotations.FreeHandAnnotation.html#Locked__anchor

Best Regards,
Tyler Gordon
Web Development Support Engineer
PDFTron Systems, Inc.
www.pdftron.com

Hi Tyler,

I have tried the ‘Locked’ and ‘LockedContent’ flags, but the annotations are still editable in both the WebViewer and downloaded PDF File. I think I’m calling the flag setting function correctly, but perhaps you can tell me if this is wrong:

Note, this successfully sets the ReadOnly flag:
annotation.fieldFlags.set('ReadOnly', true)

However, this is not causing the annotation to be locked:
annotation.fieldFlags.set('Locked', true);
annotation.fieldFlags.set('LockedContents', true);

Thanks!

Hi Tim,

.fieldFlags.set() only supports these flags (which is why only ReadOnly worked): PDFTron WebViewer Class: WidgetFlags

You can directly set the Locked and LockedContents property of an annotation by doing:

annotation.Locked = true;
annotation.LockedContents = true;

Best Regards,
Tyler Gordon
Web Development Support Engineer
PDFTron Systems, Inc.
www.pdftron.com