Create PDF/A-1a file in C#

The PDF/A-1 standard specifies two levels of conformance for PDF files: PDF/A-1a (Level A conformance) and PDF/A-1b (Level B conformance). With Spire.PDF, you can create both PDF/A-1a and PDF/A-1b files easily. This article demonstrates the detail steps of how to create a PDF/A-1a file by using Spire.PDF.

Below is the PDF/A-1a file we created:

Create PDF/A-1a file in C#

Detail steps:

Step 1: Create a new PDF file and specify its conformance level as PDF/A-1a.

PdfDocument pdf = new PdfDocument(PdfConformanceLevel.Pdf_A1A);

Step 2: Add a new page to the file, then add an image and some text to the page.

PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4);
page.Canvas.DrawImage(PdfImage.FromFile("Background.jpg"), PointF.Empty, page.GetClientSize());
page.Canvas.DrawString("Hello World, test PDF/A-1a!", new PdfTrueTypeFont(new Font("Arial", 20f), true), PdfBrushes.Red, new Point(10, 15));

Step 3: Save the file.

pdf.SaveToFile("A-1a.pdf");

Full code:

using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Graphics;

namespace Create_PDF_A_1a
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument(PdfConformanceLevel.Pdf_A1A);
            PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4);
            page.Canvas.DrawImage(PdfImage.FromFile("Background.jpg"), PointF.Empty, page.GetClientSize());
            page.Canvas.DrawString("Hello World, test PDF/A-1a!", new PdfTrueTypeFont(new Font("Arial", 20f), true), PdfBrushes.Red, new Point(10, 15));
            pdf.SaveToFile("A-1a.pdf");
        }
    }
}