// // Copyright (c) 2001-2012 by PDFTron Systems Inc. All Rights Reserved. // using System; using pdftron; using pdftron.SDF; using pdftron.PDF; using pdftron.PDF.PDFA; //----------------------------------------------------------------------------------- // The sample illustrates how to use PDF/A related API-s. //----------------------------------------------------------------------------------- namespace PDFATestCS { class Class1 { // Relative path to the folder containing test files. static string input_path = "../../../../TestFiles/"; static string output_path = "../../../../TestFiles/Output/"; /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { PDFNet.Initialize(); PDFNet.SetColorManagement(PDFNet.CMSType.e_lcms); // Required for PDFA validation. //----------------------------------------------------------- // Example 1: PDF/A Validation //----------------------------------------------------------- try { string filename = "newsletter.pdf"; PDFACompliance pdf_a = new PDFACompliance(false, input_path+filename, null, PDFACompliance.Conformance.e_Level1B, null, 10, false); PrintResults(pdf_a, filename); pdf_a.Dispose(); } catch (pdftron.Common.PDFNetException e) { Console.WriteLine(e.Message); } //----------------------------------------------------------- // Example 2: PDF/A Conversion //----------------------------------------------------------- try { string filename = "fish.pdf"; PDFACompliance pdf_a = new PDFACompliance(true, input_path+filename, null, PDFACompliance.Conformance.e_Level1B, null, 10, false); filename = output_path + "pdfa.pdf"; pdf_a.SaveAs(filename, true); pdf_a.Dispose(); // Re-validate the document after the conversion... pdf_a = new PDFACompliance(false, filename, null, PDFACompliance.Conformance.e_Level1B, null, 10, false); PrintResults(pdf_a, filename); pdf_a.Dispose(); } catch (pdftron.Common.PDFNetException e) { Console.WriteLine(e.Message); } PDFNet.Terminate(); } static void PrintResults(PDFACompliance pdf_a, String filename) { int err_cnt = pdf_a.GetErrorCount(); if (err_cnt == 0) { Console.WriteLine("{0}: OK.", filename); } else { Console.WriteLine("{0} is NOT a valid PDFA.", filename); for (int i=0; i 0) { Console.Write(" Objects:"); for (int j=0; j