| |
29. 33. 3. 设置书签名称 |
|
import java.io.FileOutputStream;
import com.lowagie.text.ChapterAutoNumber;
import com.lowagie.text.Document;
import com.lowagie.text.Phrase;
import com.lowagie.text.Section;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
document.open();
Phrase text = new Phrase("test. ");
ChapterAutoNumber chapter1 = new ChapterAutoNumber("This is a sample sentence:");
chapter1.setBookmarkTitle("The fox");
chapter1.setBookmarkOpen(false);
Section section1 = chapter1.addSection("Quick");
section1.add(text);
document.add(chapter1);
ChapterAutoNumber chapter2 = new ChapterAutoNumber("Jumps");
Section section = chapter2.addSection("Over");
section.add(text);
document.add(chapter2);
document.close();
}
}
|
|
|