ParamConverter.cs 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275
  1. using ComPDFKit.Import;
  2. using ComPDFKit.Measure;
  3. using ComPDFKit.PDFAnnotation;
  4. using ComPDFKit.PDFAnnotation.Form;
  5. using ComPDFKit.PDFDocument;
  6. using ComPDFKit.PDFDocument.Action;
  7. using ComPDFKit.PDFPage;
  8. using ComPDFKit.PDFPage.Edit;
  9. using ComPDFKit.Tool.SettingParam;
  10. using ComPDFKit.Tool.UndoManger;
  11. using ComPDFKit.Viewer.Helper;
  12. using ComPDFKitViewer.Helper;
  13. using ComPDFKitViewer;
  14. using System.Collections.Generic;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Windows;
  18. using System.Windows.Media;
  19. using System.Windows.Media.Imaging;
  20. using static ComPDFKit.PDFAnnotation.CTextAttribute;
  21. using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
  22. namespace ComPDFKit.Tool.Help
  23. {
  24. /// <summary>
  25. /// Some quick conversion tools for parameters
  26. /// </summary>
  27. public static class ParamConverter
  28. {
  29. public enum FormField
  30. {
  31. /// <summary>
  32. /// Visible
  33. /// </summary>
  34. Visible,
  35. /// <summary>
  36. /// Hidden
  37. /// </summary>
  38. Hidden,
  39. /// <summary>
  40. /// Visible but unprintable
  41. /// </summary>
  42. VisibleNoPrint,
  43. /// <summary>
  44. /// Hidden but printable
  45. /// </summary>
  46. HiddenPrintable
  47. }
  48. public static AnnotHistory CreateHistory(CPDFAnnotation cPDFAnnotation)
  49. {
  50. AnnotHistory annotHistory = null;
  51. switch (cPDFAnnotation.Type)
  52. {
  53. case C_ANNOTATION_TYPE.C_ANNOTATION_NONE:
  54. break;
  55. case C_ANNOTATION_TYPE.C_ANNOTATION_UNKOWN:
  56. break;
  57. case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  58. annotHistory = new StickyNoteAnnotHistory();
  59. break;
  60. case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  61. annotHistory = new LinkAnnotHistory();
  62. break;
  63. case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  64. annotHistory = new FreeTextAnnotHistory();
  65. break;
  66. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  67. if ((cPDFAnnotation as CPDFLineAnnotation).IsMeasured())
  68. {
  69. annotHistory = new LineMeasureAnnotHistory();
  70. }
  71. else
  72. {
  73. annotHistory = new LineAnnotHistory();
  74. }
  75. break;
  76. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  77. annotHistory = new SquareAnnotHistory();
  78. break;
  79. case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  80. annotHistory = new CircleAnnotHistory();
  81. break;
  82. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
  83. annotHistory = new PolygonMeasureAnnotHistory();
  84. break;
  85. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
  86. annotHistory = new PolyLineMeasureAnnotHistory();
  87. break;
  88. case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  89. annotHistory = new HighlightAnnotHistory();
  90. break;
  91. case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  92. annotHistory = new UnderlineAnnotHistory();
  93. break;
  94. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  95. annotHistory = new SquigglyAnnotHistory();
  96. break;
  97. case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  98. annotHistory = new StrikeoutAnnotHistory();
  99. break;
  100. case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  101. annotHistory = new StampAnnotHistory();
  102. break;
  103. case C_ANNOTATION_TYPE.C_ANNOTATION_CARET:
  104. break;
  105. case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  106. annotHistory = new InkAnnotHistory();
  107. break;
  108. case C_ANNOTATION_TYPE.C_ANNOTATION_POPUP:
  109. break;
  110. case C_ANNOTATION_TYPE.C_ANNOTATION_FILEATTACHMENT:
  111. break;
  112. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  113. annotHistory = new SoundAnnotHistory();
  114. break;
  115. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  116. break;
  117. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  118. switch ((cPDFAnnotation as CPDFWidget).WidgetType)
  119. {
  120. case C_WIDGET_TYPE.WIDGET_NONE:
  121. break;
  122. case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  123. annotHistory = new PushButtonHistory();
  124. break;
  125. case C_WIDGET_TYPE.WIDGET_CHECKBOX:
  126. annotHistory = new CheckBoxHistory();
  127. break;
  128. case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  129. annotHistory = new RadioButtonHistory();
  130. break;
  131. case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  132. annotHistory = new TextBoxHistory();
  133. break;
  134. case C_WIDGET_TYPE.WIDGET_COMBOBOX:
  135. annotHistory = new ComboBoxHistory();
  136. break;
  137. case C_WIDGET_TYPE.WIDGET_LISTBOX:
  138. annotHistory = new ListBoxHistory();
  139. break;
  140. case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  141. annotHistory = new SignatureHistory();
  142. break;
  143. case C_WIDGET_TYPE.WIDGET_UNKNOWN:
  144. break;
  145. default:
  146. break;
  147. }
  148. break;
  149. case C_ANNOTATION_TYPE.C_ANNOTATION_SCREEN:
  150. break;
  151. case C_ANNOTATION_TYPE.C_ANNOTATION_PRINTERMARK:
  152. break;
  153. case C_ANNOTATION_TYPE.C_ANNOTATION_TRAPNET:
  154. break;
  155. case C_ANNOTATION_TYPE.C_ANNOTATION_WATERMARK:
  156. break;
  157. case C_ANNOTATION_TYPE.C_ANNOTATION_3D:
  158. break;
  159. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  160. break;
  161. case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
  162. annotHistory = new RedactAnnotHistory();
  163. break;
  164. case C_ANNOTATION_TYPE.C_ANNOTATION_INTERCHANGE:
  165. break;
  166. default:
  167. break;
  168. }
  169. return annotHistory;
  170. }
  171. public static AnnotHistory CreateHistory(AnnotParam annotParam)
  172. {
  173. if (annotParam != null)
  174. {
  175. switch (annotParam.CurrentType)
  176. {
  177. case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  178. return new HighlightAnnotHistory();
  179. case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  180. return new UnderlineAnnotHistory();
  181. case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  182. return new StrikeoutAnnotHistory();
  183. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  184. return new SquigglyAnnotHistory();
  185. case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  186. return new InkAnnotHistory();
  187. case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  188. return new FreeTextAnnotHistory();
  189. case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  190. return new StickyNoteAnnotHistory();
  191. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  192. return new SquareAnnotHistory();
  193. case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  194. return new CircleAnnotHistory();
  195. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  196. return new LineAnnotHistory();
  197. case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  198. return new LinkAnnotHistory();
  199. case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  200. return new StampAnnotHistory();
  201. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  202. {
  203. WidgetParm widgetParam = annotParam as WidgetParm;
  204. if (widgetParam != null)
  205. {
  206. switch (widgetParam.WidgetType)
  207. {
  208. case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  209. return new RadioButtonHistory();
  210. case C_WIDGET_TYPE.WIDGET_CHECKBOX:
  211. return new CheckBoxHistory();
  212. case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  213. return new TextBoxHistory();
  214. case C_WIDGET_TYPE.WIDGET_LISTBOX:
  215. return new ListBoxHistory();
  216. case C_WIDGET_TYPE.WIDGET_COMBOBOX:
  217. return new ComboBoxHistory();
  218. case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  219. return new PushButtonHistory();
  220. default:
  221. break;
  222. }
  223. }
  224. }
  225. break;
  226. default:
  227. break;
  228. }
  229. }
  230. return new AnnotHistory();
  231. }
  232. public static bool RemovePageAnnot(Dictionary<int, List<int>> removeAnnots, CPDFViewer cPDFViewer)
  233. {
  234. CPDFDocument cPDFDocument = cPDFViewer.GetDocument();
  235. if (cPDFDocument == null || removeAnnots.Count <= 0)
  236. {
  237. return false;
  238. }
  239. GroupHistory historyGroup = new GroupHistory();
  240. foreach (int pageIndex in removeAnnots.Keys)
  241. {
  242. CPDFPage pageCore = cPDFDocument.PageAtIndex(pageIndex);
  243. List<CPDFAnnotation> cPDFAnnotations = pageCore.GetAnnotations();
  244. foreach (int annotIndex in removeAnnots[pageIndex])
  245. {
  246. CPDFAnnotation cPDFAnnotation = cPDFAnnotations.ElementAtOrDefault(annotIndex);
  247. if (cPDFAnnotation != null)
  248. {
  249. AnnotParam annotParam = CPDFDataConverterToAnnotParam(cPDFDocument, pageIndex, cPDFAnnotation);
  250. AnnotHistory annotHistory = CreateHistory(cPDFAnnotation);
  251. annotHistory.CurrentParam = annotParam;
  252. annotHistory.PDFDoc = cPDFDocument;
  253. annotHistory.Action = HistoryAction.Remove;
  254. historyGroup.Histories.Add(annotHistory);
  255. }
  256. }
  257. }
  258. if (historyGroup.Histories.Count > 0)
  259. {
  260. cPDFViewer.UndoManager.AddHistory(historyGroup);
  261. }
  262. foreach (int pageIndex in removeAnnots.Keys)
  263. {
  264. CPDFPage pageCore = cPDFDocument.PageAtIndex(pageIndex);
  265. List<CPDFAnnotation> cPDFAnnotations = pageCore.GetAnnotations();
  266. foreach (int annotIndex in removeAnnots[pageIndex])
  267. {
  268. CPDFAnnotation cPDFAnnotation = cPDFAnnotations.ElementAtOrDefault(annotIndex);
  269. if (cPDFAnnotation != null)
  270. {
  271. cPDFAnnotation.RemoveAnnot();
  272. }
  273. }
  274. }
  275. return true;
  276. }
  277. public static FormField ConverterWidgetFormFlags(int Flags, bool IsHidden)
  278. {
  279. int flag = Flags;
  280. bool invisible = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible) != 0;
  281. bool noview = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView) != 0;
  282. bool print = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint) != 0;
  283. if (noview && print)
  284. {
  285. return FormField.HiddenPrintable;
  286. }
  287. if (IsHidden || noview || invisible)
  288. {
  289. return FormField.Hidden;
  290. }
  291. bool visibleflag = !IsHidden && !invisible && !noview && !print;
  292. if (visibleflag)
  293. {
  294. return FormField.VisibleNoPrint;
  295. }
  296. return FormField.Visible;
  297. }
  298. public static int GetFormFlags(FormField field, CPDFWidget widget)
  299. {
  300. int flag = widget.GetFlags();
  301. switch (field)
  302. {
  303. case FormField.Hidden:
  304. widget.SetIsHidden(true);
  305. flag = widget.GetFlags();
  306. break;
  307. case FormField.Visible:
  308. {
  309. int newflag = (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagHidden
  310. | (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible;
  311. flag &= ~newflag;
  312. flag |= (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint;
  313. }
  314. break;
  315. case FormField.VisibleNoPrint:
  316. {
  317. int newflag = (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint |
  318. (int)CPDFAnnotationFlags.CPDFAnnotationFlagHidden | (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible;
  319. flag &= ~newflag;
  320. }
  321. break;
  322. case FormField.HiddenPrintable:
  323. {
  324. flag = flag | (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint;
  325. }
  326. break;
  327. default:
  328. break;
  329. }
  330. return flag;
  331. }
  332. public static Color ConverterByteForColor(byte[] bytes)
  333. {
  334. if (bytes != null && bytes.Length == 3)
  335. {
  336. return new Color { R = bytes[0], G = bytes[1], B = bytes[2], A = 255};
  337. }
  338. return new Color { R = 0, G = 0, B = 0, A = 0 };
  339. }
  340. public static void ParseDashStyle(DashStyle dashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle)
  341. {
  342. if (dashStyle == DashStyles.Solid || dashStyle == null)
  343. {
  344. LineDash = new float[0];
  345. BorderStyle = C_BORDER_STYLE.BS_SOLID;
  346. }
  347. else
  348. {
  349. List<float> floatArray = new List<float>();
  350. foreach (double num in dashStyle.Dashes)
  351. {
  352. floatArray.Add((float)num);
  353. }
  354. LineDash = floatArray.ToArray();
  355. BorderStyle = C_BORDER_STYLE.BS_DASHDED;
  356. }
  357. }
  358. public static AnnotParam CPDFDataConverterToAnnotParam(CPDFDocument cPDFDocument, int PageIndex, CPDFAnnotation cPDFAnnotation)
  359. {
  360. if (cPDFAnnotation == null && !cPDFAnnotation.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid())
  361. {
  362. return null;
  363. }
  364. AnnotParam annotParam = null;
  365. if (cPDFAnnotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
  366. {
  367. annotParam = WidgetConverter(cPDFDocument, cPDFAnnotation);
  368. }
  369. else
  370. {
  371. annotParam = AnnotConverter(cPDFDocument, cPDFAnnotation);
  372. }
  373. if (annotParam != null)
  374. {
  375. annotParam.PageIndex = PageIndex;
  376. CPDFPage cPDFPage = cPDFDocument.PageAtIndex(annotParam.PageIndex, false);
  377. List<CPDFAnnotation> cPDFAnnotations = cPDFPage.GetAnnotations();
  378. annotParam.AnnotIndex = cPDFAnnotations.IndexOf(cPDFAnnotation);
  379. }
  380. return annotParam;
  381. }
  382. public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocument, CPDFEditArea cPDFEditArea, int pageIndex)
  383. {
  384. PDFEditParam annotParam = null;
  385. if (cPDFEditArea == null && !cPDFEditArea.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid() && pageIndex >= 0)
  386. {
  387. return null;
  388. }
  389. switch (cPDFEditArea.Type)
  390. {
  391. case CPDFEditType.None:
  392. break;
  393. case CPDFEditType.EditText:
  394. annotParam = GetTextEditParam(cPDFDocument, cPDFEditArea as CPDFEditTextArea, pageIndex);
  395. break;
  396. case CPDFEditType.EditImage:
  397. annotParam = GetImageEditParam(cPDFDocument, cPDFEditArea as CPDFEditImageArea, pageIndex);
  398. break;
  399. case CPDFEditType.EditPath:
  400. annotParam = GetPathEditParam(cPDFDocument, cPDFEditArea as CPDFEditPathArea, pageIndex);
  401. break;
  402. default:
  403. break;
  404. }
  405. return annotParam;
  406. }
  407. #region PDFEdit
  408. internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEditTextArea cPDFEditArea, int pageIndex)
  409. {
  410. TextEditParam textEditParam = new TextEditParam();
  411. string fontName = "Helvetica";
  412. float fontSize = 14;
  413. byte[] fontColor = {0,0,0};
  414. byte transparency = 255;
  415. bool isBold = false;
  416. bool isItalic = false;
  417. cPDFEditArea.GetTextStyle(ref fontName,ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
  418. textEditParam.FontName = fontName;
  419. textEditParam.FontSize = fontSize;
  420. textEditParam.FontColor = fontColor;
  421. textEditParam.Transparency = transparency;
  422. textEditParam.TextAlign = cPDFEditArea.GetTextSectionAlign();
  423. textEditParam.EditType = CPDFEditType.EditText;
  424. CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
  425. CPDFEditPage editPage = docPage.GetEditPage();
  426. textEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
  427. textEditParam.PageIndex = pageIndex;
  428. if(string.IsNullOrEmpty(cPDFEditArea.SelectText))
  429. {
  430. textEditParam.IsBold = isBold;
  431. textEditParam.IsItalic = isItalic;
  432. }
  433. else
  434. {
  435. textEditParam.IsBold = cPDFEditArea.IsCharsFontBold();
  436. textEditParam.IsItalic = cPDFEditArea.IsCharsFontItalic();
  437. }
  438. return textEditParam;
  439. }
  440. internal static ImageEditParam GetImageEditParam(CPDFDocument cPDFDocument, CPDFEditImageArea cPDFEditArea, int pageIndex)
  441. {
  442. ImageEditParam imageEditParam = new ImageEditParam();
  443. imageEditParam.Transparency = cPDFEditArea.GetImageTransparency();
  444. imageEditParam.Rotate = cPDFEditArea.GetRotation();
  445. imageEditParam.ClipRect = cPDFEditArea.GetClipRect();
  446. imageEditParam.EditType = CPDFEditType.EditImage;
  447. CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
  448. CPDFEditPage editPage = docPage.GetEditPage();
  449. imageEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
  450. imageEditParam.PageIndex = pageIndex;
  451. return imageEditParam;
  452. }
  453. internal static PathEditParam GetPathEditParam(CPDFDocument cPDFDocument, CPDFEditPathArea cPDFEditArea, int pageIndex)
  454. {
  455. PathEditParam pathEditParam = new PathEditParam();
  456. pathEditParam.Transparency = cPDFEditArea.GetTransparency();
  457. pathEditParam.Rotate = cPDFEditArea.GetRotation();
  458. pathEditParam.StrokeColor = cPDFEditArea.GetStrokeColor();
  459. pathEditParam.FillColor = cPDFEditArea.GetFillColor();
  460. pathEditParam.ClipRect = cPDFEditArea.GetClipRect();
  461. pathEditParam.EditType = CPDFEditType.EditPath;
  462. CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
  463. CPDFEditPage editPage = docPage.GetEditPage();
  464. pathEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
  465. pathEditParam.PageIndex = pageIndex;
  466. return pathEditParam;
  467. }
  468. #endregion
  469. #region Widegt
  470. internal static AnnotParam WidgetConverter(CPDFDocument document, CPDFAnnotation cPDFAnnotation)
  471. {
  472. AnnotParam annotParam = null;
  473. if (cPDFAnnotation is CPDFWidget)
  474. {
  475. switch ((cPDFAnnotation as CPDFWidget).WidgetType)
  476. {
  477. case C_WIDGET_TYPE.WIDGET_NONE:
  478. break;
  479. case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  480. annotParam = GetPushButtonParam(document, cPDFAnnotation as CPDFPushButtonWidget);
  481. break;
  482. case C_WIDGET_TYPE.WIDGET_CHECKBOX:
  483. annotParam = GetCheckBoxParam(cPDFAnnotation as CPDFCheckBoxWidget);
  484. break;
  485. case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  486. annotParam = GetRadioButtonParam(cPDFAnnotation as CPDFRadioButtonWidget);
  487. break;
  488. case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  489. annotParam = GetTextBoxParam(cPDFAnnotation as CPDFTextWidget);
  490. break;
  491. case C_WIDGET_TYPE.WIDGET_COMBOBOX:
  492. annotParam = GetComboBoxParam(cPDFAnnotation as CPDFComboBoxWidget);
  493. break;
  494. case C_WIDGET_TYPE.WIDGET_LISTBOX:
  495. annotParam = GetListBoxParam(cPDFAnnotation as CPDFListBoxWidget);
  496. break;
  497. case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  498. annotParam = GetSignatureParam(cPDFAnnotation as CPDFSignatureWidget);
  499. break;
  500. case C_WIDGET_TYPE.WIDGET_UNKNOWN:
  501. break;
  502. default:
  503. break;
  504. }
  505. }
  506. return annotParam;
  507. }
  508. internal static PushButtonParam GetPushButtonParam(CPDFDocument document, CPDFPushButtonWidget cPDFWidget)
  509. {
  510. PushButtonParam pushButtonParam = null;
  511. if (cPDFWidget != null && cPDFWidget.IsValid())
  512. {
  513. pushButtonParam = new PushButtonParam();
  514. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  515. pushButtonParam.IsBold = IsBold(cTextAttribute.FontName);
  516. pushButtonParam.IsItalic = IsItalic(cTextAttribute.FontName);
  517. pushButtonParam.Text = cPDFWidget.GetButtonTitle();
  518. pushButtonParam.FontColor = cTextAttribute.FontColor;
  519. pushButtonParam.FontName = cTextAttribute.FontName;
  520. pushButtonParam.FontSize = cTextAttribute.FontSize;
  521. CPDFAction cPDFAction = cPDFWidget.GetButtonAction();
  522. if (cPDFAction != null)
  523. {
  524. switch (cPDFAction.ActionType)
  525. {
  526. case C_ACTION_TYPE.ACTION_TYPE_URI:
  527. pushButtonParam.Uri = (cPDFAction as CPDFUriAction)?.GetUri();
  528. break;
  529. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  530. CPDFGoToAction gotoAction = cPDFAction as CPDFGoToAction;
  531. CPDFDestination dest = gotoAction.GetDestination(document);
  532. pushButtonParam.DestinationPageIndex = dest.PageIndex;
  533. pushButtonParam.DestinationPosition = new CPoint(dest.Position_X, dest.Position_Y);
  534. break;
  535. default:
  536. break;
  537. }
  538. pushButtonParam.Action = cPDFAction.ActionType;
  539. }
  540. pushButtonParam.WidgetType = cPDFWidget.WidgetType;
  541. pushButtonParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  542. byte[] LineColor = new byte[3];
  543. pushButtonParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  544. pushButtonParam.LineColor = LineColor;
  545. byte[] BgColor = new byte[3];
  546. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  547. pushButtonParam.HasBgColor = hasBgColor;
  548. pushButtonParam.BgColor = BgColor;
  549. pushButtonParam.LineWidth = cPDFWidget.GetBorderWidth();
  550. pushButtonParam.FieldName = cPDFWidget.GetFieldName();
  551. pushButtonParam.Flags = cPDFWidget.GetFlags();
  552. pushButtonParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  553. pushButtonParam.IsHidden = cPDFWidget.GetIsHidden();
  554. GetAnnotCommonParam(cPDFWidget, pushButtonParam);
  555. }
  556. return pushButtonParam;
  557. }
  558. internal static CheckBoxParam GetCheckBoxParam(CPDFCheckBoxWidget cPDFWidget)
  559. {
  560. CheckBoxParam checkBoxParam = null;
  561. if (cPDFWidget != null && cPDFWidget.IsValid())
  562. {
  563. checkBoxParam = new CheckBoxParam();
  564. checkBoxParam.CheckStyle = cPDFWidget.GetWidgetCheckStyle();
  565. checkBoxParam.IsChecked = cPDFWidget.IsChecked();
  566. checkBoxParam.WidgetType = cPDFWidget.WidgetType;
  567. checkBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  568. byte[] LineColor = new byte[3];
  569. checkBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  570. checkBoxParam.LineColor = LineColor;
  571. byte[] BgColor = new byte[3];
  572. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  573. checkBoxParam.HasBgColor = hasBgColor;
  574. checkBoxParam.BgColor = BgColor;
  575. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  576. checkBoxParam.FontColor = cTextAttribute.FontColor;
  577. checkBoxParam.FontName = cTextAttribute.FontName;
  578. checkBoxParam.FontSize = cTextAttribute.FontSize;
  579. checkBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
  580. checkBoxParam.FieldName = cPDFWidget.GetFieldName();
  581. checkBoxParam.Flags = cPDFWidget.GetFlags();
  582. checkBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  583. checkBoxParam.IsHidden = cPDFWidget.GetIsHidden();
  584. GetAnnotCommonParam(cPDFWidget, checkBoxParam);
  585. }
  586. return checkBoxParam;
  587. }
  588. internal static RadioButtonParam GetRadioButtonParam(CPDFRadioButtonWidget cPDFWidget)
  589. {
  590. RadioButtonParam radioButtonParam = null;
  591. if (cPDFWidget != null && cPDFWidget.IsValid())
  592. {
  593. radioButtonParam = new RadioButtonParam();
  594. radioButtonParam.CheckStyle = cPDFWidget.GetWidgetCheckStyle();
  595. radioButtonParam.IsChecked = cPDFWidget.IsChecked();
  596. radioButtonParam.WidgetType = cPDFWidget.WidgetType;
  597. radioButtonParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  598. byte[] LineColor = new byte[3];
  599. radioButtonParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  600. radioButtonParam.LineColor = LineColor;
  601. byte[] BgColor = new byte[3];
  602. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  603. radioButtonParam.HasBgColor = hasBgColor;
  604. radioButtonParam.BgColor = BgColor;
  605. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  606. radioButtonParam.FontColor = cTextAttribute.FontColor;
  607. radioButtonParam.FontName = cTextAttribute.FontName;
  608. radioButtonParam.FontSize = cTextAttribute.FontSize;
  609. radioButtonParam.LineWidth = cPDFWidget.GetBorderWidth();
  610. radioButtonParam.FieldName = cPDFWidget.GetFieldName();
  611. radioButtonParam.Flags = cPDFWidget.GetFlags();
  612. radioButtonParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  613. radioButtonParam.IsHidden = cPDFWidget.GetIsHidden();
  614. GetAnnotCommonParam(cPDFWidget, radioButtonParam);
  615. }
  616. return radioButtonParam;
  617. }
  618. internal static TextBoxParam GetTextBoxParam(CPDFTextWidget cPDFWidget)
  619. {
  620. TextBoxParam textBoxParam = null;
  621. if (cPDFWidget != null && cPDFWidget.IsValid())
  622. {
  623. textBoxParam = new TextBoxParam();
  624. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  625. textBoxParam.Text = cPDFWidget.Text;
  626. textBoxParam.IsMultiLine = cPDFWidget.IsMultiLine;
  627. textBoxParam.IsPassword = cPDFWidget.IsPassword;
  628. textBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
  629. textBoxParam.IsBold = IsBold(cTextAttribute.FontName);
  630. textBoxParam.Alignment = cPDFWidget.Alignment;
  631. textBoxParam.WidgetType = cPDFWidget.WidgetType;
  632. textBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  633. byte[] LineColor = new byte[3];
  634. textBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  635. textBoxParam.LineColor = LineColor;
  636. byte[] BgColor = new byte[3];
  637. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  638. textBoxParam.HasBgColor = hasBgColor;
  639. textBoxParam.BgColor = BgColor;
  640. textBoxParam.FontColor = cTextAttribute.FontColor;
  641. textBoxParam.FontName = cTextAttribute.FontName;
  642. textBoxParam.FontSize = cTextAttribute.FontSize;
  643. textBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
  644. textBoxParam.FieldName = cPDFWidget.GetFieldName();
  645. textBoxParam.Flags = cPDFWidget.GetFlags();
  646. textBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  647. textBoxParam.IsHidden = cPDFWidget.GetIsHidden();
  648. GetAnnotCommonParam(cPDFWidget, textBoxParam);
  649. }
  650. return textBoxParam;
  651. }
  652. internal static ComboBoxParam GetComboBoxParam(CPDFComboBoxWidget cPDFWidget)
  653. {
  654. ComboBoxParam comboBoxParam = null;
  655. if (cPDFWidget != null && cPDFWidget.IsValid())
  656. {
  657. comboBoxParam = new ComboBoxParam();
  658. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  659. comboBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
  660. comboBoxParam.IsBold = IsBold(cTextAttribute.FontName);
  661. //Support for multiple selections needs to be adjusted later.
  662. CWidgetItem[] cWidgetItem = cPDFWidget.LoadWidgetItems();
  663. CWidgetItem cWidgetItem1 = cPDFWidget.GetSelectedItem();
  664. if (cWidgetItem != null)
  665. {
  666. for (int i = 0; i < cWidgetItem.Length; i++)
  667. {
  668. CWidgetItem item = cWidgetItem[i];
  669. comboBoxParam.OptionItems.Add(item.Value, item.Text);
  670. if (cWidgetItem1 != null && cWidgetItem1.Text == item.Text && cWidgetItem1.Value == item.Value)
  671. {
  672. comboBoxParam.SelectItemsIndex = new List<int> { i };
  673. }
  674. }
  675. }
  676. comboBoxParam.WidgetType = cPDFWidget.WidgetType;
  677. comboBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  678. byte[] LineColor = new byte[3];
  679. comboBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  680. comboBoxParam.LineColor = LineColor;
  681. byte[] BgColor = new byte[3];
  682. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  683. comboBoxParam.HasBgColor = hasBgColor;
  684. comboBoxParam.BgColor = BgColor;
  685. comboBoxParam.FontColor = cTextAttribute.FontColor;
  686. comboBoxParam.FontName = cTextAttribute.FontName;
  687. comboBoxParam.FontSize = cTextAttribute.FontSize;
  688. comboBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
  689. comboBoxParam.FieldName = cPDFWidget.GetFieldName();
  690. comboBoxParam.Flags = cPDFWidget.GetFlags();
  691. comboBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  692. comboBoxParam.IsHidden = cPDFWidget.GetIsHidden();
  693. GetAnnotCommonParam(cPDFWidget, comboBoxParam);
  694. }
  695. return comboBoxParam;
  696. }
  697. internal static ListBoxParam GetListBoxParam(CPDFListBoxWidget cPDFWidget)
  698. {
  699. ListBoxParam listBoxParam = null;
  700. if (cPDFWidget != null && cPDFWidget.IsValid())
  701. {
  702. listBoxParam = new ListBoxParam();
  703. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  704. listBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
  705. listBoxParam.IsBold = IsBold(cTextAttribute.FontName);
  706. CWidgetItem[] cWidgetItem = cPDFWidget.LoadWidgetItems();
  707. //Support for multiple selections needs to be adjusted later.
  708. CWidgetItem cWidgetItem1 = cPDFWidget.GetSelectedItem();
  709. if (cWidgetItem != null)
  710. {
  711. for (int i = 0; i < cWidgetItem.Length; i++)
  712. {
  713. CWidgetItem item = cWidgetItem[i];
  714. listBoxParam.OptionItems.Add(item.Value, item.Text);
  715. if (cWidgetItem1 != null && cWidgetItem1.Text == item.Text && cWidgetItem1.Value == item.Value)
  716. {
  717. listBoxParam.SelectItemsIndex = new List<int> { i };
  718. }
  719. }
  720. }
  721. listBoxParam.WidgetType = cPDFWidget.WidgetType;
  722. listBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  723. byte[] LineColor = new byte[3];
  724. listBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  725. listBoxParam.LineColor = LineColor;
  726. byte[] BgColor = new byte[3];
  727. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  728. listBoxParam.HasBgColor = hasBgColor;
  729. listBoxParam.BgColor = BgColor;
  730. listBoxParam.FontColor = cTextAttribute.FontColor;
  731. listBoxParam.FontName = cTextAttribute.FontName;
  732. listBoxParam.FontSize = cTextAttribute.FontSize;
  733. listBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
  734. listBoxParam.FieldName = cPDFWidget.GetFieldName();
  735. listBoxParam.Flags = cPDFWidget.GetFlags();
  736. listBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  737. listBoxParam.IsHidden = cPDFWidget.GetIsHidden();
  738. GetAnnotCommonParam(cPDFWidget, listBoxParam);
  739. }
  740. return listBoxParam;
  741. }
  742. internal static SignatureParam GetSignatureParam(CPDFSignatureWidget cPDFWidget)
  743. {
  744. SignatureParam signatureParam = null;
  745. if (cPDFWidget != null && cPDFWidget.IsValid())
  746. {
  747. signatureParam = new SignatureParam();
  748. signatureParam.WidgetType = cPDFWidget.WidgetType;
  749. signatureParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
  750. byte[] LineColor = new byte[3];
  751. signatureParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
  752. signatureParam.LineColor = LineColor;
  753. byte[] BgColor = new byte[3];
  754. bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
  755. signatureParam.HasBgColor = hasBgColor;
  756. signatureParam.BgColor = BgColor;
  757. CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
  758. signatureParam.FontColor = cTextAttribute.FontColor;
  759. signatureParam.FontName = cTextAttribute.FontName;
  760. signatureParam.FontSize = cTextAttribute.FontSize;
  761. signatureParam.LineWidth = cPDFWidget.GetBorderWidth();
  762. signatureParam.FieldName = cPDFWidget.GetFieldName();
  763. signatureParam.Flags = cPDFWidget.GetFlags();
  764. signatureParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
  765. signatureParam.IsHidden = cPDFWidget.GetIsHidden();
  766. GetAnnotCommonParam(cPDFWidget, signatureParam);
  767. }
  768. return signatureParam;
  769. }
  770. #endregion
  771. #region Annot
  772. internal static AnnotParam MeasureAnnotConverter(CPDFAnnotation pdfAnnot)
  773. {
  774. if (pdfAnnot == null || pdfAnnot.IsValid() == false)
  775. {
  776. return null;
  777. }
  778. switch (pdfAnnot.Type)
  779. {
  780. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  781. {
  782. CPDFLineAnnotation lineAnnot = pdfAnnot as CPDFLineAnnotation;
  783. if (lineAnnot != null)
  784. {
  785. return GetLineMeasureParam(lineAnnot);
  786. }
  787. }
  788. break;
  789. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
  790. {
  791. CPDFPolylineAnnotation polylineAnnot = pdfAnnot as CPDFPolylineAnnotation;
  792. if (polylineAnnot != null)
  793. {
  794. return GetPolylineParam(polylineAnnot);
  795. }
  796. }
  797. break;
  798. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
  799. {
  800. CPDFPolygonAnnotation polygonAnnot = pdfAnnot as CPDFPolygonAnnotation;
  801. if (polygonAnnot != null)
  802. {
  803. return GetPolygonParam(polygonAnnot);
  804. }
  805. }
  806. break;
  807. }
  808. return null;
  809. }
  810. internal static AnnotParam AnnotConverter(CPDFDocument pdfDoc, CPDFAnnotation pdfAnnot)
  811. {
  812. if (pdfAnnot == null || pdfAnnot.IsValid() == false)
  813. {
  814. return null;
  815. }
  816. switch (pdfAnnot.Type)
  817. {
  818. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  819. {
  820. CPDFSquareAnnotation squareAnnot = pdfAnnot as CPDFSquareAnnotation;
  821. if (squareAnnot != null)
  822. {
  823. return GetSquareParam(squareAnnot);
  824. }
  825. }
  826. break;
  827. case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  828. {
  829. CPDFCircleAnnotation circleAnnot = pdfAnnot as CPDFCircleAnnotation;
  830. if (circleAnnot != null)
  831. {
  832. return GetCircleParam(circleAnnot);
  833. }
  834. }
  835. break;
  836. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  837. {
  838. CPDFLineAnnotation lineAnnot = pdfAnnot as CPDFLineAnnotation;
  839. if (lineAnnot != null)
  840. {
  841. if(lineAnnot.IsMeasured())
  842. {
  843. return GetLineMeasureParam(lineAnnot);
  844. }
  845. return GetLineParam(lineAnnot);
  846. }
  847. }
  848. break;
  849. case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  850. {
  851. CPDFInkAnnotation inkAnnot = pdfAnnot as CPDFInkAnnotation;
  852. if (inkAnnot != null)
  853. {
  854. return GetInkParam(inkAnnot);
  855. }
  856. }
  857. break;
  858. case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  859. {
  860. CPDFFreeTextAnnotation freetextAnnot = pdfAnnot as CPDFFreeTextAnnotation;
  861. if (freetextAnnot != null)
  862. {
  863. return GetFreeTextParam(freetextAnnot);
  864. }
  865. }
  866. break;
  867. case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  868. {
  869. CPDFHighlightAnnotation highlightAnnot = pdfAnnot as CPDFHighlightAnnotation;
  870. if (highlightAnnot != null)
  871. {
  872. return GetHighlightParam(highlightAnnot);
  873. }
  874. }
  875. break;
  876. case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  877. {
  878. CPDFUnderlineAnnotation underlineAnnot = pdfAnnot as CPDFUnderlineAnnotation;
  879. if (underlineAnnot != null)
  880. {
  881. return GetUnderlineParam(underlineAnnot);
  882. }
  883. }
  884. break;
  885. case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  886. {
  887. CPDFStrikeoutAnnotation strikeoutAnnot = pdfAnnot as CPDFStrikeoutAnnotation;
  888. if (strikeoutAnnot != null)
  889. {
  890. return GetStrikeoutParam(strikeoutAnnot);
  891. }
  892. }
  893. break;
  894. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  895. {
  896. CPDFSquigglyAnnotation squigglyAnnot = pdfAnnot as CPDFSquigglyAnnotation;
  897. if (squigglyAnnot != null)
  898. {
  899. return GetSquigglyParam(squigglyAnnot);
  900. }
  901. }
  902. break;
  903. case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  904. {
  905. CPDFTextAnnotation stickyAnnot = pdfAnnot as CPDFTextAnnotation;
  906. if (stickyAnnot != null)
  907. {
  908. return GetStickynoteParam(stickyAnnot);
  909. }
  910. }
  911. break;
  912. case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  913. {
  914. CPDFStampAnnotation stampAnnot = pdfAnnot as CPDFStampAnnotation;
  915. if (stampAnnot != null)
  916. {
  917. return GetStampParam(stampAnnot);
  918. }
  919. }
  920. break;
  921. case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  922. {
  923. CPDFLinkAnnotation linkAnnot = pdfAnnot as CPDFLinkAnnotation;
  924. if (linkAnnot != null)
  925. {
  926. return GetLinkParam(linkAnnot, pdfDoc);
  927. }
  928. }
  929. break;
  930. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  931. {
  932. CPDFSoundAnnotation soundAnnot = pdfAnnot as CPDFSoundAnnotation;
  933. if (soundAnnot != null)
  934. {
  935. return GetSoundParam(soundAnnot);
  936. }
  937. }
  938. break;
  939. case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
  940. {
  941. CPDFRedactAnnotation redactAnnot= pdfAnnot as CPDFRedactAnnotation;
  942. if(redactAnnot != null)
  943. {
  944. return GetRedactParam(redactAnnot);
  945. }
  946. }
  947. break;
  948. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
  949. {
  950. CPDFPolylineAnnotation polylineAnnot= pdfAnnot as CPDFPolylineAnnotation;
  951. if (polylineAnnot!=null && polylineAnnot.IsMeasured())
  952. {
  953. return GetPolyLineMeasureParam(polylineAnnot);
  954. }
  955. }
  956. break;
  957. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
  958. {
  959. CPDFPolygonAnnotation polygonAnnot= pdfAnnot as CPDFPolygonAnnotation;
  960. if(polygonAnnot!=null)
  961. {
  962. return GetPolygonMeasureParam(polygonAnnot);
  963. }
  964. }
  965. break;
  966. default:
  967. break;
  968. }
  969. return null;
  970. }
  971. internal static void GetAnnotCommonParam(CPDFAnnotation pdfAnnot, AnnotParam annotParam)
  972. {
  973. if (pdfAnnot == null || annotParam == null || !pdfAnnot.IsValid())
  974. {
  975. return;
  976. }
  977. annotParam.CurrentType = pdfAnnot.Type;
  978. annotParam.Author = pdfAnnot.GetAuthor();
  979. annotParam.Transparency = pdfAnnot.GetTransparency();
  980. annotParam.Content = pdfAnnot.GetContent();
  981. annotParam.UpdateTime = pdfAnnot.GetModifyDate();
  982. annotParam.CreateTime = pdfAnnot.GetCreationDate();
  983. annotParam.Locked = pdfAnnot.GetIsLocked();
  984. annotParam.ClientRect = pdfAnnot.GetRect();
  985. annotParam.AnnotIndex = pdfAnnot.Page.GetAnnotations().IndexOf(pdfAnnot);
  986. //Annotation object exists, but the list cannot be found, it can only be a newly created annotation object.
  987. if (annotParam.AnnotIndex == -1)
  988. {
  989. annotParam.AnnotIndex = pdfAnnot.Page.GetAnnotCount() - 1;
  990. }
  991. annotParam.PageIndex = pdfAnnot.Page.PageIndex;
  992. }
  993. internal static SquareParam GetSquareParam(CPDFSquareAnnotation squareAnnot)
  994. {
  995. if (squareAnnot == null || squareAnnot.IsValid() == false)
  996. {
  997. return null;
  998. }
  999. SquareParam squareParam = new SquareParam();
  1000. if (squareAnnot.LineColor != null && squareAnnot.LineColor.Length == 3)
  1001. {
  1002. squareParam.LineColor = new byte[3]
  1003. {
  1004. squareAnnot.LineColor[0],
  1005. squareAnnot.LineColor[1],
  1006. squareAnnot.LineColor[2]
  1007. };
  1008. }
  1009. if (squareAnnot.HasBgColor && squareAnnot.BgColor != null)
  1010. {
  1011. if (squareAnnot.BgColor.Length == 3)
  1012. {
  1013. squareParam.HasBgColor = true;
  1014. squareParam.BgColor = new byte[3]
  1015. {
  1016. squareAnnot.BgColor[0],
  1017. squareAnnot.BgColor[1],
  1018. squareAnnot.BgColor[2]
  1019. };
  1020. }
  1021. }
  1022. squareParam.LineWidth = squareAnnot.LineWidth;
  1023. squareParam.BorderStyle = squareAnnot.BorderStyle;
  1024. if (squareAnnot.Dash != null && squareAnnot.Dash.Length > 0)
  1025. {
  1026. squareParam.LineDash = new float[squareAnnot.Dash.Length];
  1027. squareAnnot.Dash.CopyTo(squareParam.LineDash, 0);
  1028. }
  1029. GetAnnotCommonParam(squareAnnot, squareParam);
  1030. return squareParam;
  1031. }
  1032. internal static CircleParam GetCircleParam(CPDFCircleAnnotation circleAnnot)
  1033. {
  1034. if (circleAnnot == null || circleAnnot.IsValid() == false)
  1035. {
  1036. return null;
  1037. }
  1038. CircleParam circleParam = new CircleParam();
  1039. if (circleAnnot.LineColor != null && circleAnnot.LineColor.Length == 3)
  1040. {
  1041. circleParam.LineColor = new byte[3]
  1042. {
  1043. circleAnnot.LineColor[0],
  1044. circleAnnot.LineColor[1],
  1045. circleAnnot.LineColor[2]
  1046. };
  1047. }
  1048. if (circleAnnot.HasBgColor && circleAnnot.BgColor != null)
  1049. {
  1050. if (circleAnnot.BgColor.Length == 3)
  1051. {
  1052. circleParam.HasBgColor = true;
  1053. circleParam.BgColor = new byte[3]
  1054. {
  1055. circleAnnot.BgColor[0],
  1056. circleAnnot.BgColor[1],
  1057. circleAnnot.BgColor[2]
  1058. };
  1059. }
  1060. }
  1061. circleParam.LineWidth = circleAnnot.LineWidth;
  1062. circleParam.BorderStyle = circleAnnot.BorderStyle;
  1063. if (circleAnnot.Dash != null && circleAnnot.Dash.Length > 0)
  1064. {
  1065. circleParam.LineDash = new float[circleAnnot.Dash.Length];
  1066. circleAnnot.Dash.CopyTo(circleParam.LineDash, 0);
  1067. }
  1068. GetAnnotCommonParam(circleAnnot, circleParam);
  1069. return circleParam;
  1070. }
  1071. private static AnnotParam GetPolylineParam(CPDFPolylineAnnotation polylineAnnot)
  1072. {
  1073. if (polylineAnnot == null || polylineAnnot.IsValid() == false)
  1074. {
  1075. return null;
  1076. }
  1077. PolyLineMeasureParam polylineParam = new PolyLineMeasureParam();
  1078. if (polylineAnnot.LineColor != null && polylineAnnot.LineColor.Length == 3)
  1079. {
  1080. polylineParam.LineColor = new byte[3]
  1081. {
  1082. polylineAnnot.LineColor[0],
  1083. polylineAnnot.LineColor[1],
  1084. polylineAnnot.LineColor[2]
  1085. };
  1086. }
  1087. polylineParam.LineWidth = polylineAnnot.LineWidth;
  1088. polylineParam.BorderStyle = polylineAnnot.BorderStyle;
  1089. if (polylineAnnot.Dash != null && polylineAnnot.Dash.Length > 0)
  1090. {
  1091. polylineParam.LineDash = new float[polylineAnnot.Dash.Length];
  1092. polylineAnnot.Dash.CopyTo(polylineParam.LineDash, 0);
  1093. }
  1094. if (polylineAnnot.Points != null && polylineAnnot.Points.Count > 0)
  1095. {
  1096. polylineParam.SavePoints = new List<CPoint>();
  1097. foreach (CPoint point in polylineAnnot.Points)
  1098. {
  1099. polylineParam.SavePoints.Add(point);
  1100. }
  1101. }
  1102. CTextAttribute cTextAttribute = polylineAnnot.GetTextAttribute();
  1103. polylineParam.FontName = cTextAttribute.FontName;
  1104. polylineParam.FontSize = cTextAttribute.FontSize;
  1105. polylineParam.FontColor = cTextAttribute.FontColor;
  1106. GetAnnotCommonParam(polylineAnnot, polylineParam);
  1107. return polylineParam;
  1108. }
  1109. private static AnnotParam GetPolygonParam(CPDFPolygonAnnotation polygonAnnot)
  1110. {
  1111. if (polygonAnnot == null || polygonAnnot.IsValid() == false)
  1112. {
  1113. return null;
  1114. }
  1115. PolygonMeasureParam polygonParam = new PolygonMeasureParam();
  1116. if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3)
  1117. {
  1118. polygonParam.LineColor = new byte[3]
  1119. {
  1120. polygonAnnot.LineColor[0],
  1121. polygonAnnot.LineColor[1],
  1122. polygonAnnot.LineColor[2]
  1123. };
  1124. }
  1125. if(polygonAnnot.HasBgColor && polygonAnnot.BgColor != null)
  1126. {
  1127. polygonParam.HasFillColor = true;
  1128. polygonParam.FillColor = new byte[3]
  1129. {
  1130. polygonAnnot.BgColor[0],
  1131. polygonAnnot.BgColor[1],
  1132. polygonAnnot.BgColor[2]
  1133. };
  1134. }
  1135. polygonParam.LineWidth = polygonAnnot.LineWidth;
  1136. polygonParam.BorderStyle = polygonAnnot.BorderStyle;
  1137. if (polygonAnnot.Dash != null && polygonAnnot.Dash.Length > 0)
  1138. {
  1139. polygonParam.LineDash = new float[polygonAnnot.Dash.Length];
  1140. polygonAnnot.Dash.CopyTo(polygonParam.LineDash, 0);
  1141. }
  1142. if (polygonAnnot.Points != null && polygonAnnot.Points.Count > 0)
  1143. {
  1144. polygonParam.SavePoints = new List<CPoint>();
  1145. foreach (CPoint point in polygonAnnot.Points)
  1146. {
  1147. polygonParam.SavePoints.Add(point);
  1148. }
  1149. }
  1150. CTextAttribute cTextAttribute = polygonAnnot.GetTextAttribute();
  1151. polygonParam.FontName = cTextAttribute.FontName;
  1152. polygonParam.FontSize = cTextAttribute.FontSize;
  1153. polygonParam.FontColor = cTextAttribute.FontColor;
  1154. GetAnnotCommonParam(polygonAnnot, polygonParam);
  1155. return polygonParam;
  1156. }
  1157. internal static LineParam GetLineParam(CPDFLineAnnotation lineAnnot)
  1158. {
  1159. if (lineAnnot == null || lineAnnot.IsValid() == false)
  1160. {
  1161. return null;
  1162. }
  1163. LineParam lineParam = new LineParam();
  1164. if (lineAnnot.LineColor != null && lineAnnot.LineColor.Length == 3)
  1165. {
  1166. lineParam.LineColor = new byte[3]
  1167. {
  1168. lineAnnot.LineColor[0],
  1169. lineAnnot.LineColor[1],
  1170. lineAnnot.LineColor[2]
  1171. };
  1172. }
  1173. if (lineAnnot.HasBgColor && lineAnnot.BgColor != null)
  1174. {
  1175. if (lineAnnot.BgColor.Length == 3)
  1176. {
  1177. lineParam.HasBgColor = true;
  1178. lineParam.BgColor = new byte[3]
  1179. {
  1180. lineAnnot.BgColor[0],
  1181. lineAnnot.BgColor[1],
  1182. lineAnnot.BgColor[2]
  1183. };
  1184. }
  1185. }
  1186. lineParam.LineWidth = lineAnnot.LineWidth;
  1187. lineParam.BorderStyle = lineAnnot.BorderStyle;
  1188. if (lineAnnot.Dash != null && lineAnnot.Dash.Length > 0)
  1189. {
  1190. lineParam.LineDash = new float[lineAnnot.Dash.Length];
  1191. lineAnnot.Dash.CopyTo(lineParam.LineDash, 0);
  1192. }
  1193. lineParam.HeadLineType = lineAnnot.HeadLineType;
  1194. lineParam.TailLineType = lineAnnot.TailLineType;
  1195. if (lineAnnot.Points != null && lineAnnot.Points.Length == 2)
  1196. {
  1197. lineParam.HeadPoint = lineAnnot.Points[0];
  1198. lineParam.TailPoint = lineAnnot.Points[1];
  1199. }
  1200. GetAnnotCommonParam(lineAnnot, lineParam);
  1201. return lineParam;
  1202. }
  1203. internal static LineMeasureParam GetLineMeasureParam(CPDFLineAnnotation lineAnnot)
  1204. {
  1205. if (lineAnnot == null || lineAnnot.IsValid() == false || lineAnnot.IsMeasured()==false)
  1206. {
  1207. return null;
  1208. }
  1209. LineMeasureParam measureParam = new LineMeasureParam();
  1210. CPDFDistanceMeasure distanceMeasure = lineAnnot.GetDistanceMeasure();
  1211. measureParam.measureInfo = distanceMeasure.MeasureInfo;
  1212. if (lineAnnot.LineColor != null && lineAnnot.LineColor.Length == 3)
  1213. {
  1214. measureParam.LineColor = new byte[3] { lineAnnot.LineColor[0], lineAnnot.LineColor[1], lineAnnot.LineColor[2] };
  1215. }
  1216. measureParam.LeadLength=distanceMeasure.GetLeadLength();
  1217. measureParam.LeadExtension=distanceMeasure.GetLeadExtension();
  1218. measureParam.LeadOffset=distanceMeasure.GetLeadOffset();
  1219. measureParam.BorderStyle = lineAnnot.BorderStyle;
  1220. measureParam.LineWidth = lineAnnot.LineWidth;
  1221. measureParam.Transparency = lineAnnot.Transparency;
  1222. measureParam.LineDash = lineAnnot.Dash;
  1223. CTextAttribute textAttr = lineAnnot.GetTextAttribute();
  1224. measureParam.FontName = textAttr.FontName;
  1225. measureParam.FontSize = textAttr.FontSize;
  1226. if (textAttr.FontColor != null && textAttr.FontColor.Length == 3)
  1227. {
  1228. measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
  1229. }
  1230. measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
  1231. measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
  1232. measureParam.HeadLineType=lineAnnot.HeadLineType;
  1233. measureParam.TailLineType=lineAnnot.TailLineType;
  1234. measureParam.HeadPoint = lineAnnot.Points[0];
  1235. measureParam.TailPoint = lineAnnot.Points[1];
  1236. GetAnnotCommonParam(lineAnnot, measureParam);
  1237. return measureParam;
  1238. }
  1239. internal static InkParam GetInkParam(CPDFInkAnnotation inkAnnot)
  1240. {
  1241. if (inkAnnot == null || inkAnnot.IsValid() == false)
  1242. {
  1243. return null;
  1244. }
  1245. InkParam inkParam = new InkParam();
  1246. inkParam.Thickness = inkAnnot.Thickness;
  1247. if (inkAnnot.InkColor != null && inkAnnot.InkColor.Length == 3)
  1248. {
  1249. inkParam.InkColor = new byte[3]
  1250. {
  1251. inkAnnot.InkColor[0],
  1252. inkAnnot.InkColor[1],
  1253. inkAnnot.InkColor[2]
  1254. };
  1255. }
  1256. if (inkAnnot.InkPath != null && inkAnnot.InkPath.Count > 0)
  1257. {
  1258. List<List<CPoint>> inkPath = new List<List<CPoint>>();
  1259. foreach (List<CPoint> copyList in inkAnnot.InkPath)
  1260. {
  1261. if (copyList.Count == 0)
  1262. {
  1263. continue;
  1264. }
  1265. List<CPoint> saveList = new List<CPoint>();
  1266. foreach (CPoint item in copyList)
  1267. {
  1268. saveList.Add(item);
  1269. }
  1270. if (saveList.Count > 0)
  1271. {
  1272. inkPath.Add(saveList);
  1273. }
  1274. }
  1275. if (inkPath.Count > 0)
  1276. {
  1277. inkParam.InkPath = inkPath;
  1278. }
  1279. }
  1280. if(inkAnnot.Dash!=null && inkAnnot.Dash.Length>0)
  1281. {
  1282. inkParam.Dash =new float[inkAnnot.Dash.Length];
  1283. inkAnnot.Dash.CopyTo(inkParam.Dash, 0);
  1284. }
  1285. GetAnnotCommonParam(inkAnnot, inkParam);
  1286. return inkParam;
  1287. }
  1288. internal static FreeTextParam GetFreeTextParam(CPDFFreeTextAnnotation freetextAnnot)
  1289. {
  1290. if (freetextAnnot == null || freetextAnnot.IsValid() == false)
  1291. {
  1292. return null;
  1293. }
  1294. FreeTextParam freetextParam = new FreeTextParam();
  1295. if (freetextAnnot.LineColor != null && freetextAnnot.LineColor.Length == 3)
  1296. {
  1297. freetextParam.LineColor = new byte[3]
  1298. {
  1299. freetextAnnot.LineColor[0],
  1300. freetextAnnot.LineColor[1],
  1301. freetextAnnot.LineColor[2]
  1302. };
  1303. }
  1304. if (freetextAnnot.HasBgColor && freetextAnnot.BgColor != null)
  1305. {
  1306. if (freetextAnnot.BgColor.Length == 3)
  1307. {
  1308. freetextParam.HasBgColor = true;
  1309. freetextParam.BgColor = new byte[3]
  1310. {
  1311. freetextAnnot.BgColor[0],
  1312. freetextAnnot.BgColor[1],
  1313. freetextAnnot.BgColor[2]
  1314. };
  1315. }
  1316. }
  1317. freetextParam.LineWidth = freetextAnnot.LineWidth;
  1318. if (freetextAnnot.FreeTextDa != null)
  1319. {
  1320. byte[] fontColor = freetextAnnot.FreeTextDa.FontColor;
  1321. if (fontColor != null && fontColor.Length == 3)
  1322. {
  1323. freetextParam.FontColor = new byte[3]
  1324. {
  1325. fontColor[0],
  1326. fontColor[1],
  1327. fontColor[2]
  1328. };
  1329. }
  1330. string fontName = freetextAnnot.FreeTextDa.FontName;
  1331. if (!string.IsNullOrEmpty(fontName))
  1332. {
  1333. freetextParam.FontName = fontName;
  1334. freetextParam.IsBold = IsBold(fontName);
  1335. freetextParam.IsItalic = IsItalic(fontName);
  1336. }
  1337. freetextParam.FontSize = freetextAnnot.FreeTextDa.FontSize;
  1338. freetextParam.Alignment = freetextAnnot.Alignment;
  1339. }
  1340. if (freetextAnnot.Dash != null && freetextAnnot.Dash.Length > 0)
  1341. {
  1342. freetextParam.Dash = new float[freetextAnnot.Dash.Length];
  1343. freetextAnnot.Dash.CopyTo(freetextParam.Dash, 0);
  1344. }
  1345. GetAnnotCommonParam(freetextAnnot, freetextParam);
  1346. return freetextParam;
  1347. }
  1348. internal static HighlightParam GetHighlightParam(CPDFHighlightAnnotation highlightAnnot)
  1349. {
  1350. if (highlightAnnot == null || highlightAnnot.IsValid() == false)
  1351. {
  1352. return null;
  1353. }
  1354. HighlightParam highlightParam = new HighlightParam();
  1355. if (highlightAnnot.Color != null && highlightAnnot.Color.Length == 3)
  1356. {
  1357. highlightParam.HighlightColor = new byte[3]
  1358. {
  1359. highlightAnnot.Color[0],
  1360. highlightAnnot.Color[1],
  1361. highlightAnnot.Color[2]
  1362. };
  1363. }
  1364. if (highlightAnnot.QuardRects != null && highlightAnnot.QuardRects.Count > 0)
  1365. {
  1366. List<CRect> saveList = new List<CRect>();
  1367. foreach (CRect saveRect in highlightAnnot.QuardRects)
  1368. {
  1369. saveList.Add(saveRect);
  1370. }
  1371. highlightParam.QuardRects = saveList;
  1372. }
  1373. GetAnnotCommonParam(highlightAnnot, highlightParam);
  1374. return highlightParam;
  1375. }
  1376. internal static UnderlineParam GetUnderlineParam(CPDFUnderlineAnnotation underlineAnnot)
  1377. {
  1378. if (underlineAnnot == null || underlineAnnot.IsValid() == false)
  1379. {
  1380. return null;
  1381. }
  1382. UnderlineParam underlineParam = new UnderlineParam();
  1383. if (underlineAnnot.Color != null && underlineAnnot.Color.Length == 3)
  1384. {
  1385. underlineParam.UnderlineColor = new byte[3]
  1386. {
  1387. underlineAnnot.Color[0],
  1388. underlineAnnot.Color[1],
  1389. underlineAnnot.Color[2]
  1390. };
  1391. }
  1392. if (underlineAnnot.QuardRects != null && underlineAnnot.QuardRects.Count > 0)
  1393. {
  1394. List<CRect> saveList = new List<CRect>();
  1395. foreach (CRect saveRect in underlineAnnot.QuardRects)
  1396. {
  1397. saveList.Add(saveRect);
  1398. }
  1399. underlineParam.QuardRects = saveList;
  1400. }
  1401. GetAnnotCommonParam(underlineAnnot, underlineParam);
  1402. return underlineParam;
  1403. }
  1404. internal static StrikeoutParam GetStrikeoutParam(CPDFStrikeoutAnnotation strikeoutAnnot)
  1405. {
  1406. if (strikeoutAnnot == null || strikeoutAnnot.IsValid() == false)
  1407. {
  1408. return null;
  1409. }
  1410. StrikeoutParam strikeoutParam = new StrikeoutParam();
  1411. if (strikeoutAnnot.Color != null && strikeoutAnnot.Color.Length == 3)
  1412. {
  1413. strikeoutParam.StrikeoutColor = new byte[3]
  1414. {
  1415. strikeoutAnnot.Color[0],
  1416. strikeoutAnnot.Color[1],
  1417. strikeoutAnnot.Color[2]
  1418. };
  1419. }
  1420. if (strikeoutAnnot.QuardRects != null && strikeoutAnnot.QuardRects.Count > 0)
  1421. {
  1422. List<CRect> saveList = new List<CRect>();
  1423. foreach (CRect saveRect in strikeoutAnnot.QuardRects)
  1424. {
  1425. saveList.Add(saveRect);
  1426. }
  1427. strikeoutParam.QuardRects = saveList;
  1428. }
  1429. GetAnnotCommonParam(strikeoutAnnot, strikeoutParam);
  1430. return strikeoutParam;
  1431. }
  1432. internal static SquigglyParam GetSquigglyParam(CPDFSquigglyAnnotation squigglyAnnot)
  1433. {
  1434. if (squigglyAnnot == null || squigglyAnnot.IsValid() == false)
  1435. {
  1436. return null;
  1437. }
  1438. SquigglyParam squigglyParam = new SquigglyParam();
  1439. if (squigglyAnnot.Color != null && squigglyAnnot.Color.Length == 3)
  1440. {
  1441. squigglyParam.SquigglyColor = new byte[3]
  1442. {
  1443. squigglyAnnot.Color[0],
  1444. squigglyAnnot.Color[1],
  1445. squigglyAnnot.Color[2]
  1446. };
  1447. }
  1448. if (squigglyAnnot.QuardRects != null && squigglyAnnot.QuardRects.Count > 0)
  1449. {
  1450. List<CRect> saveList = new List<CRect>();
  1451. foreach (CRect saveRect in squigglyAnnot.QuardRects)
  1452. {
  1453. saveList.Add(saveRect);
  1454. }
  1455. squigglyParam.QuardRects = saveList;
  1456. }
  1457. GetAnnotCommonParam(squigglyAnnot, squigglyParam);
  1458. return squigglyParam;
  1459. }
  1460. internal static StickyNoteParam GetStickynoteParam(CPDFTextAnnotation stickyAnnot)
  1461. {
  1462. if (stickyAnnot == null || stickyAnnot.IsValid() == false)
  1463. {
  1464. return null;
  1465. }
  1466. StickyNoteParam stickyParam = new StickyNoteParam();
  1467. if (stickyAnnot.Color != null && stickyAnnot.Color.Length == 3)
  1468. {
  1469. stickyParam.StickyNoteColor = new byte[3]
  1470. {
  1471. stickyAnnot.Color[0],
  1472. stickyAnnot.Color[1],
  1473. stickyAnnot.Color[2]
  1474. };
  1475. }
  1476. stickyParam.IconName=stickyAnnot.GetIconName();
  1477. GetAnnotCommonParam(stickyAnnot, stickyParam);
  1478. return stickyParam;
  1479. }
  1480. internal static StampParam GetStampParam(CPDFStampAnnotation stampAnnot)
  1481. {
  1482. if (stampAnnot == null || stampAnnot.IsValid() == false)
  1483. {
  1484. return null;
  1485. }
  1486. StampParam stampParam = new StampParam();
  1487. C_STAMP_TYPE stampType = stampAnnot.GetStampType();
  1488. switch (stampType)
  1489. {
  1490. case C_STAMP_TYPE.STANDARD_STAMP:
  1491. {
  1492. stampParam.StampText = stampAnnot.GetStandardStamp();
  1493. stampParam.StampType = stampType;
  1494. }
  1495. break;
  1496. case C_STAMP_TYPE.TEXT_STAMP:
  1497. {
  1498. string stampText = string.Empty;
  1499. string dateText = string.Empty;
  1500. C_TEXTSTAMP_SHAPE stampShape = C_TEXTSTAMP_SHAPE.TEXTSTAMP_NONE;
  1501. C_TEXTSTAMP_COLOR stampColor = C_TEXTSTAMP_COLOR.TEXTSTAMP_WHITE;
  1502. stampAnnot.GetTextStamp(ref stampText,
  1503. ref dateText,
  1504. ref stampShape,
  1505. ref stampColor);
  1506. stampParam.StampText = stampText;
  1507. stampParam.DateText = dateText;
  1508. stampParam.TextStampShape = stampShape;
  1509. stampParam.TextStampColor = stampColor;
  1510. stampParam.StampType = stampType;
  1511. }
  1512. break;
  1513. case C_STAMP_TYPE.IMAGE_STAMP:
  1514. case C_STAMP_TYPE.UNKNOWN_STAMP:
  1515. {
  1516. stampParam.StampType = stampType;
  1517. CRect rawRect = stampAnnot.GetRect();
  1518. int width = (int)(rawRect.width() / 72D * 96D);
  1519. int height = (int)(rawRect.height() / 72D * 96D);
  1520. if (width > 0 && height > 0)
  1521. {
  1522. Rect rotateRect = new Rect(0, 0, width, height);
  1523. Matrix rotateMatrix = new Matrix();
  1524. rotateMatrix.RotateAt(-90 * stampAnnot.Page.Rotation, width / 2, height / 2);
  1525. rotateRect.Transform(rotateMatrix);
  1526. int imageWidth = (int)rotateRect.Width;
  1527. int imageHeight = (int)rotateRect.Height;
  1528. byte[] ImageArray = new byte[imageWidth * imageHeight * 4];
  1529. stampAnnot.RenderAnnot(imageWidth, imageHeight, ImageArray);
  1530. WriteableBitmap writeBitmap = new WriteableBitmap(
  1531. imageWidth,
  1532. imageHeight,
  1533. 96,
  1534. 96,
  1535. PixelFormats.Bgra32,
  1536. null);
  1537. writeBitmap.WritePixels(new Int32Rect(0, 0, imageWidth, imageHeight), ImageArray, imageWidth * 4, 0);
  1538. PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
  1539. pngEncoder.Frames.Add(BitmapFrame.Create(writeBitmap));
  1540. MemoryStream memStream = new MemoryStream();
  1541. pngEncoder.Save(memStream);
  1542. stampParam.ImageStream = memStream;
  1543. }
  1544. }
  1545. break;
  1546. default:
  1547. return null;
  1548. }
  1549. stampParam.PageRotation = stampAnnot.Page.Rotation;
  1550. stampParam.Rotation = stampAnnot.AnnotationRotator.GetRotation();
  1551. CRect sourceRect = new CRect();
  1552. stampAnnot.GetSourceRect(ref sourceRect);
  1553. stampParam.SourceRect = sourceRect;
  1554. GetAnnotCommonParam(stampAnnot, stampParam);
  1555. return stampParam;
  1556. }
  1557. internal static LinkParam GetLinkParam(CPDFLinkAnnotation linkAnnot, CPDFDocument pdfDoc)
  1558. {
  1559. if (linkAnnot == null || linkAnnot.IsValid() == false)
  1560. {
  1561. return null;
  1562. }
  1563. LinkParam linkParam = new LinkParam();
  1564. CPDFAction linkAction = linkAnnot.GetLinkAction();
  1565. if (linkAction != null)
  1566. {
  1567. switch (linkAction.ActionType)
  1568. {
  1569. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  1570. {
  1571. CPDFGoToAction gotoAction = linkAction as CPDFGoToAction;
  1572. if (gotoAction != null && pdfDoc != null && pdfDoc.IsValid())
  1573. {
  1574. CPDFDestination dest = gotoAction.GetDestination(pdfDoc);
  1575. if (dest != null)
  1576. {
  1577. linkParam.Action = C_ACTION_TYPE.ACTION_TYPE_GOTO;
  1578. linkParam.DestinationPageIndex = dest.PageIndex;
  1579. linkParam.DestinationPosition = new CPoint(dest.Position_X, dest.Position_Y);
  1580. }
  1581. }
  1582. }
  1583. break;
  1584. case C_ACTION_TYPE.ACTION_TYPE_URI:
  1585. {
  1586. CPDFUriAction urlAction = linkAction as CPDFUriAction;
  1587. if (urlAction != null)
  1588. {
  1589. linkParam.Uri = urlAction.GetUri();
  1590. linkParam.Action = C_ACTION_TYPE.ACTION_TYPE_URI;
  1591. }
  1592. }
  1593. break;
  1594. default:
  1595. break;
  1596. }
  1597. }
  1598. GetAnnotCommonParam(linkAnnot, linkParam);
  1599. return linkParam;
  1600. }
  1601. internal static SoundParam GetSoundParam(CPDFSoundAnnotation stampAnnot)
  1602. {
  1603. if (stampAnnot == null || stampAnnot.IsValid() == false)
  1604. {
  1605. return null;
  1606. }
  1607. SoundParam soundParam = new SoundParam();
  1608. GetAnnotCommonParam(stampAnnot, soundParam);
  1609. return soundParam;
  1610. }
  1611. internal static RedactParam GetRedactParam(CPDFRedactAnnotation redactAnnot)
  1612. {
  1613. if(redactAnnot == null || redactAnnot.IsValid() == false)
  1614. {
  1615. return null;
  1616. }
  1617. RedactParam redactParam = new RedactParam();
  1618. if (redactAnnot.OutlineColor != null && redactAnnot.OutlineColor.Length == 3)
  1619. {
  1620. redactParam.LineColor = new byte[3] { redactAnnot.OutlineColor[0], redactAnnot.OutlineColor[1], redactAnnot.OutlineColor[2] };
  1621. }
  1622. if (redactAnnot.FillColor != null && redactAnnot.FillColor.Length == 3)
  1623. {
  1624. redactParam.BgColor = new byte[3] { redactAnnot.FillColor[0], redactAnnot.FillColor[1], redactAnnot.FillColor[2] };
  1625. }
  1626. if (redactAnnot.TextDa != null)
  1627. {
  1628. if (redactAnnot.TextDa.FontColor != null && redactAnnot.TextDa.FontColor.Length == 3)
  1629. {
  1630. redactParam.FontColor = new byte[3] { redactAnnot.TextDa.FontColor[0], redactAnnot.TextDa.FontColor[1], redactAnnot.TextDa.FontColor[2] };
  1631. }
  1632. redactParam.FontName= redactAnnot.TextDa.FontName;
  1633. redactParam.FontSize = redactAnnot.TextDa.FontSize;
  1634. redactParam.Alignment=redactAnnot.TextAlignment;
  1635. }
  1636. if(redactAnnot.QuardRects!=null)
  1637. {
  1638. redactParam.QuardRects = new List<CRect>(redactAnnot.QuardRects);
  1639. }
  1640. redactParam.OverlayText = redactAnnot.OverlayText;
  1641. GetAnnotCommonParam(redactAnnot, redactParam);
  1642. return redactParam;
  1643. }
  1644. internal static PolyLineMeasureParam GetPolyLineMeasureParam(CPDFPolylineAnnotation polylineAnnot)
  1645. {
  1646. if (polylineAnnot == null || polylineAnnot.IsValid() == false || polylineAnnot.IsMeasured()==false)
  1647. {
  1648. return null;
  1649. }
  1650. PolyLineMeasureParam measureParam = new PolyLineMeasureParam();
  1651. CPDFPerimeterMeasure perimeterMeasure = polylineAnnot.GetPerimeterMeasure();
  1652. measureParam.measureInfo= perimeterMeasure.MeasureInfo;
  1653. if (polylineAnnot.LineColor != null && polylineAnnot.LineColor.Length == 3)
  1654. {
  1655. measureParam.LineColor = new byte[3] { polylineAnnot.LineColor[0], polylineAnnot.LineColor[1], polylineAnnot.LineColor[2] };
  1656. }
  1657. measureParam.SavePoints = polylineAnnot.Points;
  1658. measureParam.BorderStyle = polylineAnnot.BorderStyle;
  1659. measureParam.LineWidth=polylineAnnot.LineWidth;
  1660. measureParam.Transparency=polylineAnnot.Transparency;
  1661. measureParam.LineDash=polylineAnnot.Dash;
  1662. CTextAttribute textAttr = polylineAnnot.GetTextAttribute();
  1663. measureParam.FontName = textAttr.FontName;
  1664. measureParam.FontSize = textAttr.FontSize;
  1665. if(textAttr.FontColor!=null && textAttr.FontColor.Length == 3)
  1666. {
  1667. measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
  1668. }
  1669. measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
  1670. measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
  1671. GetAnnotCommonParam(polylineAnnot, measureParam);
  1672. return measureParam;
  1673. }
  1674. internal static PolygonMeasureParam GetPolygonMeasureParam(CPDFPolygonAnnotation polygonAnnot)
  1675. {
  1676. if (polygonAnnot == null || polygonAnnot.IsValid() == false)
  1677. {
  1678. return null;
  1679. }
  1680. PolygonMeasureParam measureParam = new PolygonMeasureParam();
  1681. if(polygonAnnot.IsMeasured())
  1682. {
  1683. CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure();
  1684. measureParam.measureInfo = areaMeasure.MeasureInfo;
  1685. CTextAttribute textAttr = polygonAnnot.GetTextAttribute();
  1686. measureParam.FontName = textAttr.FontName;
  1687. measureParam.FontSize = textAttr.FontSize;
  1688. if (textAttr.FontColor != null && textAttr.FontColor.Length == 3)
  1689. {
  1690. measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
  1691. }
  1692. measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
  1693. measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
  1694. }
  1695. if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3)
  1696. {
  1697. measureParam.LineColor = new byte[] { polygonAnnot.LineColor[0], polygonAnnot.LineColor[1], polygonAnnot.LineColor[2] };
  1698. }
  1699. if(polygonAnnot.HasBgColor && polygonAnnot.BgColor!=null && polygonAnnot.BgColor.Length == 3)
  1700. {
  1701. measureParam.HasFillColor = true;
  1702. measureParam.FillColor = new byte[] { polygonAnnot.BgColor[0], polygonAnnot.BgColor[1], polygonAnnot.BgColor[2] };
  1703. }
  1704. measureParam.SavePoints = polygonAnnot.Points;
  1705. measureParam.BorderStyle = polygonAnnot.BorderStyle;
  1706. measureParam.LineWidth = polygonAnnot.LineWidth;
  1707. measureParam.Transparency = polygonAnnot.Transparency;
  1708. measureParam.LineDash = polygonAnnot.Dash;
  1709. measureParam.BorderEffector = polygonAnnot.GetAnnotBorderEffector();
  1710. GetAnnotCommonParam(polygonAnnot, measureParam);
  1711. return measureParam;
  1712. }
  1713. #endregion
  1714. public static bool SetParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1715. {
  1716. bool successful = false;
  1717. if (cPDFAnnotation == null && !cPDFAnnotation.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid())
  1718. {
  1719. return successful;
  1720. }
  1721. if (cPDFAnnotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
  1722. {
  1723. successful = SetWidgetParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
  1724. }
  1725. else
  1726. {
  1727. successful = SetAnnotParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
  1728. }
  1729. return successful;
  1730. }
  1731. #region SetWidegt
  1732. internal static bool SetWidgetParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1733. {
  1734. bool successful = false;
  1735. if (cPDFAnnotation is CPDFWidget)
  1736. {
  1737. switch ((cPDFAnnotation as CPDFWidget).WidgetType)
  1738. {
  1739. case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  1740. successful = SetPushButtonParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
  1741. break;
  1742. case C_WIDGET_TYPE.WIDGET_CHECKBOX:
  1743. successful = SetCheckBoxParamForPDFAnnot(cPDFAnnotation, param);
  1744. break;
  1745. case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  1746. successful = SetRadioButtonParamForPDFAnnot(cPDFAnnotation, param);
  1747. break;
  1748. case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  1749. successful = SetTextBoxParamForPDFAnnot(cPDFAnnotation, param);
  1750. break;
  1751. case C_WIDGET_TYPE.WIDGET_COMBOBOX:
  1752. successful = SetComboBoxParamForPDFAnnot(cPDFAnnotation, param);
  1753. break;
  1754. case C_WIDGET_TYPE.WIDGET_LISTBOX:
  1755. successful = SetListBoxParamForPDFAnnot(cPDFAnnotation, param);
  1756. break;
  1757. case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  1758. successful = SetSignatureParamForPDFAnnot(cPDFAnnotation, param);
  1759. break;
  1760. default:
  1761. successful = false;
  1762. break;
  1763. }
  1764. }
  1765. return successful;
  1766. }
  1767. internal static bool SetPushButtonParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1768. {
  1769. PushButtonParam CurrentParam = param as PushButtonParam;
  1770. CPDFPushButtonWidget pushbuttonWidget = cPDFAnnotation as CPDFPushButtonWidget;
  1771. bool successful = false;
  1772. if (pushbuttonWidget == null && !pushbuttonWidget.IsValid() && CurrentParam == null)
  1773. {
  1774. return successful;
  1775. }
  1776. else
  1777. {
  1778. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  1779. {
  1780. pushbuttonWidget.SetFieldName(CurrentParam.FieldName);
  1781. }
  1782. if (CurrentParam.HasLineColor)
  1783. {
  1784. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  1785. {
  1786. pushbuttonWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  1787. }
  1788. }
  1789. if (CurrentParam.HasBgColor)
  1790. {
  1791. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  1792. {
  1793. pushbuttonWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  1794. }
  1795. }
  1796. if (!string.IsNullOrEmpty(CurrentParam.Text))
  1797. {
  1798. pushbuttonWidget.SetButtonTitle(CurrentParam.Text);
  1799. }
  1800. pushbuttonWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  1801. pushbuttonWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  1802. CTextAttribute textAttr = new CTextAttribute();
  1803. byte[] fontColor = new byte[3];
  1804. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  1805. {
  1806. fontColor = CurrentParam.FontColor;
  1807. }
  1808. textAttr.FontColor = fontColor;
  1809. textAttr.FontSize = (float)CurrentParam.FontSize;
  1810. textAttr.FontName = ObtainFontName(
  1811. GetFontType(CurrentParam.FontName),
  1812. CurrentParam.IsBold,
  1813. CurrentParam.IsItalic);
  1814. pushbuttonWidget.SetTextAttribute(textAttr);
  1815. switch (CurrentParam.Action)
  1816. {
  1817. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  1818. {
  1819. CPDFGoToAction gotoAction = new CPDFGoToAction();
  1820. CPDFDestination destination = new CPDFDestination();
  1821. destination.Position_X = CurrentParam.DestinationPosition.x;
  1822. destination.Position_Y = CurrentParam.DestinationPosition.y;
  1823. destination.PageIndex = CurrentParam.DestinationPageIndex;
  1824. gotoAction.SetDestination(cPDFDocument, destination);
  1825. pushbuttonWidget.SetButtonAction(gotoAction);
  1826. }
  1827. break;
  1828. case C_ACTION_TYPE.ACTION_TYPE_URI:
  1829. {
  1830. CPDFUriAction uriAction = new CPDFUriAction();
  1831. uriAction.SetUri(CurrentParam.Uri);
  1832. pushbuttonWidget.SetButtonAction(uriAction);
  1833. }
  1834. break;
  1835. default:
  1836. break;
  1837. }
  1838. pushbuttonWidget.SetRect(CurrentParam.ClientRect);
  1839. pushbuttonWidget.SetFlags(CurrentParam.Flags);
  1840. pushbuttonWidget.SetIsLocked(CurrentParam.Locked);
  1841. pushbuttonWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  1842. pushbuttonWidget.SetIsHidden(CurrentParam.IsHidden);
  1843. pushbuttonWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  1844. pushbuttonWidget.UpdateFormAp();
  1845. successful = true;
  1846. return successful;
  1847. }
  1848. }
  1849. internal static bool SetCheckBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1850. {
  1851. CheckBoxParam CurrentParam = param as CheckBoxParam;
  1852. CPDFCheckBoxWidget checkboxWidget = cPDFAnnotation as CPDFCheckBoxWidget;
  1853. bool successful = false;
  1854. if (checkboxWidget == null && !checkboxWidget.IsValid() && CurrentParam == null)
  1855. {
  1856. return successful;
  1857. }
  1858. else
  1859. {
  1860. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  1861. {
  1862. checkboxWidget.SetFieldName(CurrentParam.FieldName);
  1863. }
  1864. checkboxWidget.SetWidgetCheckStyle(CurrentParam.CheckStyle);
  1865. checkboxWidget.SetChecked(CurrentParam.IsChecked);
  1866. if (CurrentParam.HasLineColor)
  1867. {
  1868. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  1869. {
  1870. checkboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  1871. }
  1872. }
  1873. if (CurrentParam.HasBgColor)
  1874. {
  1875. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  1876. {
  1877. checkboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  1878. }
  1879. }
  1880. checkboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  1881. checkboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  1882. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  1883. {
  1884. CTextAttribute textAttr = checkboxWidget.GetTextAttribute();
  1885. textAttr.FontColor = CurrentParam.FontColor;
  1886. checkboxWidget.SetTextAttribute(textAttr);
  1887. }
  1888. checkboxWidget.SetRect(CurrentParam.ClientRect);
  1889. checkboxWidget.SetFlags(CurrentParam.Flags);
  1890. checkboxWidget.SetIsLocked(CurrentParam.Locked);
  1891. checkboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  1892. checkboxWidget.SetIsHidden(CurrentParam.IsHidden);
  1893. checkboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  1894. checkboxWidget.UpdateFormAp();
  1895. successful = true;
  1896. return successful;
  1897. }
  1898. }
  1899. internal static bool SetRadioButtonParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1900. {
  1901. RadioButtonParam CurrentParam = param as RadioButtonParam;
  1902. CPDFRadioButtonWidget radioWidget = cPDFAnnotation as CPDFRadioButtonWidget;
  1903. bool successful = false;
  1904. if (radioWidget == null && !radioWidget.IsValid() && CurrentParam == null)
  1905. {
  1906. return successful;
  1907. }
  1908. else
  1909. {
  1910. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  1911. {
  1912. radioWidget.SetFieldName(CurrentParam.FieldName);
  1913. }
  1914. radioWidget.SetWidgetCheckStyle(CurrentParam.CheckStyle);
  1915. radioWidget.SetChecked(CurrentParam.IsChecked);
  1916. if (CurrentParam.HasLineColor)
  1917. {
  1918. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  1919. {
  1920. radioWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  1921. }
  1922. }
  1923. if (CurrentParam.HasBgColor)
  1924. {
  1925. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  1926. {
  1927. radioWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  1928. }
  1929. }
  1930. radioWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  1931. radioWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  1932. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  1933. {
  1934. CTextAttribute textAttr = radioWidget.GetTextAttribute();
  1935. textAttr.FontColor = CurrentParam.FontColor;
  1936. radioWidget.SetTextAttribute(textAttr);
  1937. }
  1938. radioWidget.SetRect(CurrentParam.ClientRect);
  1939. radioWidget.SetFlags(CurrentParam.Flags);
  1940. radioWidget.SetIsLocked(CurrentParam.Locked);
  1941. radioWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  1942. radioWidget.SetIsHidden(CurrentParam.IsHidden);
  1943. radioWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  1944. radioWidget.UpdateFormAp();
  1945. successful = true;
  1946. return successful;
  1947. }
  1948. }
  1949. internal static bool SetTextBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  1950. {
  1951. TextBoxParam CurrentParam = param as TextBoxParam;
  1952. CPDFTextWidget textWidget = cPDFAnnotation as CPDFTextWidget;
  1953. bool successful = false;
  1954. if (textWidget == null && !textWidget.IsValid() && CurrentParam == null)
  1955. {
  1956. return successful;
  1957. }
  1958. else
  1959. {
  1960. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  1961. {
  1962. textWidget.SetFieldName(CurrentParam.FieldName);
  1963. }
  1964. if (CurrentParam.HasLineColor)
  1965. {
  1966. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  1967. {
  1968. textWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  1969. }
  1970. }
  1971. if (CurrentParam.HasBgColor)
  1972. {
  1973. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  1974. {
  1975. textWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  1976. }
  1977. }
  1978. if (!string.IsNullOrEmpty(CurrentParam.Text))
  1979. {
  1980. textWidget.SetText(CurrentParam.Text);
  1981. }
  1982. CTextAttribute textAttr = new CTextAttribute();
  1983. byte[] fontColor = new byte[3];
  1984. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  1985. {
  1986. fontColor = CurrentParam.FontColor;
  1987. }
  1988. textAttr.FontColor = fontColor;
  1989. textAttr.FontSize = (float)CurrentParam.FontSize;
  1990. textAttr.FontName = ObtainFontName(
  1991. GetFontType(CurrentParam.FontName),
  1992. CurrentParam.IsBold,
  1993. CurrentParam.IsItalic);
  1994. textWidget.SetTextAttribute(textAttr);
  1995. textWidget.SetJustification(CurrentParam.Alignment);
  1996. textWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  1997. textWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  1998. textWidget.SetMultiLine(CurrentParam.IsMultiLine);
  1999. textWidget.SetRect(CurrentParam.ClientRect);
  2000. textWidget.SetFlags(CurrentParam.Flags);
  2001. textWidget.SetIsLocked(CurrentParam.Locked);
  2002. textWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  2003. textWidget.SetIsHidden(CurrentParam.IsHidden);
  2004. textWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2005. textWidget.UpdateFormAp();
  2006. successful = true;
  2007. return successful;
  2008. }
  2009. }
  2010. internal static bool SetComboBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2011. {
  2012. ComboBoxParam CurrentParam = param as ComboBoxParam;
  2013. CPDFComboBoxWidget comboboxWidget = cPDFAnnotation as CPDFComboBoxWidget;
  2014. bool successful = false;
  2015. if (comboboxWidget == null && !comboboxWidget.IsValid() && CurrentParam == null)
  2016. {
  2017. return successful;
  2018. }
  2019. else
  2020. {
  2021. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  2022. {
  2023. comboboxWidget.SetFieldName(CurrentParam.FieldName);
  2024. }
  2025. if (CurrentParam.HasLineColor)
  2026. {
  2027. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2028. {
  2029. comboboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  2030. }
  2031. }
  2032. if (CurrentParam.HasBgColor)
  2033. {
  2034. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2035. {
  2036. comboboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  2037. }
  2038. }
  2039. comboboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  2040. comboboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  2041. CTextAttribute textAttr = new CTextAttribute();
  2042. byte[] fontColor = new byte[3];
  2043. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  2044. {
  2045. fontColor = CurrentParam.FontColor;
  2046. }
  2047. textAttr.FontColor = fontColor;
  2048. textAttr.FontSize = (float)CurrentParam.FontSize;
  2049. textAttr.FontName = ObtainFontName(
  2050. GetFontType(CurrentParam.FontName),
  2051. CurrentParam.IsBold,
  2052. CurrentParam.IsItalic);
  2053. comboboxWidget.SetTextAttribute(textAttr);
  2054. if (CurrentParam.OptionItems != null && CurrentParam.OptionItems.Count > 0)
  2055. {
  2056. int addIndex = 0;
  2057. foreach (string key in CurrentParam.OptionItems.Keys)
  2058. {
  2059. comboboxWidget.AddOptionItem(addIndex, CurrentParam.OptionItems[key], key);
  2060. addIndex++;
  2061. }
  2062. }
  2063. if (CurrentParam.SelectItemsIndex != null && CurrentParam.SelectItemsIndex.Count > 0)
  2064. {
  2065. comboboxWidget.SelectItem(CurrentParam.SelectItemsIndex[0]);
  2066. }
  2067. comboboxWidget.SetRect(CurrentParam.ClientRect);
  2068. comboboxWidget.SetFlags(CurrentParam.Flags);
  2069. comboboxWidget.SetIsLocked(CurrentParam.Locked);
  2070. comboboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  2071. comboboxWidget.SetIsHidden(CurrentParam.IsHidden);
  2072. comboboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2073. comboboxWidget.UpdateFormAp();
  2074. successful = true;
  2075. return successful;
  2076. }
  2077. }
  2078. internal static bool SetListBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2079. {
  2080. ListBoxParam CurrentParam = param as ListBoxParam;
  2081. CPDFListBoxWidget listboxWidget = cPDFAnnotation as CPDFListBoxWidget;
  2082. bool successful = false;
  2083. if (listboxWidget == null && !listboxWidget.IsValid() && CurrentParam == null)
  2084. {
  2085. return successful;
  2086. }
  2087. else
  2088. {
  2089. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  2090. {
  2091. listboxWidget.SetFieldName(CurrentParam.FieldName);
  2092. }
  2093. if (CurrentParam.HasLineColor)
  2094. {
  2095. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2096. {
  2097. listboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  2098. }
  2099. }
  2100. if (CurrentParam.HasBgColor)
  2101. {
  2102. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2103. {
  2104. listboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  2105. }
  2106. }
  2107. listboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  2108. listboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  2109. CTextAttribute textAttr = new CTextAttribute();
  2110. byte[] fontColor = new byte[3];
  2111. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  2112. {
  2113. fontColor = CurrentParam.FontColor;
  2114. }
  2115. textAttr.FontColor = fontColor;
  2116. textAttr.FontSize = (float)CurrentParam.FontSize;
  2117. textAttr.FontName = ObtainFontName(
  2118. GetFontType(CurrentParam.FontName),
  2119. CurrentParam.IsBold,
  2120. CurrentParam.IsItalic);
  2121. listboxWidget.SetTextAttribute(textAttr);
  2122. if (CurrentParam.OptionItems != null && CurrentParam.OptionItems.Count > 0)
  2123. {
  2124. int addIndex = 0;
  2125. foreach (string key in CurrentParam.OptionItems.Keys)
  2126. {
  2127. listboxWidget.AddOptionItem(addIndex, CurrentParam.OptionItems[key], key);
  2128. addIndex++;
  2129. }
  2130. }
  2131. if (CurrentParam.SelectItemsIndex != null && CurrentParam.SelectItemsIndex.Count > 0)
  2132. {
  2133. listboxWidget.SelectItem(CurrentParam.SelectItemsIndex[0]);
  2134. }
  2135. listboxWidget.SetRect(CurrentParam.ClientRect);
  2136. listboxWidget.SetFlags(CurrentParam.Flags);
  2137. listboxWidget.SetIsLocked(CurrentParam.Locked);
  2138. listboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  2139. listboxWidget.SetIsHidden(CurrentParam.IsHidden);
  2140. listboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2141. listboxWidget.UpdateFormAp();
  2142. successful = true;
  2143. return successful;
  2144. }
  2145. }
  2146. internal static bool SetSignatureParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2147. {
  2148. SignatureParam CurrentParam = param as SignatureParam;
  2149. CPDFSignatureWidget signWidget = cPDFAnnotation as CPDFSignatureWidget;
  2150. bool successful = false;
  2151. if (signWidget == null && !signWidget.IsValid() && CurrentParam == null)
  2152. {
  2153. return successful;
  2154. }
  2155. else
  2156. {
  2157. if (!string.IsNullOrEmpty(CurrentParam.FieldName))
  2158. {
  2159. signWidget.SetFieldName(CurrentParam.FieldName);
  2160. }
  2161. if (CurrentParam.HasLineColor)
  2162. {
  2163. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2164. {
  2165. signWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
  2166. }
  2167. }
  2168. if (CurrentParam.HasBgColor)
  2169. {
  2170. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2171. {
  2172. signWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
  2173. }
  2174. }
  2175. signWidget.SetBorderWidth((float)CurrentParam.LineWidth);
  2176. signWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
  2177. signWidget.SetRect(CurrentParam.ClientRect);
  2178. signWidget.SetFlags(CurrentParam.Flags);
  2179. signWidget.SetIsLocked(CurrentParam.Locked);
  2180. signWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
  2181. signWidget.SetIsHidden(CurrentParam.IsHidden);
  2182. signWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2183. signWidget.UpdateFormAp();
  2184. successful = true;
  2185. return successful;
  2186. }
  2187. }
  2188. #endregion
  2189. #region SetAnnot
  2190. internal static bool SetAnnotParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2191. {
  2192. bool successful = false;
  2193. if (cPDFAnnotation != null)
  2194. {
  2195. switch (cPDFAnnotation.Type)
  2196. {
  2197. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  2198. successful = SetSquareAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2199. break;
  2200. case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  2201. successful = SetCircleAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2202. break;
  2203. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  2204. successful = SetLineAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2205. break;
  2206. case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  2207. successful = SetInkAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2208. break;
  2209. case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  2210. successful = SetFreeTextAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2211. break;
  2212. case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  2213. successful = SetHighlightAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2214. break;
  2215. case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  2216. successful = SetUnderlineAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2217. break;
  2218. case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  2219. successful = SetStrikeoutAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2220. break;
  2221. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  2222. successful = SetSquigglyAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2223. break;
  2224. case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  2225. successful = SetTextAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2226. break;
  2227. case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  2228. successful = SetStampAnnotParamForPDFAnnot(cPDFAnnotation, param);
  2229. break;
  2230. case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  2231. successful = SetLinkAnnotParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
  2232. break;
  2233. default:
  2234. break;
  2235. }
  2236. }
  2237. return successful;
  2238. }
  2239. internal static bool SetSquareAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2240. {
  2241. SquareParam CurrentParam = param as SquareParam;
  2242. CPDFSquareAnnotation squareAnnot = cPDFAnnotation as CPDFSquareAnnotation;
  2243. bool successful = false;
  2244. if (squareAnnot == null && !squareAnnot.IsValid() && CurrentParam == null)
  2245. {
  2246. return successful;
  2247. }
  2248. else
  2249. {
  2250. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2251. {
  2252. squareAnnot.SetLineColor(CurrentParam.LineColor);
  2253. }
  2254. if (CurrentParam.HasBgColor)
  2255. {
  2256. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2257. {
  2258. squareAnnot.SetBgColor(CurrentParam.BgColor);
  2259. }
  2260. }
  2261. squareAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2262. squareAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
  2263. squareAnnot.SetRect(CurrentParam.ClientRect);
  2264. List<float> floatArray = new List<float>();
  2265. if (CurrentParam.LineDash != null)
  2266. {
  2267. foreach (float num in CurrentParam.LineDash)
  2268. {
  2269. floatArray.Add(num);
  2270. }
  2271. }
  2272. squareAnnot.SetBorderStyle(CurrentParam.BorderStyle, floatArray.ToArray());
  2273. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2274. {
  2275. squareAnnot.SetAuthor(CurrentParam.Author);
  2276. }
  2277. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2278. {
  2279. squareAnnot.SetContent(CurrentParam.Content);
  2280. }
  2281. squareAnnot.SetIsLocked(CurrentParam.Locked);
  2282. squareAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2283. squareAnnot.UpdateAp();
  2284. successful = true;
  2285. return successful;
  2286. }
  2287. }
  2288. internal static bool SetCircleAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2289. {
  2290. CircleParam CurrentParam = param as CircleParam;
  2291. CPDFCircleAnnotation circleAnnot = cPDFAnnotation as CPDFCircleAnnotation;
  2292. bool successful = false;
  2293. if (circleAnnot == null && !circleAnnot.IsValid() && CurrentParam == null)
  2294. {
  2295. return successful;
  2296. }
  2297. else
  2298. {
  2299. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2300. {
  2301. circleAnnot.SetLineColor(CurrentParam.LineColor);
  2302. }
  2303. if (CurrentParam.HasBgColor)
  2304. {
  2305. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2306. {
  2307. circleAnnot.SetBgColor(CurrentParam.BgColor);
  2308. }
  2309. }
  2310. circleAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2311. circleAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
  2312. circleAnnot.SetRect(CurrentParam.ClientRect);
  2313. List<float> floatArray = new List<float>();
  2314. if (CurrentParam.LineDash != null)
  2315. {
  2316. foreach (float num in CurrentParam.LineDash)
  2317. {
  2318. floatArray.Add(num);
  2319. }
  2320. }
  2321. circleAnnot.SetBorderStyle(CurrentParam.BorderStyle, floatArray.ToArray());
  2322. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2323. {
  2324. circleAnnot.SetAuthor(CurrentParam.Author);
  2325. }
  2326. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2327. {
  2328. circleAnnot.SetContent(CurrentParam.Content);
  2329. }
  2330. circleAnnot.SetIsLocked(CurrentParam.Locked);
  2331. circleAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2332. circleAnnot.UpdateAp();
  2333. successful = true;
  2334. return successful;
  2335. }
  2336. }
  2337. internal static bool SetLineAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2338. {
  2339. LineParam CurrentParam = param as LineParam;
  2340. CPDFLineAnnotation lineAnnot = cPDFAnnotation as CPDFLineAnnotation;
  2341. bool successful = false;
  2342. if (lineAnnot == null && !lineAnnot.IsValid() && CurrentParam == null)
  2343. {
  2344. return successful;
  2345. }
  2346. else
  2347. {
  2348. if (CurrentParam.HeadLineType != C_LINE_TYPE.LINETYPE_NONE || CurrentParam.TailLineType != C_LINE_TYPE.LINETYPE_NONE)
  2349. {
  2350. lineAnnot.SetLineType(CurrentParam.HeadLineType, CurrentParam.TailLineType);
  2351. }
  2352. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2353. {
  2354. lineAnnot.SetLineColor(CurrentParam.LineColor);
  2355. }
  2356. if (CurrentParam.HasBgColor)
  2357. {
  2358. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2359. {
  2360. lineAnnot.SetBgColor(CurrentParam.BgColor);
  2361. }
  2362. }
  2363. lineAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2364. lineAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
  2365. lineAnnot.SetLinePoints(CurrentParam.HeadPoint, CurrentParam.TailPoint);
  2366. lineAnnot.SetRect(CurrentParam.ClientRect);
  2367. List<float> floatArray = new List<float>();
  2368. if (CurrentParam.LineDash != null)
  2369. {
  2370. foreach (float num in CurrentParam.LineDash)
  2371. {
  2372. floatArray.Add(num);
  2373. }
  2374. }
  2375. lineAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, floatArray.ToArray());
  2376. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2377. {
  2378. lineAnnot.SetAuthor(CurrentParam.Author);
  2379. }
  2380. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2381. {
  2382. lineAnnot.SetContent(CurrentParam.Content);
  2383. }
  2384. lineAnnot.SetIsLocked(CurrentParam.Locked);
  2385. lineAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2386. lineAnnot.UpdateAp();
  2387. successful = true;
  2388. return successful;
  2389. }
  2390. }
  2391. internal static bool SetInkAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2392. {
  2393. InkParam CurrentParam = param as InkParam;
  2394. CPDFInkAnnotation inkAnnot = cPDFAnnotation as CPDFInkAnnotation;
  2395. bool successful = false;
  2396. if (inkAnnot == null && !inkAnnot.IsValid() && CurrentParam == null)
  2397. {
  2398. return successful;
  2399. }
  2400. else
  2401. {
  2402. if (CurrentParam.InkColor != null && CurrentParam.InkColor.Length == 3)
  2403. {
  2404. inkAnnot.SetInkColor(CurrentParam.InkColor);
  2405. }
  2406. inkAnnot.SetThickness((float)CurrentParam.Thickness);
  2407. inkAnnot.SetInkPath(CurrentParam.InkPath);
  2408. inkAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2409. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2410. {
  2411. inkAnnot.SetAuthor(CurrentParam.Author);
  2412. }
  2413. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2414. {
  2415. inkAnnot.SetContent(CurrentParam.Content);
  2416. }
  2417. inkAnnot.SetIsLocked(CurrentParam.Locked);
  2418. inkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2419. inkAnnot.UpdateAp();
  2420. successful = true;
  2421. return successful;
  2422. }
  2423. }
  2424. internal static bool SetHighlightAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2425. {
  2426. HighlightParam CurrentParam = param as HighlightParam;
  2427. CPDFHighlightAnnotation highlightAnnot = cPDFAnnotation as CPDFHighlightAnnotation;
  2428. bool successful = false;
  2429. if (highlightAnnot == null && !highlightAnnot.IsValid() && CurrentParam == null)
  2430. {
  2431. return successful;
  2432. }
  2433. else
  2434. {
  2435. highlightAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2436. if (CurrentParam.QuardRects != null)
  2437. {
  2438. highlightAnnot.SetQuardRects(CurrentParam.QuardRects);
  2439. }
  2440. if (CurrentParam.HighlightColor != null && CurrentParam.HighlightColor.Length == 3)
  2441. {
  2442. highlightAnnot.SetColor(CurrentParam.HighlightColor);
  2443. }
  2444. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2445. {
  2446. highlightAnnot.SetAuthor(CurrentParam.Author);
  2447. }
  2448. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2449. {
  2450. highlightAnnot.SetContent(CurrentParam.Content);
  2451. }
  2452. highlightAnnot.SetRect(CurrentParam.ClientRect);
  2453. highlightAnnot.SetIsLocked(CurrentParam.Locked);
  2454. highlightAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2455. highlightAnnot.UpdateAp();
  2456. successful = true;
  2457. return successful;
  2458. }
  2459. }
  2460. internal static bool SetUnderlineAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2461. {
  2462. UnderlineParam CurrentParam = param as UnderlineParam;
  2463. CPDFUnderlineAnnotation underlineAnnot = cPDFAnnotation as CPDFUnderlineAnnotation;
  2464. bool successful = false;
  2465. if (underlineAnnot == null && !underlineAnnot.IsValid() && CurrentParam == null)
  2466. {
  2467. return successful;
  2468. }
  2469. else
  2470. {
  2471. underlineAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2472. underlineAnnot.SetRect(CurrentParam.ClientRect);
  2473. if (CurrentParam.QuardRects != null)
  2474. {
  2475. underlineAnnot.SetQuardRects(CurrentParam.QuardRects);
  2476. }
  2477. if (CurrentParam.UnderlineColor != null && CurrentParam.UnderlineColor.Length == 3)
  2478. {
  2479. underlineAnnot.SetColor(CurrentParam.UnderlineColor);
  2480. }
  2481. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2482. {
  2483. underlineAnnot.SetAuthor(CurrentParam.Author);
  2484. }
  2485. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2486. {
  2487. underlineAnnot.SetContent(CurrentParam.Content);
  2488. }
  2489. underlineAnnot.SetIsLocked(CurrentParam.Locked);
  2490. underlineAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2491. underlineAnnot.UpdateAp();
  2492. successful = true;
  2493. return successful;
  2494. }
  2495. }
  2496. internal static bool SetStrikeoutAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2497. {
  2498. StrikeoutParam CurrentParam = param as StrikeoutParam;
  2499. CPDFStrikeoutAnnotation strikeoutAnnot = cPDFAnnotation as CPDFStrikeoutAnnotation;
  2500. bool successful = false;
  2501. if (strikeoutAnnot == null && !strikeoutAnnot.IsValid() && CurrentParam == null)
  2502. {
  2503. return successful;
  2504. }
  2505. else
  2506. {
  2507. strikeoutAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2508. strikeoutAnnot.SetRect(CurrentParam.ClientRect);
  2509. if (CurrentParam.QuardRects != null)
  2510. {
  2511. strikeoutAnnot.SetQuardRects(CurrentParam.QuardRects);
  2512. }
  2513. if (CurrentParam.StrikeoutColor != null && CurrentParam.StrikeoutColor.Length == 3)
  2514. {
  2515. strikeoutAnnot.SetColor(CurrentParam.StrikeoutColor);
  2516. }
  2517. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2518. {
  2519. strikeoutAnnot.SetAuthor(CurrentParam.Author);
  2520. }
  2521. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2522. {
  2523. strikeoutAnnot.SetContent(CurrentParam.Content);
  2524. }
  2525. strikeoutAnnot.SetIsLocked(CurrentParam.Locked);
  2526. strikeoutAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2527. strikeoutAnnot.UpdateAp();
  2528. successful = true;
  2529. return successful;
  2530. }
  2531. }
  2532. internal static bool SetSquigglyAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2533. {
  2534. SquigglyParam CurrentParam = param as SquigglyParam;
  2535. CPDFSquigglyAnnotation squigglyAnnot = cPDFAnnotation as CPDFSquigglyAnnotation;
  2536. bool successful = false;
  2537. if (squigglyAnnot == null && !squigglyAnnot.IsValid() && CurrentParam == null)
  2538. {
  2539. return successful;
  2540. }
  2541. else
  2542. {
  2543. squigglyAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2544. squigglyAnnot.SetRect(CurrentParam.ClientRect);
  2545. if (CurrentParam.QuardRects != null)
  2546. {
  2547. squigglyAnnot.SetQuardRects(CurrentParam.QuardRects);
  2548. }
  2549. if (CurrentParam.SquigglyColor != null && CurrentParam.SquigglyColor.Length == 3)
  2550. {
  2551. squigglyAnnot.SetColor(CurrentParam.SquigglyColor);
  2552. }
  2553. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2554. {
  2555. squigglyAnnot.SetAuthor(CurrentParam.Author);
  2556. }
  2557. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2558. {
  2559. squigglyAnnot.SetContent(CurrentParam.Content);
  2560. }
  2561. squigglyAnnot.SetIsLocked(CurrentParam.Locked);
  2562. squigglyAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2563. squigglyAnnot.UpdateAp();
  2564. successful = true;
  2565. return successful;
  2566. }
  2567. }
  2568. internal static bool SetFreeTextAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2569. {
  2570. FreeTextParam CurrentParam = param as FreeTextParam;
  2571. CPDFFreeTextAnnotation textAnnot = cPDFAnnotation as CPDFFreeTextAnnotation;
  2572. bool successful = false;
  2573. if (textAnnot == null && !textAnnot.IsValid() && CurrentParam == null)
  2574. {
  2575. return successful;
  2576. }
  2577. else
  2578. {
  2579. if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
  2580. {
  2581. textAnnot.SetLineColor(CurrentParam.LineColor);
  2582. }
  2583. if (CurrentParam.HasBgColor)
  2584. {
  2585. if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
  2586. {
  2587. textAnnot.SetBgColor(CurrentParam.BgColor);
  2588. }
  2589. }
  2590. textAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2591. textAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
  2592. textAnnot.SetFreetextAlignment(CurrentParam.Alignment);
  2593. CTextAttribute textAttr = new CTextAttribute();
  2594. byte[] fontColor = new byte[3];
  2595. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  2596. {
  2597. fontColor = CurrentParam.FontColor;
  2598. }
  2599. textAttr.FontColor = fontColor;
  2600. textAttr.FontSize = (float)CurrentParam.FontSize;
  2601. textAttr.FontName = ObtainFontName(
  2602. GetFontType(CurrentParam.FontName),
  2603. CurrentParam.IsBold,
  2604. CurrentParam.IsItalic);
  2605. textAnnot.SetFreetextDa(textAttr);
  2606. textAnnot.SetRect(CurrentParam.ClientRect);
  2607. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2608. {
  2609. textAnnot.SetAuthor(CurrentParam.Author);
  2610. }
  2611. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2612. {
  2613. textAnnot.SetContent(CurrentParam.Content);
  2614. }
  2615. textAnnot.SetIsLocked(CurrentParam.Locked);
  2616. textAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2617. textAnnot.UpdateAp();
  2618. successful = true;
  2619. return successful;
  2620. }
  2621. }
  2622. internal static bool SetStampAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2623. {
  2624. StampParam CurrentParam = param as StampParam;
  2625. CPDFStampAnnotation stampAnnot = cPDFAnnotation as CPDFStampAnnotation;
  2626. bool successful = false;
  2627. if (stampAnnot == null && !stampAnnot.IsValid() && CurrentParam == null)
  2628. {
  2629. return successful;
  2630. }
  2631. else
  2632. {
  2633. switch (CurrentParam.StampType)
  2634. {
  2635. case C_STAMP_TYPE.STANDARD_STAMP:
  2636. {
  2637. string stampText = CurrentParam.StampText;
  2638. if (stampText == null)
  2639. {
  2640. stampText = string.Empty;
  2641. }
  2642. stampAnnot.SetStandardStamp(stampText, CurrentParam.PageRotation);
  2643. stampAnnot.SetRect(CurrentParam.ClientRect);
  2644. }
  2645. break;
  2646. case C_STAMP_TYPE.TEXT_STAMP:
  2647. {
  2648. string dateText = CurrentParam.DateText;
  2649. string stampText = CurrentParam.StampText;
  2650. if (dateText == null)
  2651. {
  2652. dateText = string.Empty;
  2653. }
  2654. if (stampText == null)
  2655. {
  2656. stampText = string.Empty;
  2657. }
  2658. stampAnnot.SetTextStamp(
  2659. stampText,
  2660. dateText,
  2661. CurrentParam.TextStampShape,
  2662. CurrentParam.TextStampColor,
  2663. CurrentParam.PageRotation);
  2664. stampAnnot.SetRect(CurrentParam.ClientRect);
  2665. }
  2666. break;
  2667. case C_STAMP_TYPE.IMAGE_STAMP:
  2668. {
  2669. byte[] imageData = null;
  2670. int imageWidth = 0;
  2671. int imageHeight = 0;
  2672. PDFHelp.ImageStreamToByte(CurrentParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight);
  2673. if (imageData != null && imageWidth > 0 && imageHeight > 0)
  2674. {
  2675. stampAnnot.SetRect(CurrentParam.ClientRect);
  2676. stampAnnot.SetImageStamp(
  2677. imageData,
  2678. imageWidth,
  2679. imageHeight,
  2680. CurrentParam.PageRotation);
  2681. }
  2682. }
  2683. break;
  2684. default:
  2685. break;
  2686. }
  2687. stampAnnot.SetTransparency((byte)CurrentParam.Transparency);
  2688. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2689. {
  2690. stampAnnot.SetAuthor(CurrentParam.Author);
  2691. }
  2692. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2693. {
  2694. stampAnnot.SetContent(CurrentParam.Content);
  2695. }
  2696. stampAnnot.SetIsLocked(CurrentParam.Locked);
  2697. stampAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2698. stampAnnot.UpdateAp();
  2699. successful = true;
  2700. return successful;
  2701. }
  2702. }
  2703. internal static bool SetLinkAnnotParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2704. {
  2705. LinkParam CurrentParam = param as LinkParam;
  2706. CPDFLinkAnnotation linkAnnot = cPDFAnnotation as CPDFLinkAnnotation;
  2707. bool successful = false;
  2708. if (linkAnnot == null && !linkAnnot.IsValid() && CurrentParam == null)
  2709. {
  2710. return successful;
  2711. }
  2712. else
  2713. {
  2714. switch (CurrentParam.Action)
  2715. {
  2716. case C_ACTION_TYPE.ACTION_TYPE_GOTO:
  2717. {
  2718. CPDFGoToAction gotoAction = new CPDFGoToAction();
  2719. CPDFDestination destination = new CPDFDestination();
  2720. destination.Position_X = CurrentParam.DestinationPosition.x;
  2721. destination.Position_Y = CurrentParam.DestinationPosition.y;
  2722. destination.PageIndex = CurrentParam.DestinationPageIndex;
  2723. gotoAction.SetDestination(cPDFDocument, destination);
  2724. linkAnnot.SetLinkAction(gotoAction);
  2725. }
  2726. break;
  2727. case C_ACTION_TYPE.ACTION_TYPE_URI:
  2728. {
  2729. CPDFUriAction uriAction = new CPDFUriAction();
  2730. if (!string.IsNullOrEmpty(CurrentParam.Uri))
  2731. {
  2732. uriAction.SetUri(CurrentParam.Uri);
  2733. }
  2734. linkAnnot.SetLinkAction(uriAction);
  2735. }
  2736. break;
  2737. default:
  2738. break;
  2739. }
  2740. linkAnnot.SetRect(CurrentParam.ClientRect);
  2741. if (!string.IsNullOrEmpty(CurrentParam.Author))
  2742. {
  2743. linkAnnot.SetAuthor(CurrentParam.Author);
  2744. }
  2745. if (!string.IsNullOrEmpty(CurrentParam.Content))
  2746. {
  2747. linkAnnot.SetContent(CurrentParam.Content);
  2748. }
  2749. linkAnnot.SetIsLocked(CurrentParam.Locked);
  2750. linkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2751. linkAnnot.UpdateAp();
  2752. successful = true;
  2753. return successful;
  2754. }
  2755. }
  2756. internal static bool SetTextAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
  2757. {
  2758. StickyNoteParam textAnnotParam = param as StickyNoteParam;
  2759. CPDFTextAnnotation textAnnot = cPDFAnnotation as CPDFTextAnnotation;
  2760. if (textAnnot == null && !textAnnot.IsValid() && textAnnotParam == null)
  2761. {
  2762. return false;
  2763. }
  2764. else
  2765. {
  2766. if (textAnnotParam.StickyNoteColor != null && textAnnotParam.StickyNoteColor.Length == 3)
  2767. {
  2768. textAnnot.SetColor(textAnnotParam.StickyNoteColor);
  2769. }
  2770. textAnnot.SetTransparency((byte)textAnnotParam.Transparency);
  2771. textAnnot.SetRect(textAnnotParam.ClientRect);
  2772. if (!string.IsNullOrEmpty(textAnnotParam.Author))
  2773. {
  2774. textAnnot.SetAuthor(textAnnotParam.Author);
  2775. }
  2776. if (!string.IsNullOrEmpty(textAnnotParam.Content))
  2777. {
  2778. textAnnot.SetContent(textAnnotParam.Content);
  2779. }
  2780. textAnnot.SetIsLocked(textAnnotParam.Locked);
  2781. textAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
  2782. textAnnot.UpdateAp();
  2783. return true;
  2784. }
  2785. }
  2786. #endregion
  2787. public static bool SetParamForPDFEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
  2788. {
  2789. bool successful = false;
  2790. if (cPDFEditArea == null && !cPDFEditArea.IsValid())
  2791. {
  2792. return successful;
  2793. }
  2794. switch (cPDFEditArea.Type)
  2795. {
  2796. case CPDFEditType.EditText:
  2797. SetParamForPDFTextEdit(cPDFEditArea, param);
  2798. break;
  2799. default:
  2800. break;
  2801. }
  2802. return successful;
  2803. }
  2804. internal static bool SetParamForPDFTextEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
  2805. {
  2806. TextEditParam CurrentParam = param as TextEditParam;
  2807. CPDFEditTextArea cPDFEditTextArea = cPDFEditArea as CPDFEditTextArea;
  2808. bool successful = false;
  2809. if (cPDFEditTextArea == null && !cPDFEditTextArea.IsValid() && CurrentParam == null)
  2810. {
  2811. return successful;
  2812. }
  2813. else
  2814. {
  2815. cPDFEditTextArea.SetCharsFontTransparency(param.Transparency);
  2816. cPDFEditTextArea.SetFrame(
  2817. DataConversionForWPF.RectConversionForCRect(
  2818. new Rect(CurrentParam.ClientRect.left, CurrentParam.ClientRect.top, CurrentParam.ClientRect.width(), CurrentParam.ClientRect.height())
  2819. ));
  2820. cPDFEditTextArea.SetCharsFontSize((float)CurrentParam.FontSize, true);
  2821. if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
  2822. {
  2823. cPDFEditTextArea.SetCharsFontColor(CurrentParam.FontColor[0], CurrentParam.FontColor[1], CurrentParam.FontColor[2]);
  2824. }
  2825. cPDFEditTextArea.SetTextAreaAlign(CurrentParam.TextAlign);
  2826. cPDFEditTextArea.SetCharsFontName(CurrentParam.FontName);
  2827. cPDFEditTextArea.SetCharsFontItalic(CurrentParam.IsItalic);
  2828. cPDFEditTextArea.SetCharsFontBold(CurrentParam.IsBold);
  2829. successful = true;
  2830. return successful;
  2831. }
  2832. }
  2833. internal static bool SetParamForPDFImageEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
  2834. {
  2835. ImageEditParam CurrentParam = param as ImageEditParam;
  2836. CPDFEditImageArea cPDFEditImageArea = cPDFEditArea as CPDFEditImageArea;
  2837. bool successful = false;
  2838. if (cPDFEditImageArea == null && !cPDFEditImageArea.IsValid() && CurrentParam == null)
  2839. {
  2840. return successful;
  2841. }
  2842. else
  2843. {
  2844. cPDFEditImageArea.SetImageTransparency(param.Transparency);
  2845. cPDFEditImageArea.SetFrame(
  2846. DataConversionForWPF.RectConversionForCRect(
  2847. new Rect(CurrentParam.ClientRect.left, CurrentParam.ClientRect.top, CurrentParam.ClientRect.width(), CurrentParam.ClientRect.height())
  2848. ))
  2849. ;
  2850. cPDFEditImageArea.CutWithRect(
  2851. DataConversionForWPF.RectConversionForCRect(
  2852. new Rect(CurrentParam.ClipRect.left, CurrentParam.ClipRect.top, CurrentParam.ClipRect.width(), CurrentParam.ClipRect.height())
  2853. ));
  2854. successful = true;
  2855. return successful;
  2856. }
  2857. }
  2858. }
  2859. }