【发布时间】:2018-06-04 07:34:42
【问题描述】:
在iText5中,我们可以使用章节和章节来添加标题和书签。
然后标题将在可访问的 PDF 中显示为H1 标签。
我如何在iText7 中做到这一点?
【问题讨论】:
标签: c# itext7 accessible
在iText5中,我们可以使用章节和章节来添加标题和书签。
然后标题将在可访问的 PDF 中显示为H1 标签。
我如何在iText7 中做到这一点?
【问题讨论】:
标签: c# itext7 accessible
在 iText7 中,你会这样做:
@Test
public void run() throws IOException {
File outputFile = getOutputFile();
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outputFile));
pdfDocument.setTagged();
Document layoutDocument = new Document(pdfDocument);
Paragraph para = new Paragraph("The Raven")
.setFontColor(new DeviceRgb(8, 73, 117))
.setFontSize(20f);
para.getAccessibilityProperties().setRole(StandardRoles.H1);
layoutDocument.add(para);
layoutDocument.add(new Paragraph("Once upon a midnight dreary\nWhile I pondered weak and weary\nOver many a quaint and curious volume\nOf forgotten lore"));
pdfDocument.close();
Desktop.getDesktop().open(outputFile);
}
使用 Adobe Reader 检查标签,确认已应用正确的标签。
【讨论】: