带封面的目录
示例代码
package test.create.c10;
import iofd.layout.DefaultPageProperty;
import iofd.layout.OfdDocument;
import iofd.layout.block.PageSeparator;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import iofd.layout.physcial.page.menu.IMenuCreator;
import iofd.layout.physcial.page.menu.MenuCreator;
import test.create.TestDocUtil;
public class C1003MultLevelMenuWithFrontCover {
public static void main(String[] args) throws Throwable {
C1003MultLevelMenuWithFrontCover o = new C1003MultLevelMenuWithFrontCover();
o.done();
}
private void done() throws Throwable {
String clzName = this.getClass().getSimpleName();
System.out.println(clzName + " begin");
OfdDocument doc = new OfdDocument();
IMenuCreator menuCreator = new MenuCreator();
doc.setMenuCreator(menuCreator);
DefaultPageProperty prop = DefaultPageProperty.createDefaultPageProperty();
prop.setDebug(true);
doc.setDefaultPageProperty(prop);
doc.setSetFrontCoverPage(true);
Paragraph p = new Paragraph();
String s = "该文本展示如何设置多级目录,并且带封面[本页为封面]";
p.add(new Text(s));
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1 测试目录第1级";
p.add(new Text(s));
p.createCurrentLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1 测试目录第2级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1.1 测试目录第3级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1.1.1 测试目录第4级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1.2 测试目录第3级";
p.add(new Text(s));
p.createManualMenuInfo(null, s, 3);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1.2.1 测试目录第4级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "1.1.2.2 测试目录第4级";
p.add(new Text(s));
p.createCurrentLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "2 测试目录第1级";
p.add(new Text(s));
p.createManualMenuInfo(null, s, 1);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "2.1 测试目录第2级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "2.1.1 测试目录第3级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
doc.add(new PageSeparator());
p = new Paragraph();
s = "2.1.1.1 测试目录第4级";
p.add(new Text(s));
p.createSubLevelMenuInfo(null, s);
doc.add(p);
String fileName = TestDocUtil.getOfdFilePath(this.getClass());
doc.save(fileName);
System.out.println(clzName + " end");
}
}