Hello
I have a requirement to read text from PDF so we have used getpdftext but if the user uploads password protected PDF file , the function getpdftext is throwing the below error-
Expression evaluation error at function 'getpdftext': Cannot decrypt PDF, the password is incorrect
If the file is password protected, I need to by pass the flow which is going to getpdftext, So Before only I need to check if the file is password protected or NOT. Can any one please suggest how to achieve this.
Discussion posts and replies are publicly visible
There is another plugin you could use - Document Page Counter and its "getnumberofpages" function.While it doesn't actually tell you a pdf is password-protected, it will return a value of 0 for the page count, and, more importantly, won't throw an error.
Mike's very subtle suggestion would give a more positive answer, but this plugin would at least avoid any unsupported concerns...
darrenr1624 said:While it doesn't actually tell you a pdf is password-protected, it will return a value of 0 for the page count
hm, that makes me wonder whether we could make use of functions like "getPdfFields" in a similar way - for instance I assume it would return something unusable (hopefully not a hard-stop error) when the PDF it's fed is protected. I don't know if I have a protected PDF on-hand to try with, though.
Thanks, Mike, for your message. Unfortunately, none of the PDFTool functions work with encrypted files. We already tried earlier using functions like “getPdfFields” and “getPdfMetaData”, but they returned an error stating, “cannot decrypt PDF, password is incorrect”.
manojtumulu said:but they returned an error stating, “cannot decrypt PDF, password is incorrect”
Is that a halting error message? Because if it isn't, you could always just try it and return "true" if that's your result. Assuming your original request for "telling if the PDF is protected" is still relevant.
This is the same error that originally interrupted the process execution and caused the process instance to fail.PDFTool functions do not support encrypted PDF files.
well if it's critical, and you're ok using "unlisted" functions, maybe just build yourself a "checker rule" using the try() function. it will mainly just let you check for an error state but non-haltingly.