import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
Document remote = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
PdfWriter.getInstance(remote, new FileOutputStream("remote.pdf"));
document.open();
remote.open();
PdfAction action = PdfAction.gotoLocalPage(2, new PdfDestination(PdfDestination.XYZ, -1, 10000,
0), writer);
writer.setOpenAction(action);
document.add(new Paragraph("A"));
document.newPage();
document.add(new Paragraph("B"));
document.add(new Chunk("go to page 1").setAction(PdfAction.gotoLocalPage(1, new PdfDestination(
PdfDestination.FITH, 500), writer)));
document.add(Chunk.NEWLINE);
document.add(new Chunk("go to another document").setAction(PdfAction.gotoRemotePage(
"remote.pdf", "test", false, true)));
remote.add(new Paragraph("another"));
remote.newPage();
Paragraph p = new Paragraph("This paragraph contains a ");
p.add(new Chunk("local destination").setLocalDestination("test"));
remote.add(p);
document.close();
remote.close();
}
}
|