PDFTextEditControl.xaml.cs 24 KB

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