PDFTextEditControl.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKit.PDFPage;
  3. using ComPDFKit.PDFPage.Edit;
  4. using ComPDFKit.Tool;
  5. using ComPDFKit.Tool.SettingParam;
  6. using ComPDFKit.Tool.UndoManger;
  7. using ComPDFKit.Viewer.Helper;
  8. using Compdfkit_Tools.PDFControl;
  9. using ComPDFKitViewer;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.Windows.Controls.Primitives;
  15. using System.Windows.Media;
  16. namespace Compdfkit_Tools.Edit
  17. {
  18. public partial class PDFTextEditControl : UserControl
  19. {
  20. public CPDFViewerTool ToolView { get; private set; }
  21. public TextEditParam EditEvent { get; set; }
  22. //public List<PDFEditEvent> EditMultiEvents { get; set; }
  23. public PDFTextEditControl()
  24. {
  25. InitializeComponent();
  26. Loaded += PDFTextEditControl_Loaded;
  27. }
  28. public void InitWithPDFViewer(CPDFViewerTool newPDFView)
  29. {
  30. ToolView = newPDFView;
  31. }
  32. public void SetPDFTextEditData(TextEditParam newEvent)
  33. {
  34. if (newEvent.EditIndex<0)
  35. {
  36. EditEvent = null;
  37. }
  38. else
  39. {
  40. EditEvent = newEvent;
  41. }
  42. if (newEvent != null && newEvent.EditType == CPDFEditType.EditText)
  43. {
  44. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  45. List<string> sysfontList = new List<string>();
  46. if (textArea != null)
  47. {
  48. sysfontList = textArea.GetFontList();
  49. }
  50. if (sysfontList.Count == 0)
  51. {
  52. sysfontList.Add("Helvetica");
  53. sysfontList.Add("Courier New");
  54. sysfontList.Add("Times New Roman");
  55. }
  56. if (sysfontList.Contains(newEvent.FontName) == false && string.IsNullOrEmpty(newEvent.FontName) == false)
  57. {
  58. sysfontList.Add(newEvent.FontName);
  59. }
  60. TextStyleUI.SetFontNames(sysfontList);
  61. TextStyleUI.SelectFontName(newEvent.FontName);
  62. TextStyleUI.SetFontStyle(newEvent.IsBold, newEvent.IsItalic);
  63. TextStyleUI.SetFontSize(newEvent.FontSize);
  64. OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Ceiling(newEvent.Transparency * 100 / 255D)));
  65. FontOpacitySlider.Value = ((int)(Math.Ceiling(newEvent.Transparency * 100 / 255D))) / 100D;
  66. TextAlignUI.SetFontAlign(newEvent.TextAlign);
  67. if (newEvent.FontColor != null && newEvent.FontColor.Length == 3)
  68. {
  69. FontColorUI.SetCheckedForColor(Color.FromRgb(
  70. newEvent.FontColor[0],
  71. newEvent.FontColor[1],
  72. newEvent.FontColor[2]));
  73. }
  74. }
  75. EditEvent = newEvent;
  76. }
  77. //public void SetPDFTextMultiEditData(List<PDFEditEvent> editEvents)
  78. //{
  79. // EditEvent = null;
  80. // EditMultiEvents = null;
  81. // if(editEvents!=null && editEvents.Count>0)
  82. // {
  83. // PDFEditEvent editEvent= editEvents[0];
  84. // if (editEvent != null && editEvent.EditType == CPDFEditType.EditText)
  85. // {
  86. // if (editEvent.SystemFontNameList != null && editEvent.SystemFontNameList.Count == 0)
  87. // {
  88. // editEvent.SystemFontNameList.Add("Helvetica");
  89. // editEvent.SystemFontNameList.Add("Courier New");
  90. // editEvent.SystemFontNameList.Add("Times New Roman");
  91. // }
  92. // if (editEvent.SystemFontNameList.Contains(editEvent.FontName) == false && string.IsNullOrEmpty(editEvent.FontName) == false)
  93. // {
  94. // editEvent.SystemFontNameList.Add(editEvent.FontName);
  95. // }
  96. // TextStyleUI.SetFontNames(editEvent.SystemFontNameList);
  97. // TextStyleUI.SelectFontName(editEvent.FontName);
  98. // TextStyleUI.SetFontStyle(editEvent.IsBold, editEvent.IsItalic);
  99. // TextStyleUI.SetFontSize(editEvent.FontSize);
  100. // OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Ceiling(editEvent.Transparency * 100 / 255D)));
  101. // FontOpacitySlider.Value = ((int)(Math.Ceiling(editEvent.Transparency * 100 / 255D))) / 100D;
  102. // TextAlignUI.SetFontAlign(editEvent.TextAlign);
  103. // FontColorUI.SetCheckedForColor(editEvent.FontColor);
  104. // }
  105. // }
  106. // EditMultiEvents=editEvents;
  107. //}
  108. private void Slider_DragCompleted(object sender, DragCompletedEventArgs e)
  109. {
  110. Slider slider = sender as Slider;
  111. if (slider != null)
  112. {
  113. slider.Tag = "true";
  114. }
  115. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  116. if (textArea != null)
  117. {
  118. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  119. if (textArea.SetCharsFontSize((float)slider.Value, false))
  120. {
  121. PDFEditHistory editHistory = new PDFEditHistory();
  122. editHistory.EditPage = editPage;
  123. if (pdfPage != null)
  124. {
  125. editHistory.PageIndex = pdfPage.PageIndex;
  126. }
  127. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  128. ToolView.UpDateRender(oldRect, textArea);
  129. editPage.EndEdit();
  130. }
  131. }
  132. if (EditEvent != null && textArea == null)
  133. {
  134. EditEvent.FontSize = slider.Value;
  135. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  136. defaultSettingParam.SetPDFEditParamm(EditEvent);
  137. }
  138. //if (EditMultiEvents != null)
  139. //{
  140. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  141. // {
  142. // editEvent.FontSize = slider.Value;
  143. // }
  144. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  145. //}
  146. }
  147. private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e)
  148. {
  149. Slider slider = sender as Slider;
  150. if (slider != null)
  151. {
  152. slider.Tag = "true";
  153. }
  154. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  155. if (textArea != null)
  156. {
  157. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  158. if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
  159. {
  160. PDFEditHistory editHistory = new PDFEditHistory();
  161. editHistory.EditPage = editPage;
  162. if (pdfPage != null)
  163. {
  164. editHistory.PageIndex = pdfPage.PageIndex;
  165. }
  166. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  167. ToolView.UpDateRender(oldRect, textArea);
  168. editPage.EndEdit();
  169. }
  170. }
  171. if (EditEvent != null && textArea == null)
  172. {
  173. EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
  174. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  175. defaultSettingParam.SetPDFEditParamm(EditEvent);
  176. }
  177. }
  178. private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
  179. {
  180. Slider slider = sender as Slider;
  181. if (OpacityTextBox != null && FontOpacitySlider != null)
  182. {
  183. OpacityTextBox.Text = string.Format("{0}%", (int)(FontOpacitySlider.Value * 100));
  184. }
  185. if (slider != null && slider.Tag != null && slider.Tag.ToString() == "false")
  186. {
  187. return;
  188. }
  189. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  190. if (textArea != null)
  191. {
  192. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  193. if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
  194. {
  195. PDFEditHistory editHistory = new PDFEditHistory();
  196. editHistory.EditPage = editPage;
  197. if (pdfPage != null)
  198. {
  199. editHistory.PageIndex = pdfPage.PageIndex;
  200. }
  201. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  202. ToolView.UpDateRender(oldRect, textArea);
  203. editPage.EndEdit();
  204. }
  205. }
  206. if (EditEvent != null && textArea == null)
  207. {
  208. EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
  209. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  210. defaultSettingParam.SetPDFEditParamm(EditEvent);
  211. }
  212. }
  213. private void Slider_DragStarted(object sender, DragStartedEventArgs e)
  214. {
  215. Slider slider = sender as Slider;
  216. if (slider != null)
  217. {
  218. slider.Tag = "false";
  219. }
  220. }
  221. private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
  222. {
  223. Slider slider = sender as Slider;
  224. if (slider != null && slider.Tag != null && slider.Tag.ToString() == "false")
  225. {
  226. return;
  227. }
  228. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  229. if (textArea != null)
  230. {
  231. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  232. if (textArea.SetCharsFontSize((float)slider.Value, false))
  233. {
  234. PDFEditHistory editHistory = new PDFEditHistory();
  235. editHistory.EditPage = editPage;
  236. if (pdfPage != null)
  237. {
  238. editHistory.PageIndex = pdfPage.PageIndex;
  239. }
  240. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  241. ToolView.UpDateRender(oldRect, textArea);
  242. editPage.EndEdit();
  243. }
  244. }
  245. if (EditEvent != null && textArea == null)
  246. {
  247. EditEvent.FontSize = slider.Value;
  248. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  249. defaultSettingParam.SetPDFEditParamm(EditEvent);
  250. }
  251. //if (EditMultiEvents != null)
  252. //{
  253. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  254. // {
  255. // editEvent.FontSize = slider.Value;
  256. // }
  257. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  258. //}
  259. }
  260. private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e)
  261. {
  262. TextStyleUI.TextFontChanged -= TextStyleUI_TextFontChanged;
  263. TextStyleUI.TextBoldChanged -= TextStyleUI_TextBoldChanged;
  264. TextStyleUI.TextItalicChanged -= TextStyleUI_TextItalicChanged;
  265. TextStyleUI.TextSizeChanged -= TextStyleUI_TextSizeChanged;
  266. TextAlignUI.TextAlignChanged -= TextAlignUI_TextAlignChanged;
  267. FontColorUI.ColorChanged -= FontColorUI_ColorChanged;
  268. TextStyleUI.TextFontChanged += TextStyleUI_TextFontChanged;
  269. TextStyleUI.TextBoldChanged += TextStyleUI_TextBoldChanged;
  270. TextStyleUI.TextItalicChanged += TextStyleUI_TextItalicChanged;
  271. TextStyleUI.TextSizeChanged += TextStyleUI_TextSizeChanged;
  272. TextAlignUI.TextAlignChanged += TextAlignUI_TextAlignChanged;
  273. FontColorUI.ColorChanged += FontColorUI_ColorChanged;
  274. }
  275. private void TextStyleUI_TextSizeChanged(object sender, double e)
  276. {
  277. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  278. if (textArea != null)
  279. {
  280. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  281. if (textArea.SetCharsFontSize((float)e, false))
  282. {
  283. PDFEditHistory editHistory = new PDFEditHistory();
  284. editHistory.EditPage = editPage;
  285. if (pdfPage != null)
  286. {
  287. editHistory.PageIndex = pdfPage.PageIndex;
  288. }
  289. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  290. ToolView.UpDateRender(oldRect, textArea);
  291. editPage.EndEdit();
  292. }
  293. }
  294. if (EditEvent != null && textArea == null)
  295. {
  296. EditEvent.FontSize = e;
  297. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  298. defaultSettingParam.SetPDFEditParamm(EditEvent);
  299. }
  300. //if (EditMultiEvents != null)
  301. //{
  302. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  303. // {
  304. // editEvent.FontSize = e;
  305. // }
  306. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  307. //}
  308. }
  309. private void FontColorUI_ColorChanged(object sender, EventArgs e)
  310. {
  311. SolidColorBrush newBrush = FontColorUI.Brush as SolidColorBrush;
  312. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  313. if (textArea != null && newBrush != null)
  314. {
  315. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  316. if (textArea.SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B))
  317. {
  318. PDFEditHistory editHistory = new PDFEditHistory();
  319. editHistory.EditPage = editPage;
  320. if (pdfPage != null)
  321. {
  322. editHistory.PageIndex = pdfPage.PageIndex;
  323. }
  324. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  325. ToolView.UpDateRender(oldRect, textArea);
  326. editPage.EndEdit();
  327. }
  328. }
  329. if (EditEvent != null && textArea == null && newBrush != null)
  330. {
  331. byte[] Color = new byte[3];
  332. Color[0] = newBrush.Color.R;
  333. Color[1] = newBrush.Color.G;
  334. Color[2] = newBrush.Color.B;
  335. EditEvent.FontColor = Color;
  336. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  337. defaultSettingParam.SetPDFEditParamm(EditEvent);
  338. }
  339. }
  340. private void TextAlignUI_TextAlignChanged(object sender, TextAlignType e)
  341. {
  342. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  343. if (textArea != null)
  344. {
  345. bool result = false;
  346. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  347. if (textArea.SelectLineRects != null && textArea.SelectLineRects.Count > 0)
  348. {
  349. result = textArea.SetTextRangeAlign(e);
  350. }
  351. else
  352. {
  353. result = textArea.SetTextAreaAlign(e);
  354. }
  355. if (result)
  356. {
  357. PDFEditHistory editHistory = new PDFEditHistory();
  358. editHistory.EditPage = editPage;
  359. if (pdfPage != null)
  360. {
  361. editHistory.PageIndex = pdfPage.PageIndex;
  362. }
  363. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  364. ToolView.UpDateRender(oldRect, textArea);
  365. editPage.EndEdit();
  366. }
  367. }
  368. if (EditEvent != null && textArea == null)
  369. {
  370. EditEvent.TextAlign = e;
  371. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  372. defaultSettingParam.SetPDFEditParamm(EditEvent);
  373. }
  374. //if (EditMultiEvents != null)
  375. //{
  376. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  377. // {
  378. // editEvent.TextAlign = e;
  379. // }
  380. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  381. //}
  382. }
  383. private void TextStyleUI_TextItalicChanged(object sender, bool e)
  384. {
  385. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  386. if (textArea != null)
  387. {
  388. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  389. if (textArea.SetCharsFontItalic(e))
  390. {
  391. PDFEditHistory editHistory = new PDFEditHistory();
  392. editHistory.EditPage = editPage;
  393. if (pdfPage != null)
  394. {
  395. editHistory.PageIndex = pdfPage.PageIndex;
  396. }
  397. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  398. ToolView.UpDateRender(oldRect, textArea);
  399. editPage.EndEdit();
  400. }
  401. }
  402. if (EditEvent != null && textArea == null)
  403. {
  404. EditEvent.IsItalic = e;
  405. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  406. defaultSettingParam.SetPDFEditParamm(EditEvent);
  407. }
  408. //if (EditMultiEvents != null)
  409. //{
  410. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  411. // {
  412. // editEvent.IsItalic = e;
  413. // }
  414. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  415. //}
  416. }
  417. private void TextStyleUI_TextBoldChanged(object sender, bool e)
  418. {
  419. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  420. if (textArea != null)
  421. {
  422. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  423. if (textArea.SetCharsFontBold(e))
  424. {
  425. PDFEditHistory editHistory = new PDFEditHistory();
  426. editHistory.EditPage = editPage;
  427. if (pdfPage != null)
  428. {
  429. editHistory.PageIndex = pdfPage.PageIndex;
  430. }
  431. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  432. ToolView.UpDateRender(oldRect, textArea);
  433. editPage.EndEdit();
  434. }
  435. }
  436. if (EditEvent != null && textArea == null)
  437. {
  438. EditEvent.IsBold = e;
  439. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  440. defaultSettingParam.SetPDFEditParamm(EditEvent);
  441. }
  442. //if (EditMultiEvents != null)
  443. //{
  444. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  445. // {
  446. // editEvent.IsBold = e;
  447. // }
  448. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  449. //}
  450. }
  451. private void TextStyleUI_TextFontChanged(object sender, string e)
  452. {
  453. GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
  454. if (textArea != null)
  455. {
  456. Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
  457. if (textArea.SetCharsFontName(e))
  458. {
  459. PDFEditHistory editHistory = new PDFEditHistory();
  460. editHistory.EditPage = editPage;
  461. if (pdfPage != null)
  462. {
  463. editHistory.PageIndex = pdfPage.PageIndex;
  464. }
  465. ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
  466. ToolView.UpDateRender(oldRect, textArea);
  467. editPage.EndEdit();
  468. }
  469. }
  470. if (EditEvent != null && textArea == null)
  471. {
  472. EditEvent.FontName = e;
  473. DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
  474. defaultSettingParam.SetPDFEditParamm(EditEvent);
  475. }
  476. //if (EditMultiEvents != null)
  477. //{
  478. // foreach (PDFEditEvent editEvent in EditMultiEvents)
  479. // {
  480. // editEvent.FontName = e;
  481. // }
  482. // PDFEditEvent.UpdatePDFEditList(EditMultiEvents);
  483. //}
  484. }
  485. private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  486. {
  487. ComboBoxItem selectItem = OpacityComboBox.SelectedItem as ComboBoxItem;
  488. if (selectItem != null && selectItem.Content != null)
  489. {
  490. if (double.TryParse(selectItem.Content.ToString().TrimEnd('%'), out double newOpacity))
  491. {
  492. OpacityTextBox.Text = selectItem.Content.ToString();
  493. FontOpacitySlider.Value = newOpacity / 100.0;
  494. }
  495. }
  496. }
  497. private void GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage)
  498. {
  499. textArea = null;
  500. editPage = null;
  501. pdfPage = null;
  502. if (ToolView == null)
  503. {
  504. return;
  505. }
  506. if (EditEvent != null)
  507. {
  508. try
  509. {
  510. CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
  511. CPDFDocument pdfDoc = pdfViewer.GetDocument();
  512. pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex);
  513. editPage = pdfPage.GetEditPage();
  514. List<CPDFEditArea> editAreas = editPage.GetEditAreaList();
  515. if (editAreas != null && editAreas.Count > EditEvent.EditIndex)
  516. {
  517. textArea = editAreas[EditEvent.EditIndex] as CPDFEditTextArea;
  518. }
  519. }
  520. catch (Exception ex)
  521. {
  522. }
  523. }
  524. else
  525. {
  526. CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
  527. CPDFDocument pdfDoc = pdfViewer.GetDocument();
  528. pdfPage = pdfDoc.PageAtIndex(0);
  529. editPage = pdfPage.GetEditPage();
  530. editPage.BeginEdit(CPDFEditType.EditText);
  531. editPage.EndEdit();
  532. }
  533. }
  534. }
  535. }