Examples

Creating PDF/A compatible PDF (.NET Core/Framework)

Creating PDFA compatible PDF using DynamicPDF Core Suite is straightforward.

DynamicPDF can produce and preserve PDF documents with the following conformance levels

  • PDF/A-1a
  • PDF/A-1b
  • PDF/A-2a
  • PDF/A-2b
  • PDF/A-2u
  • PDF/A-3a
  • PDF/A-3b
  • PDF/A-3u

How to Create PDF/A compatible PDF in C#

Below are the steps and sample code to create PDF/A-1a and PDF/A-3a compatible PDF document using DynamicPDF Core Suite.

Steps for Creating PDF/A Compatible PDF Document

  1. Create a Document object.
  2. Create a XmpMetadata object.
  3. Create a PdfASchema object and specify the PDF/A standard (A-1a in this case).
  4. Create a DublinCoreSchema object and assign to XmpMetadata.
  5. Set the properties for DublinCoreSchema.
  6. Set the XmpMetadata to the Document instance.
  7. Create a IccProfile object.
  8. Create a OutputIntent object and specify the parameters along with the IccProfile object.
  9. Create a Page object and add any page element.
  10. Add the Page instance to the Document instance.
  11. Save the PDf document.

Sample Code - C#

Document document = new Document();
document.Title = "PDF/A1 Document";

XmpMetadata xmp = new XmpMetadata();

PdfASchema pdfaschema = new PdfASchema(PdfAStandard.PDF_A_1a_2005);
xmp.AddSchema(pdfaschema);

DublinCoreSchema dc = xmp.DublinCore;
dc.Title.DefaultText = document.Title;
dc.Description.DefaultText = document.Subject;
dc.Creators.Add(document.Author);
dc.Title.AddLang("en-us", "PDF/A1 Document");
document.XmpMetadata = xmp;

IccProfile iccProfile = new IccProfile(@"C:\Temp\IccProfile\sRGB_IEC61966-2-1_noBPC.icc");
OutputIntent outputIntents = new OutputIntent("", "IEC 61966-2.1 Default RGB colour space - sRGB 1 ", "http://www.color.org", "sRGB IEC61966-2.1 1", iccProfile);
outputIntents.Version = OutputIntentVersion.PDF_A;
document.OutputIntents.Add(outputIntents);

string text = "PDF/A (Archiving) specifically targets PDF documents that need to be preserved long term.";
OpenTypeFont openTypeFont = new OpenTypeFont("times.ttf");
Label label = new Label(text, 0, 0, 504, 100, openTypeFont, 18, TextAlign.Center, RgbColor.BlueViolet);

Page page = new Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);
page.Elements.Add(label);
document.Pages.Add(page);
            
document.Draw(@"C:\Output.pdf");        

Steps for Creating PDF/A-3a compatible PDF Document

  1. Create a Document object.
  2. Create a XmpMetadata object.
  3. Create a PdfASchema` object and specify the PDF/A standard (A-3a in this case).
  4. Create a DublinCoreSchema object and assign to XmpMetadata.
  5. Set the properties for DublinCoreSchema.
  6. Set the XmpMetadata to the Document.
  7. Create a IccProfile object.
  8. Create a OutputIntent object and specify the parameters along with the IccProfile object.
  9. Create a EmbeddedFile object pass any file that needs to be embedded.
  10. Create a Page object and add any page element.
  11. Add Page to the Document.
  12. Save the PDf document.

Sample Code - C#

Document document = new Document();
document.Title = "PDF/A1 Document";

XmpMetadata xmp = new XmpMetadata();

PdfASchema pdfaschema = new PdfASchema(PdfAStandard.PdfA3a);
xmp.AddSchema(pdfaschema);

DublinCoreSchema dc = xmp.DublinCore;
dc.Title.DefaultText = document.Title;
dc.Description.DefaultText = document.Subject;
dc.Creators.Add(document.Author);
dc.Title.AddLang("en-us", "PDF/A1 Document");
document.XmpMetadata = xmp;

 // Needs iccprofile file to be embedded.
IccProfile iccProfile = new IccProfile(@"ProfilePath\sRGB_IEC61966-2-1_noBPC.icc");
OutputIntent outputIntents = new OutputIntent("", "IEC 61966-2.1 Default RGB colour space - sRGB 1 ", "http://www.color.org", "sRGB IEC61966-2.1 1", iccProfile);
outputIntents.Version = OutputIntentVersion.PDF_A;
document.OutputIntents.Add(outputIntents);

EmbeddedFile embeddedFile1 = new EmbeddedFile(@"ExcelFilePath\HelloWorldExcel.xls");
embeddedFile1.Relation = EmbeddedFileRelation.Data;
embeddedFile1.MimeType = "application/excel";
document.EmbeddedFiles.Add(embeddedFile1);
 
EmbeddedFile embeddedFile2 = new EmbeddedFile(@"XMLFilePath\Simple.xml");
embeddedFile2.Relation = EmbeddedFileRelation.Source;
embeddedFile2.MimeType = "application/xml";
document.EmbeddedFiles.Add(embeddedFile2);
 
string text = "PDF/A (Archiving) specifically targets PDF documents that need to be preserved long term.";
OpenTypeFont openTypeFont = new OpenTypeFont("times.ttf");
openTypeFont.Subset = false;
Label label = new Label(text, 0, 0, 504, 100, openTypeFont, 18, TextAlign.Center, RgbColor.BlueViolet);

Page page = new Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);
page.Elements.Add(label);
document.Pages.Add(page);
            
document.Draw(@"C:\Output.pdf");        

Getting Started

NuGet Package

DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is through the Visual Studio Package Manager. You can also download the package directly from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

More information can be found on the DynamicPDF Core Suite webpage.

Available on Other Platforms

DynamicPDF Core Suite is available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!