我正在尝试在横向模式下为我的PDF创建目录页面,并且链接在纵向模式下不起作用。
以下是示例代码:
Document doc = new Document(PageSize.A4.rotate());
PffWriter.getInstance(doc, new FileOutputStream("test.pdf"));
doc.open();
// Create a chunk and add it to the document.
Chunk chunk = new Chunk("Click this link to goto second page.");
chunk.setUnderline(0.2f, -2f);
chunk.setLocalGoto("test");
chunk.setLocalDestination("test1");
doc.add(chunk);
// Skip rest of current page and begin a new page.
doc.add(Chunk.NEXTPAGE);
// Create a chunk and add it to the document.
chunk = new Chunk("Click this link to goto first page.");
chunk.setUnderline(0.2f, -2f);
chunk.setLocalGoto("test1");
chunk.setLocalDestination("test");
doc.add(chunk);
doc.close();
而不是:
Document doc = new Document(PageSize.A4.rotate());
如果我这样做:
Document doc = new Document(PageSize.A4);
它按预期工作,链接工作得很好。但它在横向模式下失败了。