Hi Support,
I have 2 documents both secured using "Adobe.PubSec". One secured on my machine ("A"), another on another machine ("B").
When opening B in EU Editor the following is displayed: "a digital id was used to encrypt..."
When opening A document - it gets open.
This is all as expected.
Now, I'm trying to have the same error displayed when opening B from code.
Here's what I have: I'm opening the file in PXV Control by first opening as PXC using op.openDoc then using OpenDocFrom to load in PXV Control.
When opening the document via op.openDoc I'm also providing the IOperation with my implementation of IPXC_DocAuthCallback using "Root[Options][AuthCallback]".
My implementation of AuthDoc method calls AuthorizeWithPassword IF GetSecurityHandlerType returns Standard, in other cases it does nothing. This all works as expected for non-secured or standard-secured documents.
In the case of "Adobe.PubSec" OpenDocFrom will throw "PXCLib: Required value not found" exception (for both A and B) WHEN setting AuthCallback for op.OpenDoc.
IF I do NOT use my AuthCallback in op.openDoc then A will open and be displayed. B will not be opened ("a digital id was used ..." displayed by pxv_control). As expected.
In short: if using AuthCallback with an empty AuthDoc method (and document has non Standard security) - OpenDocFrom throws "Required value not found".
[Q]: Can I change something in my AuthDoc method so I receive the correct exception ("a digital id ...") when OpenDocFrom for such secured docs. Or at least something not to receive "Required value not found".
-žarko
op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs SOLVED
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.
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.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 3556
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs
Here is a code that should help:
Code: Select all
HRESULT AuthDoc(IPXC_Document* pDoc, ULONG nFlags)
{
CComPtr<IPXC_SecurityHandler> pHandler;
pDoc->GetSecurityHandler(VARIANT_FALSE, &pHandler);
PXC_RequestOper oper = Perm_OperOpen;
if ((nFlags & DocOpenFlag_NeedOwnerPerms) != 0)
{
oper = Perm_OperSecure;
}
PXC_PermStatus status = Perm_ReqDenied;
HRESULT hr = pHandler->DoAuthorize(pDoc, Perm_ObjDoc, oper, nFlags, &status);
if (SUCCEDDED(hr) && (status != Perm_ReqGranted))
{
hr = HRESULT_FROM_WIN32(ERROR_CANCELLED);
}
return hr;
}
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs SOLVED
Hi Ivan,
Thank you for the code - does the trick!
For future readers not using C language: the tricky thing is that the result type of AuthDoc() method is void in C# - so cannot return HResult. I can throw Ole HR exception - and that seems to be fine.
@Ivan: one question though: the nFlags is always 0, never includes DocOpenFlag_NeedOwnerPerms. Never mind if opening Standard secured document using user and/or owner password or certificate secured. The op.openDoc has no way of specifying DocOpenFlag params (if that would set it).
-žarko
Thank you for the code - does the trick!
For future readers not using C language: the tricky thing is that the result type of AuthDoc() method is void in C# - so cannot return HResult. I can throw Ole HR exception - and that seems to be fine.
@Ivan: one question though: the nFlags is always 0, never includes DocOpenFlag_NeedOwnerPerms. Never mind if opening Standard secured document using user and/or owner password or certificate secured. The op.openDoc has no way of specifying DocOpenFlag params (if that would set it).
-žarko
-
- Site Admin
- Posts: 3556
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs
Yes, nFlags in most cases would be 0. Sometimes you can see DocOpenFlag_Preview flag - it is used for example when thumbnails for the recent list are generated (controlled by parameter ForPreview in the options of op.openDoc).@Ivan: one question though: the nFlags is always 0, never includes DocOpenFlag_NeedOwnerPerms. Never mind if opening Standard secured document using user and/or owner password or certificate secured. The op.openDoc has no way of specifying DocOpenFlag params (if that would set it).
DocOpenFlag_NeedOwnerPerms will be included when op.openDoc options have parameter NeedOwnerPerms set to true.
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs
Hi Ivan,
Great, thanks.
-ž
Great, thanks.
-ž
-
- Site Admin
- Posts: 8624
- Joined: Wed Jan 03, 2018 6:52 pm
op.OpenDoc + AuthCallback + OpenDocFrom for certificate "digital id" secured PDFs
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com