{"id":1525,"date":"2010-08-19T17:33:49","date_gmt":"2010-08-19T12:03:49","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1525"},"modified":"2016-12-19T14:36:42","modified_gmt":"2016-12-19T09:06:42","slug":"handling-password-protected-pdf-with-pdfreader","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/handling-password-protected-pdf-with-pdfreader\/","title":{"rendered":"Handling Password Protected Pdf  with PdfReader"},"content":{"rendered":"<p>In one of our grails project , we had to attach cover to Pdf file . But since some of pdf&#8217;s uploaded were password protected.<\/p>\n<p>To handle this scenario we added bouncyCastle.jar , so our version of   iText was able to handle password protected pdf .<br \/>\nAnd Then to check whether pdf is password protected or not  , we used &#8220;Boolean isOpenedWithFullPermission()&#8221; method.<\/p>\n<pre lang=\"groovy\">\r\nPdfReader pdf = PdfReader(\"filePath\")\r\nBoolean editable = pdf.isOpenedWithFullPermissions()\r\n\r\nif(editable){\r\n\/\/attach Cover\r\n}else {\r\n\/\/skip  cover\r\n}\r\n\r\n\r\n<\/pre>\n<p>As &#8220;isOpenedWithFullPermissions()&#8221; returns a Boolean variable ,<br \/>\nit was easy for us to recognize whether we would be able to edit (i.e attach cover in our case) depending on its output. (i,e true or false)<br \/>\n\u00a0<\/p>\n<p>_________________________________<br \/>\nHitesh Bhatia<br \/>\n<a href=\"mailto:hitesh@intelligrape.com?subject=Feedback On Blog\">Mail<\/a><br \/>\nLinkedIn,<a href=\"http:\/\/www.facebook.com\/home.php?#!\/profile.php?id=100000114437286\" target=\"_blank\">Facebook<\/a>,<a href=\"http:\/\/twitter.com\/d1_ricky\" target=\"_blank\">Twitter<\/a><br \/>\n_________________________________<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In one of our grails project , we had to attach cover to Pdf file . But since some of pdf&#8217;s uploaded were password protected. To handle this scenario we added bouncyCastle.jar , so our version of iText was able to handle password protected pdf . And Then to check whether pdf is password protected [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[370,4840,9,367,371,369,368,292],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1525"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1525"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1525\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}