It still works for me. Are you sure that you are sending me the content of
encryptedbytes?
Does the the program com.lowagie.tools.encrypt_pdf.java work for you?

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Hibbard, Mark [SMTP:[EMAIL PROTECTED]
> Sent: Tuesday, November 04, 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");
> > 
> > 
> 


-------------------------------------------------------
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

Reply via email to