Re: Trying to check e_print permission in PDFTron/C# and I get an exception

81 views
Skip to first unread message

Support

unread,
Jan 2, 2013, 4:56:19 PM1/2/13
to pdfne...@googlegroups.com
 
Do you check if the security handler is not NULL.
Also, do you check for doc_open permission?  Your code should be something similar to this 
 
SecurityHandler s = doc.GetSecurityHandler();
if (s!=null && s.GetPermission(SecurityHandler::e_doc_open)) {

    ...   s.GetPermission(SecurityHandler::e_print)

}

else {

    if (doc.InitStdSecurityHandler("my pass "))  {

              if (s.GetPermission(SecurityHandler::e_doc_open))

                  ...  s.GetPermission(SecurityHandler::e_print)

    }

}

 
If this does not help, could you please send a test project along with a test file to support at pdftron. Than you!
 
 

On Thursday, December 27, 2012 4:36:04 AM UTC-8, arbarnhart wrote:

I have read a few posts and I think I understand what I need to do - init the security handler, then query it for the permission. But I get an exception when I try that.
Below is from the immediate window in Visual Studio during debugging. I broke at the point where I have a valid PDFDoc object. I get true returned from InitSecurityHandler. GetSecurityHandler returns an object. GetPermission gets an exception.

?oDoc
{pdftron.PDF.PDFDoc}
oDoc.InitSecurityHandler()
true
? oDoc.GetSecurityHandler()
{pdftron.SDF.SecHdlrFwd}
    [pdftron.SDF.SecHdlrFwd]: {pdftron.SDF.SecHdlrFwd}
? oDoc.GetSecurityHandler().GetPermission( SecurityHandler.Permission.e_print)

pdftron.Common.PDFNetException was unhandled
  Message=Unknown exception.
  Source=PDFNet
  StackTrace:
       at pdftron.SDF.SecHdlrFwd.GetPermission(Permission p)
  InnerException: 

Reply all
Reply to author
Forward
0 new messages