I used iText recently; pretty simple.
package org.ahss.acc.pdftools;
import java.io.*;
import com.lowagie.text.*;
import java.awt.Color;
import com.lowagie.text.pdf.*;
import java.util.*;
public class PdfFileManipulator {
public PdfFileManipulator() { }
public static void cat(ArrayList inFiles, String outFile)
throws IOException, FileNotFoundException,
DocumentException, BadPdfFormatException{
int pageOffset = 0;
ArrayList master = new ArrayList();
System.out.println("writeing to "+outFile);
Document document = null;
PdfCopy writer = null;
for (Iterator I = inFiles.iterator(); I.hasNext(); ) {
AdmissionDocument admdoc = (AdmissionDocument)I.next();
PdfReader reader = new PdfReader(admdoc.File);//create reader for
document
reader.consolidateNamedDestinations();
int n = reader.getNumberOfPages();//retrieve total number of pages
java.util.List bookmarks = SimpleBookmark.getBookmark(reader);
master.add(createBookMark(admdoc.Title, pageOffset+1));
if (bookmarks != null) {
if (pageOffset != 0) SimpleBookmark.shiftPageNumbers(bookmarks,
pageOffset, null);
master.addAll(bookmarks);
}
pageOffset += n;
System.out.println("There are " + n + " pages in " + admdoc.File);
if (document==null) {
document = new Document(reader.getPageSizeWithRotation(1));
writer = new PdfCopy(document, new FileOutputStream(outFile));
document.open();
}
for (int i = 1; i <= n; i++ ) {// step 4: we add content
PdfImportedPage page = writer.getImportedPage(reader, i);
writer.addPage(page);
}
}
if (master.size() > 0) writer.setOutlines(master);//bookmarks
document.close();// step 5: we close the document
writer.close();
}
private static HashMap createBookMark(String title, int page) {
HashMap bookmark = new HashMap();
bookmark.put("Action", "GoTo");
bookmark.put("Title", title);
bookmark.put("Page", ""+page+" XYZ 0 1000 null");
return bookmark;
}
}//============================= end of class
================================
-----Original Message-----
From: Glen Mazza [mailto:[EMAIL PROTECTED]
Sent: Monday, August 02, 2004 7:36 AM
To: [EMAIL PROTECTED]
Subject: Re: Attaching PDF to FOP output
Importance: Low
Apparently a product called "PJ" and also iText are
able to post-process a FOP-made (or any other) PDF
document. I suspect they will be able to append
another PDF, but haven't used these products yet so I
don't know for sure. See here:
http://marc.theaimsgroup.com/?l=fop-user&m=108131949107145&w=2
Glen
--- S?nke_Ruempler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Maybe a little bit offtopic:
>
> Is it possible to attach a PDF file to a FOP output?
>
> --
>
> S?nke
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]