Spire.PDF 8.7.9 support creating tagged PDF files

2022-07-27 08:15:32

We are glad to announce the release of Spire.PDF 8.7.9. This version support creating tagged PDF files and PDF/UA files. It also enhances the conversion from PDF to SVG. Additionally, it fixes some known issues such as the application threw "System.NotSupportedException" when signing a PDF document with a timestamp server. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREPDF-3803

Support creating tagged PDF files.

//Note:At present, in order to ensure the validity of the output tagged PDF file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark.

//Spire.License.LicenseProvider.SetLicenseKey("valid license key");

//Create a pdf document
PdfDocument doc = new PdfDocument();

//Add page
doc.Pages.Add();

//Set tab order
doc.Pages[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 System.Drawing.Font("Times New Roman", 10), true);
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);

//Append elements
PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document);
PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph);
PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span);
span1.BeginMarkedContent(doc.Pages[0]);

PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify);
doc.Pages[0].Canvas.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.Pages[0]);

PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph);
paragraph2.BeginMarkedContent(doc.Pages[0]); doc.Pages[0].Canvas.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.Pages[0]);

PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text 
figure1.Alt = "replacement text1";
figure1.BeginMarkedContent(doc.Pages[0], null);
PdfImage image = PdfImage.FromFile(@"E-logo.png");
doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100));
figure1.EndMarkedContent(doc.Pages[0]);

PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text
figure2.Alt = "replacement text2";
figure2.BeginMarkedContent(doc.Pages[0], null);
  doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100));
figure2.EndMarkedContent(doc.Pages[0]);

//Save to file
String result = "CreateTaggedFile_result.pdf";
doc.SaveToFile(result);
doc.Close();
New feature SPIREPDF-4559 Support creating PDF/UA files.
//Note:At present, in order to ensure the validity of the output PDF/UA file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark.
//Spire.License.LicenseProvider.SetLicenseKey("valid license key");

//Create a pdf document
PdfDocument doc = new PdfDocument();

//Add page
doc.Pages.Add();

//Set tab order
doc.Pages[0].SetTabOrder(TabOrder.Structure);

//Create PdfTaggedContent
PdfTaggedContent taggedContent = new PdfTaggedContent(doc);
taggedContent.SetLanguage("en-US");
taggedContent.SetTitle("test");

//Set PDF/UA1 identification
taggedContent.SetPdfUA1Identification();

//Set font
PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 10), true);
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);

//Append elements
PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document);
PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph);
PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span);
span1.BeginMarkedContent(doc.Pages[0]);

PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify);
doc.Pages[0].Canvas.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.Pages[0]);

PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph);
paragraph2.BeginMarkedContent(doc.Pages[0]);
doc.Pages[0].Canvas.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.Pages[0]);

PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text 
figure1.Alt = "replacement text1";
figure1.BeginMarkedContent(doc.Pages[0], null);
PdfImage image = PdfImage.FromFile(@"E-logo.png");
doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100));
figure1.EndMarkedContent(doc.Pages[0]);

PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure);
//Set Alternate text
figure2.Alt = "replacement text2";
figure2.BeginMarkedContent(doc.Pages[0], null);
  doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100));
figure2.EndMarkedContent(doc.Pages[0]);

//Save to file
String result = "CreatePDFUAFile_result.pdf";
doc.SaveToFile(result);
doc.Close();
Bug SPIREPDF-4227 Fixes the issue that the application threw "System.NotSupportedException" when signing a PDF document with a timestamp server.
Bug SPIREPDF-4596 Fixes the issue that the content format was incorrect after converting PDF to excel file.
Bug SPIREPDF-5214 Fixes the issue that the application threw "System.NullReferenceException" when converting PDF to SVG.
Bug SPIREPDF-5247 Fixes the issue that the stamp content format was incorrect after printing PDF file.
Bug SPIREPDF-5266 Optimizes the time consumption issue when finding PDF file text.
Bug SPIREPDF-5277 Fixes the issue that the ReplaceAllText() function didn't take effect.
Bug SPIREPDF-5292 Optimizes the DrawString() method to draw Html string.
Bug SPIREPDF-5314 Fixes the issue that the RemoveCustomProperty() function effect was incorrect.
Bug SPIREPDF-5317 Fixes the issue that the application threw "System.OutOfMemoryException" when compressing PDF images.
Bug SPIREPDF-5318 Fixes the issue that the output PDF couldn't be opened after converting from a u3d file.
Bug SPIREPDF-5319 Fixes the issue that the size of the extracted images was incorrect.
Bug SPIREPDF-5330 Fixes the issue that the QR code of the PDF file was incorrect after converting PDF to image.
Bug SPIREPDF-5331 Fixes the issue that the application threw "System.NullReferenceException" when extracting text from a PDF/A file.
Bug SPIREPDF-5333 Fixes the issue that it wasn't able to find text from a PDF file.
Bug SPIREPDF-5336 Fixes the issue that the application threw "Invalid year in date string" after loading and then directly saving a PDF file.
Bug SPIREPDF-5351 Fixes the issue that the content lost after printing a PDF file.
Bug SPIREPDF-5305 Fixes the issue that the application threw "System.IndexOutOfRangeException" when merging PDF files.
Click the link to download Spire.PDF 8.7.9:
More information of Spire.PDF new release or hotfix: