Setting up Local Destination
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfWriter;
public class LocalDestinationPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LocalDestinationPDF.pdf"));
document.open();
document.add(new Paragraph("Page 1"));
document.newPage();
document.add(new Paragraph("Page 2"));
PdfContentByte cb = writer.getDirectContent();
cb.localDestination("page2", new PdfDestination(PdfDestination.XYZ, -1, 10000, 0));
writer.setOpenAction("page2");
} catch (Exception de) {
de.printStackTrace();
}
document.close();
}
}
itext.zip( 1,748 k)Related examples in the same category