- Where Developers Learn, Share, & Build Careers
Using the iText library, I can merge static PDF files, but not the dynamic ones.
How do I complete this task?
Edit : (Collected from the comments below):
I have not been clearly understood the meaning of dynamic PDF. I'm writing now
Dynamic PDF file is created by Adobe Livechison Designer. I call it " XFA pdf files
".
Rvander's code works very well for static PDFs. But not for XFA PDF files.
They are not readable on merge.
I have used this dynamic PDF files.
pdf -> turbobit.net/9rn2r3quw5gx.html
How do I merge them into a single PDF file Can i do
Updated answers :
Your PDF Files are created using XFA (XML Form Architecture)
. IText has only partial support for XFA but is complete for Acroform
You have to level an XFA form and then use it as per the requirement.
may be more ...
your requirement The XfaMovie
example would be more useful to solve.
Original Answer :
You use the byte []
or InputStream
form In order to create relevant PdfReader
items, combine them to generate one and all of the dynamic PDF files and generate a PDF file.
In the example, I FileInputStream < / Code> example but you can generate the
byteignputstream
example from your dynamic PDF content Temal can.
Example :
Import com.itextpdf.text.pdf.PdfCopyFields; Import com.itextpdf.text.pdf.PdfReader; // import com.lowagie.text.pdf.PdfCopyFields; // import com.lowagie.text.pdf.PdfReader; Public class CombineDynamicPdfContents throws exceptions {// fileNotFound exceptions, IOException, DocumentException public static zero main (string ... A) throws an exception {string fileHome = System.getProperty ("user.home") + "/ desktop /"; System.out.println ("Combine PDF Files" Start); FileInputStream fis1 = new file intestust (filehome + "pdf-file-1.pdf"); FileInputStream fis2 = New FileInputStream (fileHome + "pdf-file-2.pdf"); // Now create pdfreaders using pdf content inputstreams pdfReader file1 = new pdfReader (fis1); PDF Reader File 2 = New PDF Reader (FIS2); FileOutputStream fos = New FileOutputStream (file-specific + "PDF-United PDF"); PDF copyfield copy = new PDF copyfield (Force); Copy.addDocument (file1); Copy.addDocument (file2); Copy.close (); System.out.println ("Completed ..."); } // psvm (..)} // class CombineDynamicPdfContents
Comments
Post a Comment