C# 使用iText 7和C在可访问的pdf中添加标题H1#
在C# 使用iText 7和C在可访问的pdf中添加标题H1#,c#,itext7,accessible,C#,Itext7,Accessible,在iText5中,我们可以使用章节添加标题和书签。 然后标题将在可访问的PDF中显示为H1标记。 如何在iText7中执行此操作 在iText7中,您可以这样做: @Test public void run() throws IOException { File outputFile = getOutputFile(); PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outputFile)); pdfD
iText5
中,我们可以使用章节添加标题和书签。然后标题将在可访问的PDF中显示为
H1
标记。如何在
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);
}
使用Adobe Reader检查标记可验证是否应用了正确的标记