News Category

Spire.PDF for Java 8.12.6 supports creating tagged PDF files

2022-12-21 09:10:58

We are happy to announce the release of Spire.PDF for Java 8.12.6. This version supports creating tagged PDF files. This release also includes performance optimization, such as the optimization in the time consumption of extracting images and compressing PDF files. Besides, some know issues are successfully fixed. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature - Supports creating tagged PDF files.
//Create a pdf document
PdfDocument doc = new PdfDocument();
//Add page
doc.getPages().add();
//Set tab order
doc.getPages().get(0).setTabOrder(TabOrder.Structure);
//Create PdfTaggedContent
PdfTaggedContent taggedContent = new PdfTaggedContent(doc);
taggedContent.setLanguage("en-US");
taggedContent.setTitle("test");
//Set font
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Times New Roman",Font.PLAIN,12), true);
PdfSolidBrush brush = new PdfSolidBrush(new PdfRGBColor(Color.black));
//Append elements
PdfStructureElement article = taggedContent.getStructureTreeRoot().appendChildElement(PdfStandardStructTypes.Document);
PdfStructureElement paragraph1 = article.appendChildElement(PdfStandardStructTypes.Paragraph);
PdfStructureElement span1 = paragraph1.appendChildElement(PdfStandardStructTypes.Span);
span1.beginMarkedContent(doc.getPages().get(0));
PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify);
doc.getPages().get(0).getCanvas().drawString("Spire.PDF for .NET is a professional PDF API applied to creating, writing, editing, handling and reading PDF files.",
font, brush, new Rectangle(40, 0, 480, 80), format);
span1.endMarkedContent(doc.getPages().get(0));
PdfStructureElement paragraph2 = article.appendChildElement(PdfStandardStructTypes.Paragraph);
paragraph2.beginMarkedContent(doc.getPages().get(0));
doc.getPages().get(0).getCanvas().drawString("Spire.PDF for .NET can be applied to easily convert Text, Image, SVG, HTML to PDF and convert PDF to Excel with C#/VB.NET in high quality.",
font, brush, new Rectangle(40, 80, 480, 60), format);
paragraph2.endMarkedContent(doc.getPages().get(0));
PdfStructureElement figure1 = article.appendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text
figure1.setAlt("replacement text1");
figure1.beginMarkedContent(doc.getPages().get(0), null);
PdfImage image = PdfImage.fromFile("E-logo.png");
Dimension2D dimension2D = new Dimension();
dimension2D.setSize( 100,100);
doc.getPages().get(0).getCanvas().drawImage(image, new Point2D.Float(40, 200),dimension2D);
figure1.endMarkedContent(doc.getPages().get(0));
PdfStructureElement figure2 = article.appendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text
figure2.setAlt( "replacement text2");
figure2.beginMarkedContent(doc.getPages().get(0), null);
doc.getPages().get(0).getCanvas().drawRectangle(PdfPens.getBlack(), new Rectangle(300, 200, 100, 100));
figure2.endMarkedContent(doc.getPages().get(0));

//Save to file
String result = "CreateTaggedFile_result.pdf";
doc.saveToFile(result);
doc.close();
Bug SPIREPDF-4806 Optimizes the time consumption of extracting images.
Bug SPIREPDF-4856 Optimizes the memory consumption of compressing document images.
Bug SPIREPDF-4860
SPIREPDF-5583
Fixes the issue that the application hanged for a long time when loading a PDF file.
Bug SPIREPDF-4955 Optimizes the time consumption of compressing PDF file.
Bug SPIREPDF-5496 Fixes the issue that the application threw "No 'TimesNewRoman' font found" when defining the CustomFontsFolders to convert PDF to Excel.
Bug SPIREPDF-5622 Fixes the issue that the borders had different thickness when drawing table with PdfGrid.
Bug SPIREPDF-5641 Fixes the issue that the grid cell content displayed incorrectly when drawing on different position.
Bug SPIREPDF-5646 Fixes the issue that the application threw "Unexpected token Unknown before 105" when merging PDF files.
Click the link below to download Spire.PDF for Java 8.12.6: