This is the easy part, the difficult one is inside PdfStamperImp and other 
classes to allow or not this or that action. There's a lot of work to do in 
many places.

Paulo

----- Original Message ----- 
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, August 19, 2009 7:40 PM
Subject: Re: [iText-questions] possible bug in PdfReader for encrypted pfds


1- PdfReader::PdfReader(....., int [] purpose) throw UserPermissionException
   In this new constructor the user will pass the permissions he/she want to 
perform.  PDF Reader will verify if the document has respective permission 
as it is doing now in "isOpenedWithFullPermissions".

2- PdfReader::isOpenWithUserPermissions( )
   This new method will assist  PdfStamperImp to verify the permissions 
during construction.

3- PdfReader::int [] permissionAsked // variable to cache permissions that 
user asked.

4: PdfStamperImp::PdfStamperImp
      if (  !reader.isOpenedWithFullPermissions()  )
             if (! isOpenWithUserPermissions()
                        throw new BadPasswordException("PdfReader not opened 
with owner password or user permissions")

this int array can be replace with single int where user can pass value 
after AND or OR operation.

After theses change the client code may be look like this.

try
{
      PdfReader reader = new PdfReader(filename);
     int[] purpose ={PdfReader.PRINTING, PdfReader.FILLING_FORM}

     stamp = new PdfStamper(pdfReader, output, '\0', false, purpose )
...........
}
catch(UserPermissionException e)
{
}


------------------------------------------------------------------------------
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
[email protected]
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