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.PdfOutline;
import com.lowagie.text.pdf.PdfWriter;
public class DestinationsPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DestinationsPDF.pdf"));
writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
PdfDestination d5 = new PdfDestination(PdfDestination.FIT);
PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
PdfOutline out3 = new PdfOutline(out1, d3, "sub 2");
PdfOutline out4 = new PdfOutline(out2, d4, "sub 2.1");
PdfOutline out5 = new PdfOutline(out2, d5, "sub 2.2");
document.add(new Paragraph("adasd"));
document.newPage();
} catch (Exception de) {
de.printStackTrace();
}
document.close();
}
}
|