123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using ComPDFKit.PDFDocument;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDFATest
- {
- internal class PDFATest
- {
- static private string outputPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + "\\Output\\PDFA";
- static void Main(string[] args)
- {
- Console.WriteLine("Running PDFA test sample…\r\n");
- SDKLicenseHelper.LicenseVerify();
- CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
- if (!Directory.Exists(outputPath))
- {
- Directory.CreateDirectory(outputPath);
- }
- #region PDF/A-1a
- if (CovertToPDFA1a(document))
- {
- Console.WriteLine("Convert to PDF/A-1a done.");
- }
- else
- {
- Console.WriteLine("Convert to PDF/A-1a failed.");
- }
- #endregion
- Console.WriteLine("--------------------");
- document.Release();
- document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
- #region PDF/A-1b
- if (CovertToPDFA1b(document))
- {
- Console.WriteLine("Convert to PDF/A-1b done.");
- }
- else
- {
- Console.WriteLine("Convert to PDF/A-1b failed.");
- }
- #endregion
- Console.WriteLine("--------------------");
- Console.WriteLine("Done!");
- Console.WriteLine("--------------------");
- Console.ReadLine();
- }
- static public bool CovertToPDFA1a(CPDFDocument document)
- {
- string convertToPDFA1aPath = outputPath + "\\ConvertToPDFA1aTest.pdf";
- if (!document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1a, convertToPDFA1aPath))
- {
- return false;
- }
- Console.WriteLine("Browse the changed file in " + convertToPDFA1aPath);
- return true;
- }
- static public bool CovertToPDFA1b(CPDFDocument document)
- {
- string convertToPDFA1bPath = outputPath + "\\ConvertToPDFA1bTest.pdf";
- if (!document.WritePDFAToFilePath(CPDFType.CPDFTypePDFA1b, convertToPDFA1bPath))
- {
- return false;
- }
- Console.WriteLine("Browse the changed file in " + convertToPDFA1bPath);
- return true;
- }
- }
- }
|