Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Oct 20, 2021 12:40 pm

Dear e-iceblue team,

Is it possible to produce PDF/A or PDF/UA documents with Spire.PDF?
Thank you!

Best regards,
Thomas Hofstetter

thomas.hofstetter
 
Posts: 1
Joined: Wed Oct 20, 2021 12:35 pm

Thu Oct 21, 2021 2:01 am

Hello,

Thank you for contacting us.
Our Spire.PDF supports producing PDF/A file. You can refer to the following sample code and use our latest Spire.PDF Pack(Hot Fix) Version:7.10.4 to have a try. If there is any question, just feel free to write back.
Code: Select all
 PdfDocument pdf = new PdfDocument();
 PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4);
 page.Canvas.DrawString("Hello World", new PdfTrueTypeFont(new Font("Arial", 20f), true), PdfBrushes.Red, new Point(10, 15));
 //save to PDF stream
 MemoryStream stream = new MemoryStream();
 pdf.SaveToStream(stream, Spire.Pdf.FileFormat.PDF);
 //convert to PDFA1A
 PdfStandardsConverter converter = new PdfStandardsConverter(stream);
 converter.ToPdfA1A(@"PdfA.pdf");

As for PDF/UA, sorry at present our Spire.PDF doesn’t support it. But we have added the new feature into our schedule. Once the feature is supported, we will inform you at the first time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Wed Jul 27, 2022 10:24 am

Hello,

Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:8.7.9 which supports creating PDF/UA files now, please download it from the following links and refer to the following sample code to test.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/8.7.9
Code: Select all
//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();

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF