ParamConverter.cs 132 KB

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