Hi

I have a problem when I try to bundle several (almost similar) pdffiles into 1 pdffile! The problem is that each pdffile has an integrated font, that when bundeling is interpret as a new font instead of one of the already read. So if I bundel 100 pdffiles, then I get one pdffile with 100 fonts (that could be the same)

I would like to list all of the fonts that I get when reading the pdffiles and then map the ones that are the same to a new font that then is being used in the bundled pdffile!

Is thist possible?

Here is the code that I use!

********************************
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;

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


public class c2 {


   public static void main(String args[]) {
       if (args.length < 2) {
           System.err.println("arguments: file1 [file2 ...] destfile");
       }
       else {
        System.out.println("PdfCopy example");
           try {
               int pageOffset = 0;
               ArrayList master = new ArrayList();
               int f = 0;
               String outFile = args[args.length-1];
               Document document = null;
               PdfCopy  writer = null;
               while (f < args.length-1) {
                   // we create a reader for a certain document
                   PdfReader reader = new PdfReader(args[f]);
                   reader.consolidateNamedDestinations();
                   // we retrieve the total number of pages
                   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) {
                       // step 1: creation of a document-object
document = new Document(reader.getPageSizeWithRotation(1)); // step 2: we create a writer that listens to the document writer = new PdfCopy(document, new FileOutputStream(outFile));
                       // step 3: we open the document
                       document.open();
                   }
                   // step 4: we add content
                   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++;
               }
               if (!master.isEmpty())
                   writer.setOutlines(master);
               // step 5: we close the document
               document.close();
           }
           catch(Exception e) {
               e.printStackTrace();
           }
       }
   }
}
*************************

_________________________________________________________________
Del dine store filer uden problemer på MSN Messenger: http://messenger.msn.dk/


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to