Examples

Create PDF/A Compatible PDFs

Ensuring a document's long-term archiving and preservation is a breeze when using DynamicPDF Core Suite for .NET to create PDF/A compatible PDFs. The following C# examples show you how.

How to Create PDF/A Compatible PDF

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


Steps for Creating PDF/A Compatible PDF


  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. Add the Document object's Draw method to draw and 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(@"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(@"Output.pdf");        

Steps for Creating PDF/A-3a Compatible PDF


  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. Add the Document object's Draw method to draw and 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(@"Output.pdf");        

GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub


Clone or View Example Project on GitHub

Getting Started

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing.


NuGet Package


The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information


DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!



More Information on PDF/A

Available on Other Platforms

DynamicPDF Core Suite is also 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 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

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