You can't do that directly with iText.  You can still do it, but it requires some extra effort, both from you and the computer.
 
1) Use a PdfStamper, set to append.  Use a BAOS, as in your code below.
2) Make whatever changes want and save the modified file to the BAOS.
3) Write all the additional bytes from the BAOS to the original file.  You'll need to know how long the original file was and skip over that many bytes in the BAOS.
 
iText will still go through the extra effort of copying the original file and appending the changes to the BAOS, and then you have to turn around and copy those changes again.
 
I don't see a way to trick iText into using the same stream for both a PdfReader and a PdfWriter... and in any case, it would still overwrite itself.
 
On the other hand, iText /is/ open source.  You can go in and add whatever abilities you want.
 
 

--Mark Storer
  Senior Software Engineer
  Cardiff.com

#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of nguyet minh
Sent: Monday, September 25, 2006 8:20 PM
To: [email protected]
Subject: [iText-questions] Append pdf files

Hello,
I've found one way to concat pdf files using PDFCopyFields. Ex, if I append file1 and file2, the file result is another file3. But I want the file2.pdf will be appended to file1.pdf, not file3.pdf. Do you have any suggestion?
Here's the code

public class PdfForm extends PdfReader {
public void appendPdfDocument (PdfForm pdf){
        try{
            ByteArrayOutputStream baos    =  new ByteArrayOutputStream();       
            PdfCopyFields copy = new PdfCopyFields(baos);
            copy.addDocument(this);
            copy.addDocument(pdf);
            copy.close();
            PdfForm f = new PdfForm(baos.toByteArray());               
//            FileOutputStream f = new FileOutputStream("D:\\PDF");
//            f.write(baos.toByteArray());
        }
        catch(Exception e){     }           
    }
}

And one more thing, Is there any difference between AcroFields.Item and PRAcroForm.FieldInformatin
Thank in advance.


Nguyet Minh

Chung ta song tren doi nay khong phai de tim thay mot nguoi hoan hao de yeu,ma la de hoc cach yeu nguoi khong hoan hao mot cach tron ven.


All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to