Sorry Paulo - but have you tested setting security permissions, and a security password - but NO user password on a document using PdfEncryptor.encrypt? Does this work for you? I cannot see anything I'm doing wrong in my code?
Regards Mark Hibbard -----Original Message----- From: Hibbard, Mark Sent: 04 November 2003 16:10 To: 'Paulo Soares'; Hibbard, Mark; '[EMAIL PROTECTED]' Subject: RE: [iText-questions] Security on document Definately not seeing a cached version. Attached is the document produced. This was produced from the exact code I sent earlier. -----Original Message----- From: Paulo Soares [mailto:[EMAIL PROTECTED] Sent: 04 November 2003 16:04 To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' Subject: RE: [iText-questions] Security on document The user null means that the doc can be opened but all the security restrictions apply. Aren't you using this with a browser and always seeing a cached version? You code is correct and I would like to see the pdf resulting from it. Best Regards, Paulo Soares > -----Original Message----- > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > Sent: Tuesday, November 04, 2003 15:58 > To: 'Paulo Soares'; Hibbard, Mark; > '[EMAIL PROTECTED]' > Subject: RE: [iText-questions] Security on document > > Ok. But even if I do use PdfEncryptor.encrypt I still don't see it working > correctly, i.e. it only works if i set a user password. > > Maybe I am doing something wrong? But then why would it work when setting > a > user password? > > Below is my code - I basically join two pdf documents (using PdfCopy) into > a > ByteArrayOutputStream, and then open a PdfReader on this OutputStream, > creating a new ByteArrayOutputStream with the encrypted version. > > > log.debug("Getting page size from PdfReader"); > Rectangle psize = pdfReader.getPageSize(1); > > log.debug("Creating new document"); > Document document = new Document(psize); > > log.debug("Creating pdfCopy Object"); > > ByteArrayOutputStream bytes = new ByteArrayOutputStream(); > PdfCopy pdfCopy = new PdfCopy(document, bytes); > > // pdfCopy set Encrytion is NOT supported by iText > // pdfCopy.setEncryption(false,null,"CSFBSecurity", > PdfWriter.AllowPrinting); > > int i = 0; > > // Open the document for writing > document.open(); > > log.debug("Creating each page"); > while (i < numPages) { > document.newPage(); > i++; > log.debug("Getting page no: " + i); > PdfImportedPage page = pdfCopy.getImportedPage(pdfReader, i); > log.debug("Got page"); > pdfCopy.addPage(page); > > log.debug("Processed page " + i); > } > > log.debug("Finished writing out doc to pdf file - now adding > signature > page"); > > PdfReader sigpdfReader = new PdfReader(buffer); > int numSigPages = sigpdfReader.getNumberOfPages(); > log.debug("Number of Signature Pages: " + numSigPages); > i = 0; > while (i < numSigPages) { > document.newPage(); > i++; > PdfImportedPage page = pdfCopy.getImportedPage(sigpdfReader, i); > pdfCopy.addPage(page); > > log.debug("processed signature page " + i); > } > > log.debug("Concatenation complete - closing document"); > > document.close(); > > log.debug("Size of document in ByteArrayStream: " + bytes.size()); > > /* Add security to pdf doc */ > log.debug("Encrypting document"); > PdfReader finalpdfReader = new PdfReader(bytes.toByteArray()); > ByteArrayOutputStream encryptedbytes = new ByteArrayOutputStream(); > > log.debug("Reading whole document complete"); > PdfEncryptor.encrypt(finalpdfReader, encryptedbytes,false,null, > "CSFBSecurity", PdfWriter.AllowPrinting); > log.debug("Encryption complete"); > > > > > > > -----Original Message----- > From: Paulo Soares [mailto:[EMAIL PROTECTED] > Sent: 04 November 2003 14:53 > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > Subject: RE: [iText-questions] Security on document > > > It's not supported. Whatever you get is pure chance, use it on your own > risk. In the next version it will either be supported or will throw an > exception, depending on the time I have. > > Best Regards, > Paulo Soares > > > -----Original Message----- > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > Sent: Tuesday, November 04, 2003 14:26 > > To: 'Paulo Soares'; Hibbard, Mark; > > '[EMAIL PROTECTED]' > > Subject: RE: [iText-questions] Security on document > > > > But once again - Encryption works with PdfCopy if i set a user password. > > If I > > don't set a user password (leave it blank OR null) then it does not > work. > > This > > is surely a bug? > > > > -----Original Message----- > > From: Paulo Soares [mailto:[EMAIL PROTECTED] > > Sent: 04 November 2003 14:16 > > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > > Subject: RE: [iText-questions] Security on document > > > > > > Encryption is not meant to work with PdfCopy, probably should. It only > > works > > with PdfStamper and PdfWriter. > > > > Best Regards, > > Paulo Soares > > > > > -----Original Message----- > > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > > Sent: Tuesday, November 04, 2003 13:51 > > > To: 'Paulo Soares'; Hibbard, Mark; > > > '[EMAIL PROTECTED]' > > > Subject: RE: [iText-questions] Security on document > > > > > > So please explain why when I set the user password - it clearly works > > > (i.e. it > > > is going thru the PdfEncrpytor.encrypt code & sets passwords and > correct > > > permissions). If i don't set a user password then it doesn't apply any > > > encryption. > > > > > > I am using PdfCopy, and have tried setting > > > pdfCopy.setEncryption(false,"","Security", PdfWriter.AllowPrinting) > > > > > > before > > > document.open() > > > > > > And again - this DOES NOT work, but will do if I set a user password. > > > > > > -----Original Message----- > > > From: Paulo Soares [mailto:[EMAIL PROTECTED] > > > Sent: 04 November 2003 12:11 > > > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > I don't know what you are doing over there but the document you sent > has > > > no > > > encryption whatsoever and I'm very sure that it didn't pass through > > > PdfEncryptor.encrypt(). PdfEncryptor works on existing pdfs. If you > are > > > creating a new pdf use PdfWriter.setEncryption() before > Document.open(). > > > > > > Best Regards, > > > Paulo Soares > > > > > > > -----Original Message----- > > > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > > > Sent: Tuesday, November 04, 2003 11:36 > > > > To: 'Paulo Soares'; Hibbard, Mark; > > > > '[EMAIL PROTECTED]' > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > Ahh I'm using acrobat 4 - maybe thats the issue, i'll try and test > on > > 5. > > > > > > > > Document attached was set with allow printing only and a security > > > password > > > > - > > > > but with acrobat 4 i see allow select of text and no security > password > > > > > > > > -----Original Message----- > > > > From: Paulo Soares [mailto:[EMAIL PROTECTED] > > > > Sent: 04 November 2003 11:30 > > > > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > > > > It works for me using the last iText version. In both cases only > > > printing > > > > is > > > > allowed. I tested with Acrobat 5.05. > > > > > > > > Best Regards, > > > > Paulo Soares > > > > > > > > > -----Original Message----- > > > > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > > > > Sent: Tuesday, November 04, 2003 11:15 > > > > > To: 'Paulo Soares'; Hibbard, Mark; > > > > > '[EMAIL PROTECTED]' > > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > > The Encryption settings only appear to work IF a user password is > > set. > > > > > If I don't set a user password, then nothing gets set (i.e. only > > allow > > > > > printing or set a security password) > > > > > > > > > > Sounds like a bug to me? > > > > > > > > > > This works (sets user password, security password, and only allows > > > > > printing) > > > > > PdfEncryptor.encrypt(finalpdfReader, > > > encryptedbytes,false,"user", > > > > > "CSFBSecurity", PdfWriter.AllowPrinting); > > > > > This does NOT work (doesn't set security password and default > > security > > > > > permissions - i.e. allow printing and selecting text) > > > > > PdfEncryptor.encrypt(finalpdfReader, > > encryptedbytes,false,null, > > > > > "CSFBSecurity", PdfWriter.AllowPrinting); > > > > > > > > > > -----Original Message----- > > > > > From: Paulo Soares [mailto:[EMAIL PROTECTED] > > > > > Sent: 03 November 2003 17:25 > > > > > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > > > > > Sent: Monday, November 03, 2003 17:20 > > > > > > To: 'Paulo Soares'; '[EMAIL PROTECTED]' > > > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > > > > I've used the following method from the javadocs: > > > > > > > > > > > > public static void encrypt(PdfReader reader, > > > > > > OutputStream os, > > > > > > boolean strength, > > > > > > String userPassword, > > > > > > String ownerPassword, > > > > > > int permissions) > > > > > > throws DocumentException, > > > > > > IOException > > > > > > > > > > > > What exactly is the ownerPassword? - what does this do? (it > > doesn't > > > > seem > > > > > > to do > > > > > > anything?) > > > > > > > > > > > It allows the changing of the security settings in Acrobat. > > > > > > > > > > > And if I set permissions to be 10000000 i.e. only allow printing > - > > > it > > > > > > still > > > > > > allows Selecting Text and Graphics??? > > > > > > > > > > > You must use the PdfWriter.AllowPrinting constant. > > > > > > > > > > Best Regards, > > > > > Paulo Soares > > > > > > > > > > > -----Original Message----- > > > > > > From: Paulo Soares [mailto:[EMAIL PROTECTED] > > > > > > Sent: 03 November 2003 17:06 > > > > > > To: 'Hibbard, Mark'; '[EMAIL PROTECTED]' > > > > > > Subject: RE: [iText-questions] Security on document > > > > > > > > > > > > > > > > > > Anything wrong with the javadocs? > > > > > > > > > > > > Best Regards, > > > > > > Paulo Soares > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: Hibbard, Mark [SMTP:[EMAIL PROTECTED] > > > > > > > Sent: Monday, November 03, 2003 11:34 > > > > > > > To: '[EMAIL PROTECTED]' > > > > > > > Subject: [iText-questions] Security on document > > > > > > > > > > > > > > I need to be able to set up documents in PDF with the > following > > > > > security > > > > > > > permissions: > > > > > > > > > > > > > > * A password required to change security options > > > > > > > * Do not allow - > > > > > > > Changing the document > > > > > > > Selecting text and graphics > > > > > > > Adding or changing annotations and form fields > > > > > > > > > > > > > > > > > > > > > I've tried using iText in the following way: > > > > > > > PdfEncryptor.encrypt(finalpdfReader, > encryptedBbytes,false,null, > > > > > > "owner", > > > > > > > 1000000); > > > > > > > > > > > > > > but this doesn't achieve what i require. It doesn't set a > > security > > > > > > > password, > > > > > > > and doesn't prevent selecting text and graphics. > > > > > > > > > > > > > > Can anyone help or advise how I can do this? > > > > > > > > > > > > > > Cheers > > > > > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ========================================================================== > > > > > > > ==== > > > > > > > This message is for the named person's use only. It may > contain > > > > > > sensitive > > > > > > > and > > > > > > > private proprietary or legally privileged information. No > > > > > > confidentiality > > > > > > > or > > > > > > > privilege is waived or lost by any mistransmission. If you are > > not > > > > the > > > > > > > intended recipient, please immediately delete it and all > copies > > of > > > > it > > > > > > from > > > > > > > your system, destroy any hard copies of it and notify the > > sender. > > > > You > > > > > > must > > > > > > > not, directly or indirectly, use, disclose, distribute, print, > > or > > > > copy > > > > > > any > > > > > > > part of this message if you are not the intended recipient. > > CREDIT > > > > > > SUISSE > > > > > > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON > or > > > > > CREDIT > > > > > > > SUISSE > > > > > > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON > > > > reserve > > > > > > the > > > > > > > right to monitor all e-mail communications through its > networks. > > > Any > > > > > > views > > > > > > > expressed in this message are those of the individual sender, > > > except > > > > > > where > > > > > > > the > > > > > > > message states otherwise and the sender is authorized to state > > > them > > > > to > > > > > > be > > > > > > > the > > > > > > > views of any such entity. > > > > > > > Unless otherwise stated, any pricing information given in this > > > > message > > > > > > is > > > > > > > indicative only, is subject to change and does not constitute > > an > > > > > offer > > > > > > to > > > > > > > deal at any price quoted. Any reference to the terms of > executed > > > > > > > transactions > > > > > > > should be treated as preliminary only and subject to our > formal > > > > > written > > > > > > > confirmation. > > > > > > > > > > > > > > > > > > > > > > > > > > > > ========================================================================== > > > > > > > ==== > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > > This SF.net email is sponsored by: SF.net Giveback Program. > > > > > > > Does SourceForge.net help you be more productive? Does it > > > > > > > help you create better code? SHARE THE LOVE, and help us > help > > > > > > > YOU! Click Here: http://sourceforge.net/donate/ > > > > > > > _______________________________________________ > > > > > > > iText-questions mailing list > > > > > > > [EMAIL PROTECTED] > > > > > > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > ========================================================================== > > > > > > ==== > > > > > > This message is for the named person's use only. It may contain > > > > > sensitive > > > > > > and > > > > > > private proprietary or legally privileged information. No > > > > > confidentiality > > > > > > or > > > > > > privilege is waived or lost by any mistransmission. If you are > not > > > the > > > > > > intended recipient, please immediately delete it and all copies > of > > > it > > > > > from > > > > > > your system, destroy any hard copies of it and notify the > sender. > > > You > > > > > must > > > > > > not, directly or indirectly, use, disclose, distribute, print, > or > > > copy > > > > > any > > > > > > part of this message if you are not the intended recipient. > CREDIT > > > > > SUISSE > > > > > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or > > > > CREDIT > > > > > > SUISSE > > > > > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON > > > reserve > > > > > the > > > > > > right to monitor all e-mail communications through its networks. > > Any > > > > > views > > > > > > expressed in this message are those of the individual sender, > > except > > > > > where > > > > > > the > > > > > > message states otherwise and the sender is authorized to state > > them > > > to > > > > > be > > > > > > the > > > > > > views of any such entity. > > > > > > Unless otherwise stated, any pricing information given in this > > > message > > > > > is > > > > > > indicative only, is subject to change and does not constitute > an > > > > offer > > > > > to > > > > > > deal at any price quoted. Any reference to the terms of executed > > > > > > transactions > > > > > > should be treated as preliminary only and subject to our formal > > > > written > > > > > > confirmation. > > > > > > > > > > > > > > > > > > > > > ========================================================================== > > > > > > ==== > > > > > > > > > > > > > > > > > > > > ========================================================================== > > > > > ==== > > > > > This message is for the named person's use only. It may contain > > > > sensitive > > > > > and > > > > > private proprietary or legally privileged information. No > > > > confidentiality > > > > > or > > > > > privilege is waived or lost by any mistransmission. If you are not > > the > > > > > intended recipient, please immediately delete it and all copies of > > it > > > > from > > > > > your system, destroy any hard copies of it and notify the sender. > > You > > > > must > > > > > not, directly or indirectly, use, disclose, distribute, print, or > > copy > > > > any > > > > > part of this message if you are not the intended recipient. CREDIT > > > > SUISSE > > > > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or > > > CREDIT > > > > > SUISSE > > > > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON > > reserve > > > > the > > > > > right to monitor all e-mail communications through its networks. > Any > > > > views > > > > > expressed in this message are those of the individual sender, > except > > > > where > > > > > the > > > > > message states otherwise and the sender is authorized to state > them > > to > > > > be > > > > > the > > > > > views of any such entity. > > > > > Unless otherwise stated, any pricing information given in this > > message > > > > is > > > > > indicative only, is subject to change and does not constitute an > > > offer > > > > to > > > > > deal at any price quoted. Any reference to the terms of executed > > > > > transactions > > > > > should be treated as preliminary only and subject to our formal > > > written > > > > > confirmation. > > > > > > > > > > > > > > > ========================================================================== > > > > > ==== > > > > > > > > > > > > > > > > > > ========================================================================== > > > > ==== > > > > This message is for the named person's use only. It may contain > > > sensitive > > > > and > > > > private proprietary or legally privileged information. No > > > confidentiality > > > > or > > > > privilege is waived or lost by any mistransmission. If you are not > the > > > > intended recipient, please immediately delete it and all copies of > it > > > from > > > > your system, destroy any hard copies of it and notify the sender. > You > > > must > > > > not, directly or indirectly, use, disclose, distribute, print, or > copy > > > any > > > > part of this message if you are not the intended recipient. CREDIT > > > SUISSE > > > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or > > CREDIT > > > > SUISSE > > > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON > reserve > > > the > > > > right to monitor all e-mail communications through its networks. Any > > > views > > > > expressed in this message are those of the individual sender, except > > > where > > > > the > > > > message states otherwise and the sender is authorized to state them > to > > > be > > > > the > > > > views of any such entity. > > > > Unless otherwise stated, any pricing information given in this > message > > > is > > > > indicative only, is subject to change and does not constitute an > > offer > > > to > > > > deal at any price quoted. Any reference to the terms of executed > > > > transactions > > > > should be treated as preliminary only and subject to our formal > > written > > > > confirmation. > > > > > > > > > > ========================================================================== > > > > ==== << File: test.pdf >> > > > > > > > > > ========================================================================== > > > ==== > > > This message is for the named person's use only. It may contain > > sensitive > > > and > > > private proprietary or legally privileged information. No > > confidentiality > > > or > > > privilege is waived or lost by any mistransmission. If you are not the > > > intended recipient, please immediately delete it and all copies of it > > from > > > your system, destroy any hard copies of it and notify the sender. You > > must > > > not, directly or indirectly, use, disclose, distribute, print, or copy > > any > > > part of this message if you are not the intended recipient. CREDIT > > SUISSE > > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or > CREDIT > > > SUISSE > > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve > > the > > > right to monitor all e-mail communications through its networks. Any > > views > > > expressed in this message are those of the individual sender, except > > where > > > the > > > message states otherwise and the sender is authorized to state them to > > be > > > the > > > views of any such entity. > > > Unless otherwise stated, any pricing information given in this message > > is > > > indicative only, is subject to change and does not constitute an > offer > > to > > > deal at any price quoted. Any reference to the terms of executed > > > transactions > > > should be treated as preliminary only and subject to our formal > written > > > confirmation. > > > > > > ========================================================================== > > > ==== > > > > > ========================================================================== > > ==== > > This message is for the named person's use only. It may contain > sensitive > > and > > private proprietary or legally privileged information. No > confidentiality > > or > > privilege is waived or lost by any mistransmission. If you are not the > > intended recipient, please immediately delete it and all copies of it > from > > your system, destroy any hard copies of it and notify the sender. You > must > > not, directly or indirectly, use, disclose, distribute, print, or copy > any > > part of this message if you are not the intended recipient. CREDIT > SUISSE > > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT > > SUISSE > > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve > the > > right to monitor all e-mail communications through its networks. Any > views > > expressed in this message are those of the individual sender, except > where > > the > > message states otherwise and the sender is authorized to state them to > be > > the > > views of any such entity. > > Unless otherwise stated, any pricing information given in this message > is > > indicative only, is subject to change and does not constitute an offer > to > > deal at any price quoted. Any reference to the terms of executed > > transactions > > should be treated as preliminary only and subject to our formal written > > confirmation. > > > ========================================================================== > > ==== > > ========================================================================== > ==== > This message is for the named person's use only. It may contain sensitive > and > private proprietary or legally privileged information. No confidentiality > or > privilege is waived or lost by any mistransmission. If you are not the > intended recipient, please immediately delete it and all copies of it from > your system, destroy any hard copies of it and notify the sender. You must > not, directly or indirectly, use, disclose, distribute, print, or copy any > part of this message if you are not the intended recipient. CREDIT SUISSE > GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT > SUISSE > ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the > right to monitor all e-mail communications through its networks. Any views > expressed in this message are those of the individual sender, except where > the > message states otherwise and the sender is authorized to state them to be > the > views of any such entity. > Unless otherwise stated, any pricing information given in this message is > indicative only, is subject to change and does not constitute an offer to > deal at any price quoted. Any reference to the terms of executed > transactions > should be treated as preliminary only and subject to our formal written > confirmation. > ========================================================================== > ==== ============================================================================== This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. Unless otherwise stated, any pricing information given in this message is indicative only, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as preliminary only and subject to our formal written confirmation. ============================================================================== ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
