Bri*_*tis 2 c# accessible itext7
在iText5,我们可以使用章节和章节来添加标题和书签.
然后标题将显示为H1可访问PDF中的标记.
我怎么能这样做iText7?
在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);
}
Run Code Online (Sandbox Code Playgroud)
使用Adobe Reader检查标记可验证是否已应用正确的标记.