import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class RemoteGotoPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writerA = PdfWriter.getInstance(document, new FileOutputStream("DocumentA.pdf"));
PdfWriter writerB = PdfWriter.getInstance(document, new FileOutputStream("DocumentB.pdf"));
document.open();
Paragraph pa = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document B").setRemoteGoto("DocumentB.pdf", "test"));
Paragraph pb = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document A").setRemoteGoto("DocumentA.pdf", "test"));
// a special remote goto
Paragraph pc = new Paragraph("you can also jump to a ");
pc.add(new Chunk("specific page on another document", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC)).setRemoteGoto("DocumentB.pdf", 1));
document.add(pa);
document.add(pb);
document.add(pc);
document.add(pa);
document.add(pb);
document.add(pc);
document.add(pa);
document.add(pb);
document.add(pc);
}
catch(Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}
itext.zip( 1,748 k)