package com.geek.tutorial.itext.bookmarks;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.Chunk;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfOutline;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfAction;
import java.io.FileOutputStream;
public class Outline {
public Outline() throws Exception{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("outline.pdf"));
document.open();
// Code 1
document.add(new Chunk("Chapter 1")
.setLocalDestination("1"));
document.newPage();
document.add(new Chunk("Chapter 2")
.setLocalDestination("2"));
document.add(new Paragraph(new Chunk("Sub 2.1")
.setLocalDestination("2.1")));
document.add(new Paragraph(new Chunk("Sub 2.2")
.setLocalDestination("2.2")));
document.newPage();
document.add(new Chunk("Chapter 3")
.setLocalDestination("3"));
// Code 2
PdfContentByte cb = writer.getDirectContent();
PdfOutline root = cb.getRootOutline();
// Code 3
PdfOutline oline1 = new PdfOutline(root,
PdfAction.gotoLocalPage("1", false),"Chapter 1");
PdfOutline oline2 = new PdfOutline(root,
PdfAction.gotoLocalPage("2", false),"Chapter 2");
oline2.setOpen(false);
PdfOutline oline2_1 = new PdfOutline(oline2,
PdfAction.gotoLocalPage("2.1", false),"Sub 2.1");
PdfOutline oline2_2 = new PdfOutline(oline2,
PdfAction.gotoLocalPage("2.2", false),"Sub 2.2");
PdfOutline oline3 = new PdfOutline(root,
PdfAction.gotoLocalPage("3", false),"Chapter 3");
document.close();
}
public static void main(String[] args) {
try{
Outline outline = new Outline();
}catch(Exception e){
System.out.println(e);
}
}
}
分享到:
相关推荐
Adding white noise to a signal with fixed SNR
America’s wireless industry is ready to invest $275 billion to deploy next-generation 5G networks — creating 3 million new jobs and adding $500 billion to our economy, according to Accenture.
标题中的“instructions-for-adding-your-logo.pdf”暗示了这是一个关于如何在PDF文件中添加徽标的指南。PDF(Portable Document Format)是一种广泛使用的文档格式,它能够保持文档的原始布局和设计,不受操作系统...
Advanced PDF Generator gives you an opportunity to create PDF documents with your applications written on Delphi or C++ Builder in the most simple and easiest way. There is no need to know PDF ...
Adding Objects: Learn how to place 3D Objects into augmented space. Materials & Lighting: Explore the concepts of Physical Based Rendering, textures and light estimation. Creating 3D Assets: Get ...
本文源自FAST12会议的一篇论文,题目为“Adding Advanced Storage Controller Functionality via Low-Overhead Virtualization”,主要探讨了如何利用低开销虚拟化技术来扩展存储控制器的功能。 在历史发展过程中,...
Adding Objects: Learn how to place 3D Objects into augmented space. Materials & Lighting: Explore the concepts of Physical Based Rendering, textures and light estimation. Creating 3D Assets: Get ...
Adding Objects: Learn how to place 3D Objects into augmented space. Materials & Lighting: Explore the concepts of Physical Based Rendering, textures and light estimation. Creating 3D Assets: Get ...
Adding Objects: Learn how to place 3D Objects into augmented space. Materials & Lighting: Explore the concepts of Physical Based Rendering, textures and light estimation. Creating 3D Assets: Get ...
Adding Objects: Learn how to place 3D Objects into augmented space. Materials & Lighting: Explore the concepts of Physical Based Rendering, textures and light estimation. Creating 3D Assets: Get ...
节点msoffice-pdf 通过Office远程处理,使用edge.js +一点C#代码将Office文档导出为pdf。 取决于Office 2013 + Windows。 安装 npm安装node-msoffice-pdf 用法 var msopdf = require ( 'node-msoffice-pdf' ) ; ...
在现代的Web应用中,音频元素的集成已经成为增强用户体验的重要组成部分。"tutsplus-将声音添加到您的网络应用程序"这个教程将引导你通过使用JavaScript技术来实现这一目标。JavaScript,作为Web开发中的核心技术,...
「安全意识」信息安全_数据安全_Adding Social Intelligence to Smart De - 攻防实训 威胁情报 云安全 攻防实训 WEB应用防火墙 渗透测试
在本课程"FEWD-unit4-adding-3d-effects-with-css:树屋FEWD单元4"中,我们将深入探讨如何利用CSS(Cascading Style Sheets)来创建令人惊叹的3D效果。CSS作为网页设计的核心技术之一,允许我们对网页元素进行布局、...
+ added outline to PDF export + added anchors to PDF export - fixed bug with embedded TTC fonts in PDF export + added an ability to create multiimage TIFF files + added export headers/footers in ODF ...
Indoor TD-LTE Small Cell Deployment Study:Benefit of Adding Cells is Not Always Existing
my_vector + 1 # Adding 1 to each element my_vector * 2 # Multiplying each element by 2 ``` Remember, R is a vectorized language, meaning that many operations are automatically applied element-wise to...
Enhance your capability with Debenu Quick PDF Library: a powerful, royalty-free developer PDF SDK for adding PDF functionality to your applications. With over 900 functions for use with C, C++, C#, ...
And it can put the fields returned by pgyer into an environment variable, which you can use in other build steps, You can select upload to pgyer by adding build steps or adding post-build steps. ...