What permission is required for op.document.importCommentsAndFields  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 1371
Joined: Thu Sep 05, 2019 12:35 pm

What permission is required for op.document.importCommentsAndFields

Post by zarkogajic »

Hi Support.

I'm opening a PDF using CreateOpenDocParams and specifying "PermF_All - PermF_EditNotes" for SecPermMask -> this allows to add comments to a file (without any other operations being allowed).

I then create some comments and save using op.document.exportCommentsAndFields.

Next, I open the same document using PermF_All for permissions (so full "read-only mode").

Then, I want to op.document.importCommentsAndFields.

This fails (expected) with "no permission for this operation".

I would therefore like to:

1. set the needed permission
2. do op.document.importCommentsAndFields
3. remove permission

Whatever I tried I cannot make the operation to succeed.

I've tried, for [1], the below, but nothing works:

//same how the document was opened when allowing commenting
Document.CoreDoc.SetRestrictedPermissions(PermF_All AND NOT (PermF_EditNotes));

//trying to allow various operations on Annot objects
Document.CoreDoc.SetOperationRestriction(Perm_ObjAnnot, Perm_OperCreate, false);
Document.CoreDoc.SetOperationRestriction(Perm_ObjForm, Perm_OperModify, false);

So: how to temporary allow importing comments from [x]fdf ?

-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: What permission is required for op.document.importCommentsAndFields

Post by Vasyl-Tracker Dev Team »

How about this:

doc.SetRestrictedPermissions(0);

// import...

doc.SetRestrictedPermissions(PermF_All);
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1371
Joined: Thu Sep 05, 2019 12:35 pm

Re: What permission is required for op.document.importCommentsAndFields

Post by zarkogajic »

Hi Vasyl,

Thanks, but does not work :(

Please note:

I'm opening documents using CreateOpenDocParams and the SecPermMask option.

When using "PermF_All - (PermF_Copy + PermF_EditNotes)" -> this allows to add/edit comments and save them.

Strangely (just discovered by try-fail): if only using "PermF_All - (PermF_EditNotes)" (so copy not allowed), then EXPORTCommentsAndFields will also fail with "no permission..."


Next, I'm opening the same document using only "PermF_All - PermF_Copy" -> BUT I want to be able to do IMPORTCommentsAndFields on such document. As said, this fails (also expected).

Calling "Document.CoreDoc.SetRestrictedPermissions(0);" before importCommentsAndFields does "nothing".

For test:

CoreDoc.RequestPermission(Perm_ObjAnnot, Perm_OperCreate); results in Perm_ReqDenied (expected)
CoreDoc.SetRestrictedPermissions(0);
CoreDoc.RequestPermission(Perm_ObjAnnot, Perm_OperCreate); results in Perm_ReqDenied (NOT expected)


Do I need to raise some event after CoreDoc.SetRestrictedPermissions(0); or something?

Can you please check, permission by permission, what is required for IMPORTCommentsAndFields ?

p.s.
What's even more crazy and driving me slightly mad:

If I
1. Open document using "PermF_All - (PermF_Copy + PermF_EditNotes)"
2. IMPORT
3. CoreDoc.SetRestrictedPermissions(PermF_All - PermF_Copy)

Comments get imported (expected) and comments are no longer editable (also expected).

So one "direction" (allow -> restrict) works as expected and the other (restrict -> allow) does not.


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: What permission is required for op.document.importCommentsAndFields

Post by Vasyl-Tracker Dev Team »

Well, to make the situation as clear as possible...

The core-document has 3 different layers of permissions.
1. document's level, managed by document's actual security or by digital signature. You cannot change those permissions without changing the security.
2. developer level, managed by dev, via doc.SetRestrictedPermissions and/or doc.SetOperationRestriction
3. editor's internal level for special doc-restrictions, you can specify it only when open document, in open-operation's opts or in PXC_Inst::OpenDocumentFromXXX arg. And you cannot change it for an existing document.

And finally, any perm is calculated:
Perm = DocPerm AND DevPerm AND EditorPerm;

So in your case, the best solution will be:

1. open doc with RestrictedPermissions==0
2. use doc.SetRestrictedPermissions(PermF_All & ~(PermF_Copy | PermF_EditNotes));

then for import:

1. doc.SetRestrictedPermissions(0);
2. import
3. doc.SetRestrictedPermissions(PermF_All & ~(PermF_Copy | PermF_EditNotes));

Tip: to allow form filling for users - you may combine with Permit_FormFilling flag, like:
doc.SetRestrictedPermissions(PermF_All & ~(.. | Permit_FormFilling));
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1371
Joined: Thu Sep 05, 2019 12:35 pm

Re: What permission is required for op.document.importCommentsAndFields  SOLVED

Post by zarkogajic »

Hi Vasyl,

Thanks, all clear now (especially with [3]) !

I was kind of figuring out something like this is happening under the hood - now confirmed.

-žarko
Post Reply