|
@@ -15,10 +15,13 @@ namespace AnnotationImportExportTest
|
|
|
|
|
|
static void Main(string[] args)
|
|
static void Main(string[] args)
|
|
{
|
|
{
|
|
|
|
+
|
|
Console.WriteLine("Running header and footer test sample…\r\n");
|
|
Console.WriteLine("Running header and footer test sample…\r\n");
|
|
- SDKLicenseHelper.LicenseVerify();
|
|
|
|
|
|
|
|
|
|
+ #region Preparation work
|
|
|
|
|
|
|
|
+ SDKLicenseHelper.LicenseVerify();
|
|
|
|
+
|
|
if (!Directory.Exists(outputPath))
|
|
if (!Directory.Exists(outputPath))
|
|
{
|
|
{
|
|
Directory.CreateDirectory(outputPath);
|
|
Directory.CreateDirectory(outputPath);
|
|
@@ -28,6 +31,10 @@ namespace AnnotationImportExportTest
|
|
Directory.CreateDirectory(tempPath);
|
|
Directory.CreateDirectory(tempPath);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region Sample 1: Export Annotation
|
|
|
|
+
|
|
CPDFDocument annotationsDocument = CPDFDocument.InitWithFilePath("Annotations.pdf");
|
|
CPDFDocument annotationsDocument = CPDFDocument.InitWithFilePath("Annotations.pdf");
|
|
if (ExportAnnotaiton(annotationsDocument))
|
|
if (ExportAnnotaiton(annotationsDocument))
|
|
{
|
|
{
|
|
@@ -38,9 +45,12 @@ namespace AnnotationImportExportTest
|
|
Console.WriteLine("Export annotaiton failed.");
|
|
Console.WriteLine("Export annotaiton failed.");
|
|
}
|
|
}
|
|
Console.WriteLine("--------------------");
|
|
Console.WriteLine("--------------------");
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
|
|
- CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
|
|
|
|
|
|
+ #region Sample 2: Import Annotations
|
|
|
|
|
|
|
|
+ CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
|
|
if (ImportAnnotaiton(document))
|
|
if (ImportAnnotaiton(document))
|
|
{
|
|
{
|
|
Console.WriteLine("Import annotaiton done.");
|
|
Console.WriteLine("Import annotaiton done.");
|
|
@@ -50,11 +60,43 @@ namespace AnnotationImportExportTest
|
|
Console.WriteLine("Import annotaiton failed.");
|
|
Console.WriteLine("Import annotaiton failed.");
|
|
}
|
|
}
|
|
Console.WriteLine("--------------------");
|
|
Console.WriteLine("--------------------");
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ //---------- Finished ----------
|
|
Console.WriteLine("Done");
|
|
Console.WriteLine("Done");
|
|
Console.WriteLine("--------------------");
|
|
Console.WriteLine("--------------------");
|
|
Console.ReadLine();
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Export the annotations in the document to XFDF format.
|
|
|
|
+ /// Parameters in function "ImportAnnotationFromXFDFPath":
|
|
|
|
+ /// 1. The path to the exported XFDF file
|
|
|
|
+ /// 2. The path for storing temporary files.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="document">A document with multiple annotations</param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Importing XFDF into the document.
|
|
|
|
+ /// Parameters in function "ImportAnnotationFromXFDFPath":
|
|
|
|
+ /// 1. The path to the XFDF file for importing.
|
|
|
|
+ /// 2. The path for storing temporary files.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="document">A document without annotations used for importing XFDF.</param>
|
|
|
|
+ /// <returns></returns>
|
|
static private bool ImportAnnotaiton(CPDFDocument document)
|
|
static private bool ImportAnnotaiton(CPDFDocument document)
|
|
{
|
|
{
|
|
var path = outputPath + "//ImportAnnotationTest.pdf";
|
|
var path = outputPath + "//ImportAnnotationTest.pdf";
|
|
@@ -70,17 +112,5 @@ namespace AnnotationImportExportTest
|
|
Console.WriteLine("Browse the changed file in " + path);
|
|
Console.WriteLine("Browse the changed file in " + path);
|
|
return true;
|
|
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;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|