Hi,

I have the following code but am erroring out with an ArrayIndexOutOfBounds 
exception. what am I doing wrong.

@param: pdfPath: path to a file
          pageNumbers: Vector of page numbers.
public static void removePages (String pdfPath, Vector pageNumbers) throws 
Exception{
                                
                PdfReader reader = new PdfReader(inpFile);              
                int n = reader.getNumberOfPages();
        
                Document document = null;
                PdfCopy writer = null;
                boolean first = true;
                String fileName = pdfPath;
                
                for(int j = 1; j <= n;){                                
                        PdfDictionary page1;                    
                        page1 = reader.getPageN(j);                             
        
                        PdfDictionary annot = null;
                        
                        for ( int i = 0; i < pageNumbers.size(); i++){  
                                Integer pageNum 
=(Integer)pageNumbers.elementAt(i);
                                int checkPg = pageNum.intValue();
                                                
                                if (j == checkPg){                              
                                        j++;
                                        continue;                               
        
                                }                                               
                
                        }       
                        
                        if(first){
                                document = new 
Document(reader.getPageSizeWithRotation(1));
                                writer = new PdfCopy(document, new 
FileOutputStream(fileName));
                                document.open();
                                first = false;
                        }                               
                                
                        PdfImportedPage page;
                        int z = j;
                        page = writer.getImportedPage(reader, z);
                        writer.addPage(page);   
                        
                        PRAcroForm form = reader.getAcroForm();
        
                        if (form != null) {
                                writer.copyAcroForm(reader);
                        }                       
                        j++;
                }               
                document.close();       
        }

purpose of the method is that, the Vector object contains some page numbers. I 
need to remove those pages from the input file . The output file is stored in 
the same location as the input file and with the same name. Can you give me 
some suggestions as to how I an do that?

Thank You
Kalkunda Venkat
515 362 0241
x-20241



-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 05, 2005 5:43 PM
To: Kalkunda, Venkat; [EMAIL PROTECTED]
Subject: Re: [iText-questions] quesion on XfdfReader


Wait for the next release or read first the file to a byte array.

----- Original Message ----- 
From: "Kalkunda, Venkat" <[EMAIL PROTECTED]>
To: "Paulo Soares" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, January 05, 2005 11:38 PM
Subject: RE: [iText-questions] quesion on XfdfReader


So how do I get around it, I don't want to keep it in my hard disk, which
will become a big liability in a matter of very short time.

Thank You
Kalkunda Venkat
515 362 0241
x-20241



-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 05, 2005 5:03 PM
To: Kalkunda, Venkat; [EMAIL PROTECTED]
Subject: Re: [iText-questions] quesion on XfdfReader


It's a bug, the file is never closed in XfdfReader.

----- Original Message ----- 
From: "Kalkunda, Venkat" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 05, 2005 8:34 PM
Subject: [iText-questions] quesion on XfdfReader


Hi,

I have the following code in one of my programs

AcroFields form = stamper.getAcroFields();
XfdfReader xfdf = new XfdfReader(xFDFString);
form.setFields(xfdf);

Do I need to close this reader(like closing a document or something) or
should I be closing the Acrofields object?

I am haveing problems with deleting a file which is being created using the
same string(xFDFString), It keeps saying that this file is being used by
another source. I was thinking if this the XfdfReader or AcroFields object
is still holding on to the string?

Any suggestions or help?

Thanks a lot in advance.


Thank You
Kalkunda Venkat
515 362 0241
x-20241




-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to [EMAIL PROTECTED] and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions



-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to [EMAIL PROTECTED] and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.



-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to [EMAIL PROTECTED] and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to