개정판 79f3f21a
issue #781 text search modify
KCOM/Controls/SearchPanel.xaml.cs | ||
---|---|---|
31 | 31 |
string RegistrationKey = "193B-FD48-42F4-68E6-2D35-4C94-D07"; |
32 | 32 |
string RegistrationName = "license@doftech.co.kr"; |
33 | 33 |
Bytescout.PDFExtractor.TextExtractor extractor; |
34 |
|
|
34 |
Bytescout.PDFExtractor.OCRAnalyzer ocrAnalyzer; |
|
35 | 35 |
public SearchPanel() |
36 | 36 |
{ |
37 |
//InitializeComponent(); |
|
38 |
this.Loaded += SearchPanel_Loaded; |
|
37 |
InitializeComponent(); |
|
38 |
LibInit(); |
|
39 |
//this.Loaded += SearchPanel_Loaded; |
|
40 |
btnSearch.Click += BtnSearch_Click; |
|
41 |
btnSearchPDFDownload.Click += BtnSearchPDFDownload_Click; |
|
42 |
SearchSet = new System.Collections.ObjectModel.ObservableCollection<SearchText>(); |
|
39 | 43 |
|
44 |
tbSearch.KeyDown += tbSearch_KeyDown; |
|
45 |
this.DataContext = this; |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
/* |
|
50 |
if (Common.ViewerDataModel.Instance.searchPDF ==null) |
|
51 |
{ |
|
52 |
|
|
53 |
} |
|
54 |
else |
|
55 |
{ |
|
56 |
border_Overlap.Visibility = Visibility.Collapsed; |
|
57 |
tbSearch.Focus(); |
|
58 |
|
|
59 |
} |
|
60 |
*/ |
|
61 |
|
|
62 |
if (Common.ViewerDataModel.Instance.searchPDF != null) |
|
63 |
{ |
|
64 |
border_Overlap.Visibility = Visibility.Collapsed; |
|
65 |
tbSearch.Focus(); |
|
66 |
} |
|
40 | 67 |
} |
41 | 68 |
|
42 | 69 |
private void tbSearch_KeyDown(object sender, KeyEventArgs e) |
... | ... | |
46 | 73 |
SearchMethod(); |
47 | 74 |
} |
48 | 75 |
} |
76 |
private void LibInit() |
|
77 |
{ |
|
78 |
extractor = new Bytescout.PDFExtractor.TextExtractor(RegistrationName, RegistrationKey); |
|
79 |
ocrAnalyzer = new Bytescout.PDFExtractor.OCRAnalyzer(RegistrationName, RegistrationKey); |
|
80 |
extractor.OCRMode = Bytescout.PDFExtractor.OCRMode.Auto; |
|
81 |
extractor.OCRLanguage = "eng"; |
|
82 |
extractor.OCRLanguageDataFolder = System.AppDomain.CurrentDomain.BaseDirectory + "\\tessdata\\"; |
|
83 |
extractor.OCRResolution = 300; |
|
84 |
|
|
85 |
ocrAnalyzer.OCRLanguage = "eng"; |
|
86 |
ocrAnalyzer.OCRLanguageDataFolder = System.AppDomain.CurrentDomain.BaseDirectory + "\\tessdata\\"; |
|
49 | 87 |
|
88 |
} |
|
50 | 89 |
private void SearchPanel_Loaded(object sender, RoutedEventArgs e) |
51 | 90 |
{ |
52 | 91 |
//측정 |
... | ... | |
54 | 93 |
//sw.Start(); |
55 | 94 |
InitializeComponent(); |
56 | 95 |
//System.Diagnostics.Debug.WriteLine("SearchPanel() : " + sw.ElapsedMilliseconds.ToString() + "ms"); |
57 |
|
|
96 |
|
|
58 | 97 |
btnSearch.Click += BtnSearch_Click; |
59 | 98 |
btnSearchPDFDownload.Click += BtnSearchPDFDownload_Click; |
60 | 99 |
SearchSet = new System.Collections.ObjectModel.ObservableCollection<SearchText>(); |
61 | 100 |
extractor = new Bytescout.PDFExtractor.TextExtractor(RegistrationName, RegistrationKey); |
62 | 101 |
tbSearch.KeyDown += tbSearch_KeyDown; |
63 | 102 |
this.DataContext = this; |
64 |
|
|
103 |
|
|
65 | 104 |
/* |
66 | 105 |
if (Common.ViewerDataModel.Instance.searchPDF ==null) |
67 | 106 |
{ |
... | ... | |
110 | 149 |
{ |
111 | 150 |
SearchMethod(); |
112 | 151 |
} |
113 |
|
|
152 |
|
|
114 | 153 |
private void SearchMethod() |
115 | 154 |
{ |
116 |
extractor.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
|
155 |
|
|
117 | 156 |
SearchSet.Clear(); |
118 | 157 |
string searchString = tbSearch.Text; |
119 |
int pageCount = extractor.GetPageCount(); |
|
158 |
extractor.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
|
159 |
ocrAnalyzer.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
|
120 | 160 |
|
121 | 161 |
if (chkCurrentPageOnly.IsChecked.Value) |
122 | 162 |
{ |
123 | 163 |
var currentPage = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber - 1; |
164 |
|
|
165 |
Bytescout.PDFExtractor.OCRAnalysisResults analysisResults = ocrAnalyzer.AnalyzeByOCRConfidence(currentPage); |
|
166 |
ocrAnalyzer.ApplyResults(analysisResults, extractor); |
|
167 |
|
|
124 | 168 |
if (extractor.Find(currentPage, searchString, false)) |
125 | 169 |
do |
126 | 170 |
{ |
... | ... | |
130 | 174 |
} |
131 | 175 |
else |
132 | 176 |
{ |
177 |
int pageCount = extractor.GetPageCount(); |
|
133 | 178 |
for (int i = 0; i < pageCount; i++) |
134 | 179 |
{ |
180 |
Bytescout.PDFExtractor.OCRAnalysisResults analysisResults = ocrAnalyzer.AnalyzeByOCRConfidence(i); |
|
181 |
ocrAnalyzer.ApplyResults(analysisResults, extractor); |
|
135 | 182 |
if (extractor.Find(i, searchString, false)) |
136 | 183 |
do |
137 | 184 |
{ |
내보내기 Unified diff