Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 15DC011C35 for ; Mon, 5 May 2014 03:36:30 +0000 (UTC) Received: (qmail 57835 invoked by uid 500); 5 May 2014 03:36:29 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 57398 invoked by uid 500); 5 May 2014 03:36:28 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 57389 invoked by uid 99); 5 May 2014 03:36:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2014 03:36:27 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of Paul.Cheffers@humanservices.gov.au designates 203.13.3.85 as permitted sender) Received: from [203.13.3.85] (HELO mailout1.humanservices.gov.au) (203.13.3.85) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2014 03:36:21 +0000 X-AuditID: cb0d0355-b7f766d000005006-f1-5367071a9890 Received: from mailout1.humanservices.gov.au (Unknown_Domain [10.240.37.59]) (using TLS with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by mailout1.humanservices.gov.au (Symantec Messaging Gateway) with SMTP id CE.86.20486.A1707635; Mon, 5 May 2014 13:35:54 +1000 (EST) Received: from DCVSEX9.Internal.Dept.local (10.240.37.34) by DCVSEX25.humanservices.gov.au (10.240.37.59) with Microsoft SMTP Server (TLS) id 14.3.158.1; Mon, 5 May 2014 13:36:33 +1000 Received: from DCVSXM17.Internal.Dept.local ([fe80::9d6c:458d:9db4:4a3a]) by DCVSEX9.Internal.Dept.local ([fe80::9c9b:db8e:191e:c520%10]) with mapi id 14.03.0158.001; Mon, 5 May 2014 13:36:33 +1000 From: "Cheffers, Paul" To: "users@pdfbox.apache.org" Subject: unable to apply permissions to a pdf without permissions [SEC=UNOFFICIAL] Thread-Topic: unable to apply permissions to a pdf without permissions [SEC=UNOFFICIAL] Thread-Index: Ac9oEzUHZmuQltuIRFisTAyO/xHhJQ== Date: Mon, 5 May 2014 03:36:32 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-protective-marking: VER=2012.2, NS=gov.au, SEC=UNOFFICIAL, ORIGIN=Paul.Cheffers@humanservices.gov.au x-originating-ip: [10.230.230.103] Content-Type: multipart/alternative; boundary="_000_AD522F6098DF6D41874355768F1E97AF0F28E580DCVSXM17Interna_" MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAKsWRmVeSWpSXmKPExsVympc5VFeKPT3YoLlH1eL29pesDowekz/d Zg9gjGpgtEnMy8svSSxJVUhJLU62VXLxCFZwySxOzknMzE0tUlLITLFVMlJSKMhJTE7NTc0r sVVKLChIzUtRsuNSwAA2QGWZeQqpecn5KZl56bZKnsH+uhYWppa6hkp2WlhBwjb2jN9Pl7IX zPzGWNHSc4WtgXH6Y8YuRk4OCQETiZ1LDkLZYhIX7q1n62Lk4hAS2MQksfD3FiaQhJDAHkaJ V73OEImTjBLvTywCSnBwsAlYS/R+cgOpEREwl9i/6xEziC0sECJx5dIeVpASEYFIiY9L+SBK 9CTutL4EG8kioCLx/uMtVhCbVyBYYuG8Y+wgNqOArMTvC7fBxjALiEvcejKfCeI2AYkle84z Q9iiEi8f/wMbLyGQIbHgnBlEWEli09pfjBCt+RK35qxhhhgvKHFy5hMWiE/0JVafecc8gVF0 FpINs5C0zELSAhHXkViw+xMbhK0tsWzha2YY+8yBx0zI4gsY2VcxyuYmZubkl5YY6mWU5ibm FacWlWUmpxbrpeeX6SWWbmKEppYdjH8mGB5iFOBgVOLhTWBODxZiTSwrrsw9xCjBwawkwjuL ESjEm5JYWZValB9fVJqTWnyI0RQYcBOZpUST84FpL68k3tDYyMDIwsTS1MLQ3EBJnFe7LyFY SCAdmNKyU1MLUotg+pg4OKUaGJfvNmXQT2yPfyKU78/xJWf5mZ3LFr3cdehewOmYVHfdoMWb 3p5+Wii1JbUn60lP8MbX69Llqzfs+PjjvBbfcb91BSumC4ooHXiqt4apW/d599UHU5xOTVdo n7auMOjTy98vvlgqnJH5EVRbc0Hz2fbzW+0rDPw+PFWKZjkzzSzi0IJPWZd25dxQYinOSDTU Yi4qTgQA1TR3WUMDAAA= X-Virus-Checked: Checked by ClamAV on apache.org --_000_AD522F6098DF6D41874355768F1E97AF0F28E580DCVSXM17Interna_ Content-Type: text/plain; charset="us-ascii" content-transfer-encoding: quoted-printable I'm unable to apply permissions to a pdf that has no security. The code I am using is in other posts (see below). I get an exception while= using the protect member try { document.protect(spp); } catch (BadSecurityHandlerException e) { e.printStackTrace(); I call the below routine with these arguments: creatingEncriptation("d:\\Data\\pdfstuff\\bitcoin.pdf", "d:\\Data\\pdfstuff\= \bitcoin2.pdf", "dogs"); private static void creatingEncriptation(String Infile, String Outfile, String ownerPassword) { AccessPermission ap =3D new AccessPermission(); String userPassword =3D ""; // ownerPassword =3D "XXXXXX"; int keyLength =3D 40; PDDocument document =3D null; ap.setCanAssembleDocument(true); ap.setCanExtractContent(true); ap.setCanExtractForAccessibility(true); ap.setCanFillInForm(true); ap.setCanModify(true); ap.setCanModifyAnnotations(true); ap.setCanPrint(true); ap.setCanPrintDegraded(true); if (Outfile =3D=3D null) { Outfile =3D Infile; } try { document =3D PDDocument.load(Infile); // document.setAllSecurityToBeRemoved(true); } catch (IOException e) { e.printStackTrace(); } if (!document.isEncrypted()) { StandardProtectionPolicy spp =3D new StandardProtectionPolicy( ownerPassword, userPassword, ap); spp.setEncryptionKeyLength(keyLength); try { document.protect(spp); } catch (BadSecurityHandlerException e) { e.printStackTrace(); } try { document.save(Outfile); } catch (COSVisitorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { return; } try { document.close(); document=3Dnull; } catch (IOException e) { e.printStackTrace(); } } Any ideas would be appreciated. Paul ********************************************************************** IMPOR= TANT: This e-mail is for the use of the intended recipient only and may cont= ain information that is confidential, commercially valuable and/or subject t= o legal or parliamentary privilege. If you are not the intended recipient yo= u are notified that any review, re-transmission, disclosure, dissemination o= r other use of, or taking of any action in reliance upon, this information i= s prohibited and may result in severe penalties. If you have received this e= -mail in error please notify the sender immediately and delete all electroni= c and hard copies of this transmission together with any attachments. Please= consider the environment before printing this e-mail **********************= ************************************************ --_000_AD522F6098DF6D41874355768F1E97AF0F28E580DCVSXM17Interna_--