1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using ComPDFKit.PDFDocument;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AnnotationImportExportTest
- {
- internal class AnnotationImportExportTest
- {
- private static string outputPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + "\\Output\\AnnotationImportExportTest";
- private static string tempPath = outputPath + "//temp";
- static void Main(string[] args)
- {
- Console.WriteLine("Running header and footer test sample…\r\n");
- SDKLicenseHelper.LicenseVerify();
- if (!Directory.Exists(outputPath))
- {
- Directory.CreateDirectory(outputPath);
- }
- if (!Directory.Exists(tempPath))
- {
- Directory.CreateDirectory(tempPath);
- }
- CPDFDocument annotationsDocument = CPDFDocument.InitWithFilePath("Annotations.pdf");
- if (ExportAnnotaiton(annotationsDocument))
- {
- Console.WriteLine("Export annotaiton done.");
- }
- else
- {
- Console.WriteLine("Export annotaiton failed.");
- }
- Console.WriteLine("--------------------");
- CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
- if (ImportAnnotaiton(document))
- {
- Console.WriteLine("Import annotaiton done.");
- }
- else
- {
- Console.WriteLine("Import annotaiton failed.");
- }
- Console.WriteLine("--------------------");
- Console.WriteLine("Done");
- Console.WriteLine("--------------------");
- Console.ReadLine();
- }
- static private bool ImportAnnotaiton(CPDFDocument document)
- {
- var path = outputPath + "//ImportAnnotationTest.pdf";
- if (!document.ImportAnnotationFromXFDFPath("Annotations.xfdf", tempPath))
- {
- return false;
- }
- if (!document.WriteToFilePath(path))
- {
- return false;
- }
- Console.WriteLine("Browse the changed file in " + path);
- return true;
- }
- static private bool ExportAnnotaiton(CPDFDocument document)
- {
- var path = outputPath+ "//ExportAnnotationTest.xfdf";
- if (document.ExportAnnotationToXFDFPath(path, tempPath))
- {
- return false;
- }
- Console.WriteLine("Xfdf file in " + path);
- return true;
- }
- }
- }
|