try {
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
//temDir 文件路径,如c:/aa.pdf
PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream(temDir));
document.open();
Anchor anchorTarget = new Anchor("First page of the document.");
anchorTarget.setName("BackToTop");
Paragraph paragraph1 = new Paragraph();
paragraph1.setSpacingBefore(50);
paragraph1.add(anchorTarget);
document.add(paragraph1);
document.add(new Paragraph("hello word!",
FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new CMYKColor(0, 255, 0, 0))));
writer.close();
document.close();
} catch (Exception e) {
System.out.println(e);
}
还没有评论,来说两句吧...