Hi, am quite new to iText and Java environment and would like some
assistant on some issues I am having.

I have been running iText against a PDF templates(static pdf's with
fields inside) that has acrofields in it and it works well.
I tried dynamic pdf's but our fax server(rightfax) which sends out
these documents cannot flatten the pdf when it receives it so it
looses all the data,hence why we use static pdf.

Based on this I have now had to expand it where I may need to
concatenate these templates into one pdf and then populate it with
data. I at any given point in time may not know how many pdf's need to
be concatenated. This I can do and appears to work well until the
finished pdf with data in it is viewed.
Let me just say that there can be,and will be the same field name
across multiple pdf's that are concatenated.
So once the pdf's are concatenated and filled one finds that some of
the fields which are duplicated across all pdf pages lack data,but the
last field in the pdf always has the data. Strange thing is that this
does not occur with all duplicated fields.
If I look at the concatenated pdf,before data is applied I have found
that the field is "sort of" missing. Its there but the black border
around is missing when putting it into edit mode. The field that has
the data and displays correctly has the black border around it.

The pdf templates I am working with are save on version 1.6 Acrobat 7
and utilise the fonts from the system and not embedded. All fields are
set to read only.

The code I use to concatenate comes from "roseindia.net" site which
has been altered for our
needs.(http://www.roseindia.net/java/itext/ConcatenateMoreThanTwoPdfFiles.shtml)
All our code runs within a IBM Lotus Domino environment. The original
code used the older jar files of itext and I am using the latest.


Concatenation code:
'****************
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PRAcroForm;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfImportedPage;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.SimpleBookmark;

public class Concatenate {

        private static String[] args;
        List list = new ArrayList();

        public static void concat() throws Exception {

                int maxVal = args.length + 4;
                ProgressBar pb = new ProgressBar("Merging the Contract...  ", 
maxVal,
                                false);

                pb.setBarText(1 % 3);
                pb.updateValue(1);

                if (args.length < 2) {
                        System.err.println("arguments: file1 [file2 ...] 
destfile");
                } else {

                        System.out.println("PdfCopy example");
                        System.out.println("args = " + args.length);
                        for (int x = 0; x < args.length; x++) {
                                System.out.println(" args " + x + " = " + 
args[x]);

                        }

                        pb.setBarText(2 % 3);
                        pb.updateValue(2);

                        int pageOffset = 0;
                        ArrayList master = new ArrayList();
                        int f = 0;
                        String outFile = args[args.length - 1];
                        System.out.println("outFile :" + outFile);
                        Document document = null;
                        PdfCopy writer = null;

                        pb.setBarText(3 % 3);
                        pb.updateValue(3);

                        while (f < args.length - 1) {

                                pb.setBarText(f + 1 % 3);
                                pb.updateValue(f + 1);

                                PdfReader reader = new PdfReader(args[f]);
                                reader.consolidateNamedDestinations();
                                int n = reader.getNumberOfPages();
                                List bookmarks = 
SimpleBookmark.getBookmark(reader);
                                if (bookmarks != null) {
                                        if (pageOffset != 0)
                                                
SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset,
                                                                null);
                                        master.addAll(bookmarks);
                                }
                                pageOffset += n;
                                if (f == 0) {
                                        document = new 
Document(reader.getPageSizeWithRotation(1));
                                        writer = new PdfCopy(document,
                                                        new 
FileOutputStream(outFile));
                                        document.open();
                                }
                                PdfImportedPage page;
                                for (int i = 0; i < n;) {
                                        ++i;
                                        page = writer.getImportedPage(reader, 
i);
                                        writer.addPage(page);
                                }
                                PRAcroForm form = reader.getAcroForm();
                                if (form != null)
                                        writer.copyAcroForm(reader);
                                f++;

                        } // End while

                        pb.setBarText(f + 1 % 3);
                        pb.updateValue(f + 1);

                        if (!master.isEmpty())
                                writer.setOutlines(master);

                        document.close();
                        pb.dispose();
                }
        }

        
}
'****************

Any suggestions and help would be very much appreciated. We are trying
keep our code contained in our development enviroment and not use
external api's to generate pdf's and iText seems the best way to do
this for us.

thank you

Bevan Killian

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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