AnnotationTest.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using ComPDFKit.Import;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKit.PDFDocument;
  4. using ComPDFKit.PDFPage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Xml.Linq;
  12. namespace AnnotationTest
  13. {
  14. internal class AnnotationTest
  15. {
  16. static private string outputPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) + "\\Output\\Background";
  17. static void Main(string[] args)
  18. {
  19. Console.WriteLine("Running Watermark test sample…\r\n");
  20. SDKLicenseHelper.LicenseVerify();
  21. CPDFDocument document = CPDFDocument.InitWithFilePath("CommonFivePage.pdf");
  22. if (!Directory.Exists(outputPath))
  23. {
  24. Directory.CreateDirectory(outputPath);
  25. }
  26. CreateTestAnnots(document);
  27. }
  28. static private void CreateFreetextAnnotation(CPDFDocument document)
  29. {
  30. CPDFPage page = document.PageAtIndex(0);
  31. CPDFFreeTextAnnotation freeText = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT) as CPDFFreeTextAnnotation;
  32. freeText.SetContent("ComPDFKit");
  33. freeText.SetRect(new CRect(0, 50, 50, 0));
  34. }
  35. static private void CreateFreehandAnnotation(CPDFDocument document)
  36. {
  37. }
  38. static private void CreateShapeAnnotation(CPDFDocument document)
  39. {
  40. }
  41. static private void CreateNoteAnnotation(CPDFDocument document)
  42. {
  43. }
  44. static private bool CreateTestAnnots(CPDFDocument document)
  45. {
  46. CreateFreetextAnnotation(document);
  47. CreateFreehandAnnotation(document);
  48. CreateShapeAnnotation(document);
  49. CreateNoteAnnotation(document);
  50. return true;
  51. }
  52. }
  53. }