-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCFileMark.cs
62 lines (56 loc) · 1.61 KB
/
CFileMark.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PDFXEdit;
using System.Runtime.InteropServices;
using System.Windows;
namespace WpfSimpleApp
{
class CFileMark
{
private IPXV_Inst Inst = null;
private IPXC_Document Doc = null;
public CFileMark(IPXV_Inst inst, IPXC_Document doc)
{
this.Inst = inst;
this.Doc = doc;
}
public void SaveFile(string fileName)
{
try
{
Doc.WriteToFile(fileName, null, 0);
System.Diagnostics.Process openProcess = new System.Diagnostics.Process();
openProcess.StartInfo.FileName = fileName;
openProcess.StartInfo.UseShellExecute = true;
openProcess.StartInfo.CreateNoWindow = true;
openProcess.StartInfo.Verb = "open";
openProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
openProcess.Start();
openProcess.WaitForExit();
}
catch (COMException e)
{
MessageBox.Show(string.Format("Document has been saved to '{0}'. {1}", fileName, e.Message));
};
}
public void Run()
{
int nID = Inst.Str2ID("op.search", false);
PDFXEdit.IOperation pOp = Inst.CreateOp(nID);
PDFXEdit.ICabNode input = pOp.Params.Root["Input"];
input.Add().v = Doc;
PDFXEdit.ICabNode options = pOp.Params.Root["Options"];
options["StartPage"].v = 0;
options["StopPage"].v = Doc.Pages.Count;
int nFlags = (int)PXV_SearchFlags.PXV_SearchFlag_IncludeBookmarks;
options["Flags"].v = nFlags;
PDFXEdit.ICabNode arrAnd = options["AND"];
arrAnd.Add().v = "the";
options["Callback"].v = new SearchCbBridge();
pOp.Do();
}
}
}