This question was kind of previously posted, but I'm getting the same 
error, even though I AM supplying the password byte[] to the reader when I 
do this:
I found this code somewhere and was using it as starting point to split an 
original password protected file, up into separate pages(they also need to 
be password protected with same password)


   private void split(String filePath) throws Exception {
 
      Document.plainRandomAccess = true; // try to avoid possible JVM 
crashes
      String password = "password";
      byte[] passwordBytes = password.getBytes();
      PdfReader reader = new PdfReader(filePath, passwordBytes);



Then later on in the code I do this, and it fails on the last line (
PdfReader not opened with owner password):



          Document document = new 
Document(reader.getPageSizeWithRotation(pageNo));
          File newFile = new File(fileName.append("_"
).append(pageCnt).append(".pdf").toString());
          PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream(newFile));
 
          document.open();
          PdfContentByte cb = writer.getDirectContent();
          PdfImportedPage page = writer.getImportedPage(reader, pageNo);  
<--- Fails on this line




Do I need to attach or send the passwordBytes byte[] into the document 
somehow, or the PdfWriter? 
What am I doing wrong, since I have obviously complied by sending in the 
user password with the "reader" . 


Can someone please help guide me what/where I need to set this password, 
to be able to split a password protected PDF into multiple single PDF's 
protected with the same password.

Thanks so much for your time.




Shwetank Singh wrote:
> I am unable to open the 
> file using a PdfReader..It says
> ?*PdfReader not opened with owner password*?

Provide the owner password that was used to create the PDF file.
This is in the FAQ: http://1t3xt.be/?X000402
br,
Bruno
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to