Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. using foxit;
  2. using foxit.common;
  3. using foxit.common.fxcrt;
  4. using foxit.pdf;
  5. using foxit.pdf.annots;
  6. using foxit.addon;
  7. ...
  8.  
  9. using (PDFDoc base_doc = new PDFDoc("input_base_file"))
  10. {
  11. error_code = base_doc.Load(null);
  12. if (error_code != ErrorCode.e_ErrSuccess)
  13. {
  14. Library.Release();
  15. return;
  16. }
  17.  
  18. using (PDFDoc compared_doc = new PDFDoc("input_compared_file"))
  19. {
  20. error_code = compared_doc.Load(null);
  21. if (error_code != ErrorCode.e_ErrSuccess)
  22. {
  23. Library.Release();
  24. return;
  25. }
  26.  
  27. using (Comparison comparison = new Comparison(base_doc, compared_doc))
  28. {
  29. // Start comparing.
  30. CompareResults result = comparison.DoCompare(0, 0, (int)Comparison.CompareType.e_CompareTypeText);
  31. CompareResultInfoArray oldInfo = result.results_base_doc;
  32. CompareResultInfoArray newInfo = result.results_compared_doc;
  33. uint oldInfoSize = oldInfo.GetSize();
  34. uint newInfoSize = newInfo.GetSize();
  35.  
  36. using (PDFPage page = compared_doc.GetPage(0))
  37. {
  38. for (uint i = 0; i < newInfoSize; i++)
  39. {
  40. CompareResultInfo item = newInfo.GetAt(i);
  41. CompareResultInfo.CompareResultType type = item.type;
  42. if (type == CompareResultInfo.CompareResultType.e_CompareResultTypeDeleteText)
  43. {
  44. String res_string = String.Format(""{0}"", item.diff_contents);
  45.  
  46. // Add stamp to mark the "delete" type differences between the two documents.
  47. CreateDeleteTextStamp(page, item.rect_array, 0xff0000, res_string, "Compare : Delete", "Text");
  48. }
  49. else if (type == CompareResultInfo.CompareResultType.e_CompareResultTypeInsertText)
  50. {
  51. String res_string = String.Format(""{0}"", item.diff_contents);
  52.  
  53. // Highlight the "insert" type differences between the two documents.
  54. CreateHighlightRect(page, item.rect_array, 0x0000ff, res_string, "Compare : Insert", "Text");
  55. }
  56. else if (type == CompareResultInfo.CompareResultType.e_CompareResultTypeReplaceText)
  57. {
  58. String res_string = String.Format("[Old]: "{0}"rn[New]: "{1}"", oldInfo.GetAt(i).diff_contents, item.diff_contents);
  59.  
  60. // Highlight the "replace" type differences between the two documents.
  61. CreateHighlightRect(page, item.rect_array, 0xe7651a, res_string, "Compare : Replace", "Text");
  62. }
  63. }
  64. }
  65.  
  66. // Save the comparison result to a PDF file.
  67. compared_doc.SaveAs(output_path + "result.pdf", (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement