1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181 |
- using ComPDFKit.Import;
- using ComPDFKit.Measure;
- using ComPDFKit.PDFAnnotation;
- using ComPDFKit.PDFAnnotation.Form;
- using ComPDFKit.PDFDocument;
- using ComPDFKit.PDFDocument.Action;
- using ComPDFKit.PDFPage;
- using ComPDFKit.PDFPage.Edit;
- using ComPDFKit.Tool.SettingParam;
- using ComPDFKit.Tool.UndoManger;
- using ComPDFKit.Viewer.Helper;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Windows;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using static ComPDFKit.PDFAnnotation.CTextAttribute;
- using static ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
- namespace ComPDFKit.Tool.Help
- {
- /// <summary>
- /// Some quick conversion tools for parameters
- /// </summary>
- public static class ParamConverter
- {
- public enum FormField
- {
- /// <summary>
- /// Visible
- /// </summary>
- Visible,
- /// <summary>
- /// Hidden
- /// </summary>
- Hidden,
- /// <summary>
- /// Visible but unprintable
- /// </summary>
- VisibleNoPrint,
- /// <summary>
- /// Hidden but printable
- /// </summary>
- HiddenPrintable
- }
- public static AnnotHistory CreateHistory(CPDFAnnotation cPDFAnnotation)
- {
- AnnotHistory annotHistory = null;
- switch (cPDFAnnotation.Type)
- {
- case C_ANNOTATION_TYPE.C_ANNOTATION_NONE:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_UNKOWN:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
- annotHistory = new StickyNoteAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
- annotHistory = new LinkAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
- annotHistory = new FreeTextAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
- if ((cPDFAnnotation as CPDFLineAnnotation).IsMeasured())
- {
- annotHistory = new LineMeasureAnnotHistory();
- }
- else
- {
- annotHistory = new LineAnnotHistory();
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
- annotHistory = new SquareAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
- annotHistory = new CircleAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
- annotHistory = new PolygonMeasureAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
- annotHistory = new PolyLineMeasureAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
- annotHistory = new HighlightAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
- annotHistory = new UnderlineAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
- annotHistory = new SquigglyAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
- annotHistory = new StrikeoutAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
- annotHistory = new StampAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_CARET:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
- annotHistory = new InkAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POPUP:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_FILEATTACHMENT:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
- annotHistory = new SoundAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
- switch ((cPDFAnnotation as CPDFWidget).WidgetType)
- {
- case C_WIDGET_TYPE.WIDGET_NONE:
- break;
- case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
- annotHistory = new PushButtonHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_CHECKBOX:
- annotHistory = new CheckBoxHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
- annotHistory = new RadioButtonHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
- annotHistory = new TextBoxHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_COMBOBOX:
- annotHistory = new ComboBoxHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_LISTBOX:
- annotHistory = new ListBoxHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
- annotHistory = new SignatureHistory();
- break;
- case C_WIDGET_TYPE.WIDGET_UNKNOWN:
- break;
- default:
- break;
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SCREEN:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_PRINTERMARK:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_TRAPNET:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_WATERMARK:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_3D:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
- annotHistory = new RedactAnnotHistory();
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_INTERCHANGE:
- break;
- default:
- break;
- }
- return annotHistory;
- }
- public static bool RemovePageAnnot(Dictionary<int, List<int>> removeAnnots, CPDFDocument cPDFDocument)
- {
- if (cPDFDocument == null || removeAnnots.Count <= 0)
- {
- return false;
- }
- foreach (int pageIndex in removeAnnots.Keys)
- {
- CPDFPage pageCore = cPDFDocument.PageAtIndex(pageIndex);
- List<CPDFAnnotation> cPDFAnnotations = pageCore.GetAnnotations();
- foreach (int annotIndex in removeAnnots[pageIndex])
- {
- CPDFAnnotation cPDFAnnotation = cPDFAnnotations.ElementAtOrDefault(annotIndex);
- if (cPDFAnnotation != null)
- {
- cPDFAnnotation.RemoveAnnot();
- }
- }
- }
- return false;
- }
- public static FormField ConverterWidgetFormFlags(int Flags, bool IsHidden)
- {
- int flag = Flags;
- bool invisible = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible) != 0;
- bool noview = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView) != 0;
- bool print = (flag & (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint) != 0;
- if (noview && print)
- {
- return FormField.HiddenPrintable;
- }
- if (IsHidden || noview || invisible)
- {
- return FormField.Hidden;
- }
- bool visibleflag = !IsHidden && !invisible && !noview && !print;
- if (visibleflag)
- {
- return FormField.VisibleNoPrint;
- }
- return FormField.Visible;
- }
- public static int GetFormFlags(FormField field, CPDFWidget widget)
- {
- int flag = widget.GetFlags();
- switch (field)
- {
- case FormField.Hidden:
- widget.SetIsHidden(true);
- flag = widget.GetFlags();
- break;
- case FormField.Visible:
- {
- int newflag = (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagHidden
- | (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible;
- flag &= ~newflag;
- flag |= (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint;
- }
- break;
- case FormField.VisibleNoPrint:
- {
- int newflag = (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint |
- (int)CPDFAnnotationFlags.CPDFAnnotationFlagHidden | (int)CPDFAnnotationFlags.CPDFAnnotationFlagInvisible;
- flag &= ~newflag;
- }
- break;
- case FormField.HiddenPrintable:
- {
- flag = flag | (int)CPDFAnnotationFlags.CPDFAnnotationFlagNoView | (int)CPDFAnnotationFlags.CPDFAnnotationFlagPrint;
- }
- break;
- default:
- break;
- }
- return flag;
- }
- public static Color ConverterByteForColor(byte[] bytes)
- {
- if (bytes != null && bytes.Length == 3)
- {
- return new Color { R = bytes[0], G = bytes[1], B = bytes[2], A = 255};
- }
- return new Color { R = 0, G = 0, B = 0, A = 0 };
- }
- public static void ParseDashStyle(DashStyle dashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle)
- {
- if (dashStyle == DashStyles.Solid || dashStyle == null)
- {
- LineDash = new float[0];
- BorderStyle = C_BORDER_STYLE.BS_SOLID;
- }
- else
- {
- List<float> floatArray = new List<float>();
- foreach (double num in dashStyle.Dashes)
- {
- floatArray.Add((float)num);
- }
- LineDash = floatArray.ToArray();
- BorderStyle = C_BORDER_STYLE.BS_DASHDED;
- }
- }
- public static AnnotParam CPDFDataConverterToAnnotParam(CPDFDocument cPDFDocument, int PageIndex, CPDFAnnotation cPDFAnnotation)
- {
- if (cPDFAnnotation == null && !cPDFAnnotation.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid())
- {
- return null;
- }
- AnnotParam annotParam = null;
- if (cPDFAnnotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
- {
- annotParam = WidgetConverter(cPDFDocument, cPDFAnnotation);
- }
- else
- {
- annotParam = AnnotConverter(cPDFDocument, cPDFAnnotation);
- }
- if (annotParam != null)
- {
- annotParam.PageIndex = PageIndex;
- CPDFPage cPDFPage = cPDFDocument.PageAtIndex(annotParam.PageIndex, false);
- List<CPDFAnnotation> cPDFAnnotations = cPDFPage.GetAnnotations();
- annotParam.AnnotIndex = cPDFAnnotations.IndexOf(cPDFAnnotation);
- }
- return annotParam;
- }
- public static PDFEditParam CPDFDataConverterToPDFEitParam(CPDFDocument cPDFDocument, CPDFEditArea cPDFEditArea, int pageIndex)
- {
- PDFEditParam annotParam = null;
- if (cPDFEditArea == null && !cPDFEditArea.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid() && pageIndex >= 0)
- {
- return null;
- }
- switch (cPDFEditArea.Type)
- {
- case CPDFEditType.None:
- break;
- case CPDFEditType.EditText:
- annotParam = GetTextEditParam(cPDFDocument, cPDFEditArea as CPDFEditTextArea, pageIndex);
- break;
- case CPDFEditType.EditImage:
- annotParam = GetImageEditParam(cPDFDocument, cPDFEditArea as CPDFEditImageArea, pageIndex);
- break;
- case CPDFEditType.EditPath:
- annotParam = GetPathEditParam(cPDFDocument, cPDFEditArea as CPDFEditPathArea, pageIndex);
- break;
- default:
- break;
- }
- return annotParam;
- }
- #region PDFEdit
- internal static TextEditParam GetTextEditParam(CPDFDocument cPDFDocument, CPDFEditTextArea cPDFEditArea, int pageIndex)
- {
- TextEditParam textEditParam = new TextEditParam();
- string fontName = "Helvetica";
- float fontSize = 14;
- byte[] fontColor = {0,0,0};
- byte transparency = 255;
- bool isBold = false;
- bool isItalic = false;
- cPDFEditArea.GetTextStyle(ref fontName,ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
- textEditParam.FontName = fontName;
- textEditParam.FontSize = fontSize;
- textEditParam.FontColor = fontColor;
- textEditParam.Transparency = transparency;
- textEditParam.TextAlign = cPDFEditArea.GetTextSectionAlign();
- textEditParam.EditType = CPDFEditType.EditText;
- CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
- CPDFEditPage editPage = docPage.GetEditPage();
- textEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
- textEditParam.PageIndex = pageIndex;
- if(string.IsNullOrEmpty(cPDFEditArea.SelectText))
- {
- textEditParam.IsBold = isBold;
- textEditParam.IsItalic = isItalic;
- }
- else
- {
- textEditParam.IsBold = cPDFEditArea.IsCharsFontBold();
- textEditParam.IsItalic = cPDFEditArea.IsCharsFontItalic();
- }
- return textEditParam;
- }
- internal static ImageEditParam GetImageEditParam(CPDFDocument cPDFDocument, CPDFEditImageArea cPDFEditArea, int pageIndex)
- {
- ImageEditParam imageEditParam = new ImageEditParam();
- imageEditParam.Transparency = cPDFEditArea.GetImageTransparency();
- imageEditParam.Rotate = cPDFEditArea.GetRotation();
- imageEditParam.ClipRect = cPDFEditArea.GetClipRect();
- imageEditParam.EditType = CPDFEditType.EditImage;
- CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
- CPDFEditPage editPage = docPage.GetEditPage();
- imageEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
- imageEditParam.PageIndex = pageIndex;
- return imageEditParam;
- }
- internal static PathEditParam GetPathEditParam(CPDFDocument cPDFDocument, CPDFEditPathArea cPDFEditArea, int pageIndex)
- {
- PathEditParam pathEditParam = new PathEditParam();
- pathEditParam.Transparency = cPDFEditArea.GetTransparency();
- pathEditParam.Rotate = cPDFEditArea.GetRotation();
- pathEditParam.StrokeColor = cPDFEditArea.GetStrokeColor();
- pathEditParam.FillColor = cPDFEditArea.GetFillColor();
- pathEditParam.ClipRect = cPDFEditArea.GetClipRect();
- pathEditParam.EditType = CPDFEditType.EditPath;
- CPDFPage docPage = cPDFDocument.PageAtIndex(pageIndex);
- CPDFEditPage editPage = docPage.GetEditPage();
- pathEditParam.EditIndex = editPage.GetEditAreaList().IndexOf(cPDFEditArea);
- pathEditParam.PageIndex = pageIndex;
- return pathEditParam;
- }
- #endregion
- #region Widegt
- internal static AnnotParam WidgetConverter(CPDFDocument document, CPDFAnnotation cPDFAnnotation)
- {
- AnnotParam annotParam = null;
- if (cPDFAnnotation is CPDFWidget)
- {
- switch ((cPDFAnnotation as CPDFWidget).WidgetType)
- {
- case C_WIDGET_TYPE.WIDGET_NONE:
- break;
- case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
- annotParam = GetPushButtonParam(document, cPDFAnnotation as CPDFPushButtonWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_CHECKBOX:
- annotParam = GetCheckBoxParam(cPDFAnnotation as CPDFCheckBoxWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
- annotParam = GetRadioButtonParam(cPDFAnnotation as CPDFRadioButtonWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
- annotParam = GetTextBoxParam(cPDFAnnotation as CPDFTextWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_COMBOBOX:
- annotParam = GetComboBoxParam(cPDFAnnotation as CPDFComboBoxWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_LISTBOX:
- annotParam = GetListBoxParam(cPDFAnnotation as CPDFListBoxWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
- annotParam = GetSignatureParam(cPDFAnnotation as CPDFSignatureWidget);
- break;
- case C_WIDGET_TYPE.WIDGET_UNKNOWN:
- break;
- default:
- break;
- }
- }
- return annotParam;
- }
- internal static PushButtonParam GetPushButtonParam(CPDFDocument document, CPDFPushButtonWidget cPDFWidget)
- {
- PushButtonParam pushButtonParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- pushButtonParam = new PushButtonParam();
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- pushButtonParam.IsBold = IsBold(cTextAttribute.FontName);
- pushButtonParam.IsItalic = IsItalic(cTextAttribute.FontName);
- pushButtonParam.Text = cPDFWidget.GetButtonTitle();
- pushButtonParam.FontColor = cTextAttribute.FontColor;
- pushButtonParam.FontName = cTextAttribute.FontName;
- pushButtonParam.FontSize = cTextAttribute.FontSize;
- CPDFAction cPDFAction = cPDFWidget.GetButtonAction();
- if (cPDFAction != null)
- {
- switch (cPDFAction.ActionType)
- {
- case C_ACTION_TYPE.ACTION_TYPE_URI:
- pushButtonParam.Uri = (cPDFAction as CPDFUriAction)?.GetUri();
- break;
- case C_ACTION_TYPE.ACTION_TYPE_GOTO:
- CPDFGoToAction gotoAction = cPDFAction as CPDFGoToAction;
- CPDFDestination dest = gotoAction.GetDestination(document);
- pushButtonParam.DestinationPageIndex = dest.PageIndex;
- pushButtonParam.DestinationPosition = new CPoint(dest.Position_X, dest.Position_Y);
- break;
- default:
- break;
- }
- pushButtonParam.Action = cPDFAction.ActionType;
- }
- pushButtonParam.WidgetType = cPDFWidget.WidgetType;
- pushButtonParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- pushButtonParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- pushButtonParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- pushButtonParam.HasBgColor = hasBgColor;
- pushButtonParam.BgColor = BgColor;
- pushButtonParam.LineWidth = cPDFWidget.GetBorderWidth();
- pushButtonParam.FieldName = cPDFWidget.GetFieldName();
- pushButtonParam.Flags = cPDFWidget.GetFlags();
- pushButtonParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- pushButtonParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, pushButtonParam);
- }
- return pushButtonParam;
- }
- internal static CheckBoxParam GetCheckBoxParam(CPDFCheckBoxWidget cPDFWidget)
- {
- CheckBoxParam checkBoxParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- checkBoxParam = new CheckBoxParam();
- checkBoxParam.CheckStyle = cPDFWidget.GetWidgetCheckStyle();
- checkBoxParam.IsChecked = cPDFWidget.IsChecked();
- checkBoxParam.WidgetType = cPDFWidget.WidgetType;
- checkBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- checkBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- checkBoxParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- checkBoxParam.HasBgColor = hasBgColor;
- checkBoxParam.BgColor = BgColor;
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- checkBoxParam.FontColor = cTextAttribute.FontColor;
- checkBoxParam.FontName = cTextAttribute.FontName;
- checkBoxParam.FontSize = cTextAttribute.FontSize;
- checkBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
- checkBoxParam.FieldName = cPDFWidget.GetFieldName();
- checkBoxParam.Flags = cPDFWidget.GetFlags();
- checkBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- checkBoxParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, checkBoxParam);
- }
- return checkBoxParam;
- }
- internal static RadioButtonParam GetRadioButtonParam(CPDFRadioButtonWidget cPDFWidget)
- {
- RadioButtonParam radioButtonParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- radioButtonParam = new RadioButtonParam();
- radioButtonParam.CheckStyle = cPDFWidget.GetWidgetCheckStyle();
- radioButtonParam.IsChecked = cPDFWidget.IsChecked();
- radioButtonParam.WidgetType = cPDFWidget.WidgetType;
- radioButtonParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- radioButtonParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- radioButtonParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- radioButtonParam.HasBgColor = hasBgColor;
- radioButtonParam.BgColor = BgColor;
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- radioButtonParam.FontColor = cTextAttribute.FontColor;
- radioButtonParam.FontName = cTextAttribute.FontName;
- radioButtonParam.FontSize = cTextAttribute.FontSize;
- radioButtonParam.LineWidth = cPDFWidget.GetBorderWidth();
- radioButtonParam.FieldName = cPDFWidget.GetFieldName();
- radioButtonParam.Flags = cPDFWidget.GetFlags();
- radioButtonParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- radioButtonParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, radioButtonParam);
- }
- return radioButtonParam;
- }
- internal static TextBoxParam GetTextBoxParam(CPDFTextWidget cPDFWidget)
- {
- TextBoxParam textBoxParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- textBoxParam = new TextBoxParam();
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- textBoxParam.Text = cPDFWidget.Text;
- textBoxParam.IsMultiLine = cPDFWidget.IsMultiLine;
- textBoxParam.IsPassword = cPDFWidget.IsPassword;
- textBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
- textBoxParam.IsBold = IsBold(cTextAttribute.FontName);
- textBoxParam.Alignment = cPDFWidget.Alignment;
- textBoxParam.WidgetType = cPDFWidget.WidgetType;
- textBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- textBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- textBoxParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- textBoxParam.HasBgColor = hasBgColor;
- textBoxParam.BgColor = BgColor;
- textBoxParam.FontColor = cTextAttribute.FontColor;
- textBoxParam.FontName = cTextAttribute.FontName;
- textBoxParam.FontSize = cTextAttribute.FontSize;
- textBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
- textBoxParam.FieldName = cPDFWidget.GetFieldName();
- textBoxParam.Flags = cPDFWidget.GetFlags();
- textBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- textBoxParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, textBoxParam);
- }
- return textBoxParam;
- }
- internal static ComboBoxParam GetComboBoxParam(CPDFComboBoxWidget cPDFWidget)
- {
- ComboBoxParam comboBoxParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- comboBoxParam = new ComboBoxParam();
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- comboBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
- comboBoxParam.IsBold = IsBold(cTextAttribute.FontName);
- //Support for multiple selections needs to be adjusted later.
- CWidgetItem[] cWidgetItem = cPDFWidget.LoadWidgetItems();
- CWidgetItem cWidgetItem1 = cPDFWidget.GetSelectedItem();
- if (cWidgetItem != null)
- {
- for (int i = 0; i < cWidgetItem.Length; i++)
- {
- CWidgetItem item = cWidgetItem[i];
- comboBoxParam.OptionItems.Add(item.Value, item.Text);
- if (cWidgetItem1 != null && cWidgetItem1.Text == item.Text && cWidgetItem1.Value == item.Value)
- {
- comboBoxParam.SelectItemsIndex = new List<int> { i };
- }
- }
- }
- comboBoxParam.WidgetType = cPDFWidget.WidgetType;
- comboBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- comboBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- comboBoxParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- comboBoxParam.HasBgColor = hasBgColor;
- comboBoxParam.BgColor = BgColor;
- comboBoxParam.FontColor = cTextAttribute.FontColor;
- comboBoxParam.FontName = cTextAttribute.FontName;
- comboBoxParam.FontSize = cTextAttribute.FontSize;
- comboBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
- comboBoxParam.FieldName = cPDFWidget.GetFieldName();
- comboBoxParam.Flags = cPDFWidget.GetFlags();
- comboBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- comboBoxParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, comboBoxParam);
- }
- return comboBoxParam;
- }
- internal static ListBoxParam GetListBoxParam(CPDFListBoxWidget cPDFWidget)
- {
- ListBoxParam listBoxParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- listBoxParam = new ListBoxParam();
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- listBoxParam.IsItalic = IsItalic(cTextAttribute.FontName);
- listBoxParam.IsBold = IsBold(cTextAttribute.FontName);
- CWidgetItem[] cWidgetItem = cPDFWidget.LoadWidgetItems();
- //Support for multiple selections needs to be adjusted later.
- CWidgetItem cWidgetItem1 = cPDFWidget.GetSelectedItem();
- if (cWidgetItem != null)
- {
- for (int i = 0; i < cWidgetItem.Length; i++)
- {
- CWidgetItem item = cWidgetItem[i];
- listBoxParam.OptionItems.Add(item.Value, item.Text);
- if (cWidgetItem1 != null && cWidgetItem1.Text == item.Text && cWidgetItem1.Value == item.Value)
- {
- listBoxParam.SelectItemsIndex = new List<int> { i };
- }
- }
- }
- listBoxParam.WidgetType = cPDFWidget.WidgetType;
- listBoxParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- listBoxParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- listBoxParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- listBoxParam.HasBgColor = hasBgColor;
- listBoxParam.BgColor = BgColor;
- listBoxParam.FontColor = cTextAttribute.FontColor;
- listBoxParam.FontName = cTextAttribute.FontName;
- listBoxParam.FontSize = cTextAttribute.FontSize;
- listBoxParam.LineWidth = cPDFWidget.GetBorderWidth();
- listBoxParam.FieldName = cPDFWidget.GetFieldName();
- listBoxParam.Flags = cPDFWidget.GetFlags();
- listBoxParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- listBoxParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, listBoxParam);
- }
- return listBoxParam;
- }
- internal static SignatureParam GetSignatureParam(CPDFSignatureWidget cPDFWidget)
- {
- SignatureParam signatureParam = null;
- if (cPDFWidget != null && cPDFWidget.IsValid())
- {
- signatureParam = new SignatureParam();
- signatureParam.WidgetType = cPDFWidget.WidgetType;
- signatureParam.BorderStyle = cPDFWidget.GetWidgetBorderStyle();
- byte[] LineColor = new byte[3];
- signatureParam.HasLineColor = cPDFWidget.GetWidgetBorderRGBColor(ref LineColor);
- signatureParam.LineColor = LineColor;
- byte[] BgColor = new byte[3];
- bool hasBgColor = cPDFWidget.GetWidgetBgRGBColor(ref BgColor);
- signatureParam.HasBgColor = hasBgColor;
- signatureParam.BgColor = BgColor;
- CTextAttribute cTextAttribute = cPDFWidget.GetTextAttribute();
- signatureParam.FontColor = cTextAttribute.FontColor;
- signatureParam.FontName = cTextAttribute.FontName;
- signatureParam.FontSize = cTextAttribute.FontSize;
- signatureParam.LineWidth = cPDFWidget.GetBorderWidth();
- signatureParam.FieldName = cPDFWidget.GetFieldName();
- signatureParam.Flags = cPDFWidget.GetFlags();
- signatureParam.IsReadOnly = cPDFWidget.GetIsReadOnly();
- signatureParam.IsHidden = cPDFWidget.GetIsHidden();
- GetAnnotCommonParam(cPDFWidget, signatureParam);
- }
- return signatureParam;
- }
- #endregion
- #region Annot
- internal static AnnotParam MeasureAnnotConverter(CPDFAnnotation pdfAnnot)
- {
- if (pdfAnnot == null || pdfAnnot.IsValid() == false)
- {
- return null;
- }
- switch (pdfAnnot.Type)
- {
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
- {
- CPDFLineAnnotation lineAnnot = pdfAnnot as CPDFLineAnnotation;
- if (lineAnnot != null)
- {
- return GetLineMeasureParam(lineAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
- {
- CPDFPolylineAnnotation polylineAnnot = pdfAnnot as CPDFPolylineAnnotation;
- if (polylineAnnot != null)
- {
- return GetPolylineParam(polylineAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
- {
- CPDFPolygonAnnotation polygonAnnot = pdfAnnot as CPDFPolygonAnnotation;
- if (polygonAnnot != null)
- {
- return GetPolygonParam(polygonAnnot);
- }
- }
- break;
- }
- return null;
- }
- internal static AnnotParam AnnotConverter(CPDFDocument pdfDoc, CPDFAnnotation pdfAnnot)
- {
- if (pdfAnnot == null || pdfAnnot.IsValid() == false)
- {
- return null;
- }
- switch (pdfAnnot.Type)
- {
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
- {
- CPDFSquareAnnotation squareAnnot = pdfAnnot as CPDFSquareAnnotation;
- if (squareAnnot != null)
- {
- return GetSquareParam(squareAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
- {
- CPDFCircleAnnotation circleAnnot = pdfAnnot as CPDFCircleAnnotation;
- if (circleAnnot != null)
- {
- return GetCircleParam(circleAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
- {
- CPDFLineAnnotation lineAnnot = pdfAnnot as CPDFLineAnnotation;
- if (lineAnnot != null)
- {
- if(lineAnnot.IsMeasured())
- {
- return GetLineMeasureParam(lineAnnot);
- }
- return GetLineParam(lineAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
- {
- CPDFInkAnnotation inkAnnot = pdfAnnot as CPDFInkAnnotation;
- if (inkAnnot != null)
- {
- return GetInkParam(inkAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
- {
- CPDFFreeTextAnnotation freetextAnnot = pdfAnnot as CPDFFreeTextAnnotation;
- if (freetextAnnot != null)
- {
- return GetFreeTextParam(freetextAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
- {
- CPDFHighlightAnnotation highlightAnnot = pdfAnnot as CPDFHighlightAnnotation;
- if (highlightAnnot != null)
- {
- return GetHighlightParam(highlightAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
- {
- CPDFUnderlineAnnotation underlineAnnot = pdfAnnot as CPDFUnderlineAnnotation;
- if (underlineAnnot != null)
- {
- return GetUnderlineParam(underlineAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
- {
- CPDFStrikeoutAnnotation strikeoutAnnot = pdfAnnot as CPDFStrikeoutAnnotation;
- if (strikeoutAnnot != null)
- {
- return GetStrikeoutParam(strikeoutAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
- {
- CPDFSquigglyAnnotation squigglyAnnot = pdfAnnot as CPDFSquigglyAnnotation;
- if (squigglyAnnot != null)
- {
- return GetSquigglyParam(squigglyAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
- {
- CPDFTextAnnotation stickyAnnot = pdfAnnot as CPDFTextAnnotation;
- if (stickyAnnot != null)
- {
- return GetStickynoteParam(stickyAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
- {
- CPDFStampAnnotation stampAnnot = pdfAnnot as CPDFStampAnnotation;
- if (stampAnnot != null)
- {
- return GetStampParam(stampAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
- {
- CPDFLinkAnnotation linkAnnot = pdfAnnot as CPDFLinkAnnotation;
- if (linkAnnot != null)
- {
- return GetLinkParam(linkAnnot, pdfDoc);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
- {
- CPDFSoundAnnotation soundAnnot = pdfAnnot as CPDFSoundAnnotation;
- if (soundAnnot != null)
- {
- return GetSoundParam(soundAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
- {
- CPDFRedactAnnotation redactAnnot= pdfAnnot as CPDFRedactAnnotation;
- if(redactAnnot != null)
- {
- return GetRedactParam(redactAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
- {
- CPDFPolylineAnnotation polylineAnnot= pdfAnnot as CPDFPolylineAnnotation;
- if (polylineAnnot!=null && polylineAnnot.IsMeasured())
- {
- return GetPolyLineMeasureParam(polylineAnnot);
- }
- }
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
- {
- CPDFPolygonAnnotation polygonAnnot= pdfAnnot as CPDFPolygonAnnotation;
- if(polygonAnnot!=null)
- {
- return GetPolygonMeasureParam(polygonAnnot);
- }
- }
- break;
- default:
- break;
- }
- return null;
- }
- internal static void GetAnnotCommonParam(CPDFAnnotation pdfAnnot, AnnotParam annotParam)
- {
- if (pdfAnnot == null || annotParam == null || !pdfAnnot.IsValid())
- {
- return;
- }
- annotParam.CurrentType = pdfAnnot.Type;
- annotParam.Author = pdfAnnot.GetAuthor();
- annotParam.Transparency = pdfAnnot.GetTransparency();
- annotParam.Content = pdfAnnot.GetContent();
- annotParam.UpdateTime = pdfAnnot.GetModifyDate();
- annotParam.CreateTime = pdfAnnot.GetCreationDate();
- annotParam.Locked = pdfAnnot.GetIsLocked();
- annotParam.ClientRect = pdfAnnot.GetRect();
- annotParam.AnnotIndex = pdfAnnot.Page.GetAnnotations().IndexOf(pdfAnnot);
- //Annotation object exists, but the list cannot be found, it can only be a newly created annotation object.
- if (annotParam.AnnotIndex == -1)
- {
- annotParam.AnnotIndex = pdfAnnot.Page.GetAnnotCount() - 1;
- }
- annotParam.PageIndex = pdfAnnot.Page.PageIndex;
- }
- internal static SquareParam GetSquareParam(CPDFSquareAnnotation squareAnnot)
- {
- if (squareAnnot == null || squareAnnot.IsValid() == false)
- {
- return null;
- }
- SquareParam squareParam = new SquareParam();
- if (squareAnnot.LineColor != null && squareAnnot.LineColor.Length == 3)
- {
- squareParam.LineColor = new byte[3]
- {
- squareAnnot.LineColor[0],
- squareAnnot.LineColor[1],
- squareAnnot.LineColor[2]
- };
- }
- if (squareAnnot.HasBgColor && squareAnnot.BgColor != null)
- {
- if (squareAnnot.BgColor.Length == 3)
- {
- squareParam.HasBgColor = true;
- squareParam.BgColor = new byte[3]
- {
- squareAnnot.BgColor[0],
- squareAnnot.BgColor[1],
- squareAnnot.BgColor[2]
- };
- }
- }
- squareParam.LineWidth = squareAnnot.LineWidth;
- squareParam.BorderStyle = squareAnnot.BorderStyle;
- if (squareAnnot.Dash != null && squareAnnot.Dash.Length > 0)
- {
- squareParam.LineDash = new float[squareAnnot.Dash.Length];
- squareAnnot.Dash.CopyTo(squareParam.LineDash, 0);
- }
- GetAnnotCommonParam(squareAnnot, squareParam);
- return squareParam;
- }
- internal static CircleParam GetCircleParam(CPDFCircleAnnotation circleAnnot)
- {
- if (circleAnnot == null || circleAnnot.IsValid() == false)
- {
- return null;
- }
- CircleParam circleParam = new CircleParam();
- if (circleAnnot.LineColor != null && circleAnnot.LineColor.Length == 3)
- {
- circleParam.LineColor = new byte[3]
- {
- circleAnnot.LineColor[0],
- circleAnnot.LineColor[1],
- circleAnnot.LineColor[2]
- };
- }
- if (circleAnnot.HasBgColor && circleAnnot.BgColor != null)
- {
- if (circleAnnot.BgColor.Length == 3)
- {
- circleParam.HasBgColor = true;
- circleParam.BgColor = new byte[3]
- {
- circleAnnot.BgColor[0],
- circleAnnot.BgColor[1],
- circleAnnot.BgColor[2]
- };
- }
- }
- circleParam.LineWidth = circleAnnot.LineWidth;
- circleParam.BorderStyle = circleAnnot.BorderStyle;
- if (circleAnnot.Dash != null && circleAnnot.Dash.Length > 0)
- {
- circleParam.LineDash = new float[circleAnnot.Dash.Length];
- circleAnnot.Dash.CopyTo(circleParam.LineDash, 0);
- }
- GetAnnotCommonParam(circleAnnot, circleParam);
- return circleParam;
- }
- private static AnnotParam GetPolylineParam(CPDFPolylineAnnotation polylineAnnot)
- {
- if (polylineAnnot == null || polylineAnnot.IsValid() == false)
- {
- return null;
- }
- PolyLineMeasureParam polylineParam = new PolyLineMeasureParam();
- if (polylineAnnot.LineColor != null && polylineAnnot.LineColor.Length == 3)
- {
- polylineParam.LineColor = new byte[3]
- {
- polylineAnnot.LineColor[0],
- polylineAnnot.LineColor[1],
- polylineAnnot.LineColor[2]
- };
- }
- polylineParam.LineWidth = polylineAnnot.LineWidth;
- polylineParam.BorderStyle = polylineAnnot.BorderStyle;
- if (polylineAnnot.Dash != null && polylineAnnot.Dash.Length > 0)
- {
- polylineParam.LineDash = new float[polylineAnnot.Dash.Length];
- polylineAnnot.Dash.CopyTo(polylineParam.LineDash, 0);
- }
-
- if (polylineAnnot.Points != null && polylineAnnot.Points.Count > 0)
- {
- polylineParam.SavePoints = new List<CPoint>();
- foreach (CPoint point in polylineAnnot.Points)
- {
- polylineParam.SavePoints.Add(point);
- }
- }
-
- CTextAttribute cTextAttribute = polylineAnnot.GetTextAttribute();
- polylineParam.FontName = cTextAttribute.FontName;
- polylineParam.FontSize = cTextAttribute.FontSize;
- polylineParam.FontColor = cTextAttribute.FontColor;
- GetAnnotCommonParam(polylineAnnot, polylineParam);
- return polylineParam;
- }
-
- private static AnnotParam GetPolygonParam(CPDFPolygonAnnotation polygonAnnot)
- {
- if (polygonAnnot == null || polygonAnnot.IsValid() == false)
- {
- return null;
- }
- PolygonMeasureParam polygonParam = new PolygonMeasureParam();
- if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3)
- {
- polygonParam.LineColor = new byte[3]
- {
- polygonAnnot.LineColor[0],
- polygonAnnot.LineColor[1],
- polygonAnnot.LineColor[2]
- };
- }
-
- if(polygonAnnot.HasBgColor && polygonAnnot.BgColor != null)
- {
- polygonParam.HasFillColor = true;
- polygonParam.FillColor = new byte[3]
- {
- polygonAnnot.BgColor[0],
- polygonAnnot.BgColor[1],
- polygonAnnot.BgColor[2]
- };
- }
- polygonParam.LineWidth = polygonAnnot.LineWidth;
- polygonParam.BorderStyle = polygonAnnot.BorderStyle;
- if (polygonAnnot.Dash != null && polygonAnnot.Dash.Length > 0)
- {
- polygonParam.LineDash = new float[polygonAnnot.Dash.Length];
- polygonAnnot.Dash.CopyTo(polygonParam.LineDash, 0);
- }
-
- if (polygonAnnot.Points != null && polygonAnnot.Points.Count > 0)
- {
- polygonParam.SavePoints = new List<CPoint>();
- foreach (CPoint point in polygonAnnot.Points)
- {
- polygonParam.SavePoints.Add(point);
- }
- }
-
- CTextAttribute cTextAttribute = polygonAnnot.GetTextAttribute();
- polygonParam.FontName = cTextAttribute.FontName;
- polygonParam.FontSize = cTextAttribute.FontSize;
- polygonParam.FontColor = cTextAttribute.FontColor;
- GetAnnotCommonParam(polygonAnnot, polygonParam);
- return polygonParam;
- }
-
- internal static LineParam GetLineParam(CPDFLineAnnotation lineAnnot)
- {
- if (lineAnnot == null || lineAnnot.IsValid() == false)
- {
- return null;
- }
- LineParam lineParam = new LineParam();
- if (lineAnnot.LineColor != null && lineAnnot.LineColor.Length == 3)
- {
- lineParam.LineColor = new byte[3]
- {
- lineAnnot.LineColor[0],
- lineAnnot.LineColor[1],
- lineAnnot.LineColor[2]
- };
- }
- if (lineAnnot.HasBgColor && lineAnnot.BgColor != null)
- {
- if (lineAnnot.BgColor.Length == 3)
- {
- lineParam.HasBgColor = true;
- lineParam.BgColor = new byte[3]
- {
- lineAnnot.BgColor[0],
- lineAnnot.BgColor[1],
- lineAnnot.BgColor[2]
- };
- }
- }
- lineParam.LineWidth = lineAnnot.LineWidth;
- lineParam.BorderStyle = lineAnnot.BorderStyle;
- if (lineAnnot.Dash != null && lineAnnot.Dash.Length > 0)
- {
- lineParam.LineDash = new float[lineAnnot.Dash.Length];
- lineAnnot.Dash.CopyTo(lineParam.LineDash, 0);
- }
- lineParam.HeadLineType = lineAnnot.HeadLineType;
- lineParam.TailLineType = lineAnnot.TailLineType;
- if (lineAnnot.Points != null && lineAnnot.Points.Length == 2)
- {
- lineParam.HeadPoint = lineAnnot.Points[0];
- lineParam.TailPoint = lineAnnot.Points[1];
- }
- GetAnnotCommonParam(lineAnnot, lineParam);
- return lineParam;
- }
- internal static LineMeasureParam GetLineMeasureParam(CPDFLineAnnotation lineAnnot)
- {
- if (lineAnnot == null || lineAnnot.IsValid() == false || lineAnnot.IsMeasured()==false)
- {
- return null;
- }
- LineMeasureParam measureParam = new LineMeasureParam();
- CPDFDistanceMeasure distanceMeasure = lineAnnot.GetDistanceMeasure();
- measureParam.measureInfo = distanceMeasure.MeasureInfo;
- if (lineAnnot.LineColor != null && lineAnnot.LineColor.Length == 3)
- {
- measureParam.LineColor = new byte[3] { lineAnnot.LineColor[0], lineAnnot.LineColor[1], lineAnnot.LineColor[2] };
- }
- measureParam.BorderStyle = lineAnnot.BorderStyle;
- measureParam.LineWidth = lineAnnot.LineWidth;
- measureParam.Transparency = lineAnnot.Transparency;
- measureParam.LineDash = lineAnnot.Dash;
- CTextAttribute textAttr = lineAnnot.GetTextAttribute();
- measureParam.FontName = textAttr.FontName;
- measureParam.FontSize = textAttr.FontSize;
- if (textAttr.FontColor != null && textAttr.FontColor.Length == 3)
- {
- measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
- }
- measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
- measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
- measureParam.HeadLineType=lineAnnot.HeadLineType;
- measureParam.TailLineType=lineAnnot.TailLineType;
- measureParam.HeadPoint = lineAnnot.Points[0];
- measureParam.TailPoint = lineAnnot.Points[1];
- GetAnnotCommonParam(lineAnnot, measureParam);
- return measureParam;
- }
- internal static InkParam GetInkParam(CPDFInkAnnotation inkAnnot)
- {
- if (inkAnnot == null || inkAnnot.IsValid() == false)
- {
- return null;
- }
- InkParam inkParam = new InkParam();
- inkParam.Thickness = inkAnnot.Thickness;
- if (inkAnnot.InkColor != null && inkAnnot.InkColor.Length == 3)
- {
- inkParam.InkColor = new byte[3]
- {
- inkAnnot.InkColor[0],
- inkAnnot.InkColor[1],
- inkAnnot.InkColor[2]
- };
- }
- if (inkAnnot.InkPath != null && inkAnnot.InkPath.Count > 0)
- {
- List<List<CPoint>> inkPath = new List<List<CPoint>>();
- foreach (List<CPoint> copyList in inkAnnot.InkPath)
- {
- if (copyList.Count == 0)
- {
- continue;
- }
- List<CPoint> saveList = new List<CPoint>();
- foreach (CPoint item in copyList)
- {
- saveList.Add(item);
- }
- if (saveList.Count > 0)
- {
- inkPath.Add(saveList);
- }
- }
- if (inkPath.Count > 0)
- {
- inkParam.InkPath = inkPath;
- }
- }
- if(inkAnnot.Dash!=null && inkAnnot.Dash.Length>0)
- {
- inkParam.Dash =new float[inkAnnot.Dash.Length];
- inkAnnot.Dash.CopyTo(inkParam.Dash, 0);
- }
- GetAnnotCommonParam(inkAnnot, inkParam);
- return inkParam;
- }
- internal static FreeTextParam GetFreeTextParam(CPDFFreeTextAnnotation freetextAnnot)
- {
- if (freetextAnnot == null || freetextAnnot.IsValid() == false)
- {
- return null;
- }
- FreeTextParam freetextParam = new FreeTextParam();
- if (freetextAnnot.LineColor != null && freetextAnnot.LineColor.Length == 3)
- {
- freetextParam.LineColor = new byte[3]
- {
- freetextAnnot.LineColor[0],
- freetextAnnot.LineColor[1],
- freetextAnnot.LineColor[2]
- };
- }
- if (freetextAnnot.HasBgColor && freetextAnnot.BgColor != null)
- {
- if (freetextAnnot.BgColor.Length == 3)
- {
- freetextParam.HasBgColor = true;
- freetextParam.BgColor = new byte[3]
- {
- freetextAnnot.BgColor[0],
- freetextAnnot.BgColor[1],
- freetextAnnot.BgColor[2]
- };
- }
- }
- freetextParam.LineWidth = freetextAnnot.LineWidth;
- if (freetextAnnot.FreeTextDa != null)
- {
- byte[] fontColor = freetextAnnot.FreeTextDa.FontColor;
- if (fontColor != null && fontColor.Length == 3)
- {
- freetextParam.FontColor = new byte[3]
- {
- fontColor[0],
- fontColor[1],
- fontColor[2]
- };
- }
- string fontName = freetextAnnot.FreeTextDa.FontName;
- if (!string.IsNullOrEmpty(fontName))
- {
- freetextParam.FontName = fontName;
- freetextParam.IsBold = IsBold(fontName);
- freetextParam.IsItalic = IsItalic(fontName);
- }
- freetextParam.FontSize = freetextAnnot.FreeTextDa.FontSize;
- freetextParam.Alignment = freetextAnnot.Alignment;
- }
- if (freetextAnnot.Dash != null && freetextAnnot.Dash.Length > 0)
- {
- freetextParam.Dash = new float[freetextAnnot.Dash.Length];
- freetextAnnot.Dash.CopyTo(freetextParam.Dash, 0);
- }
- GetAnnotCommonParam(freetextAnnot, freetextParam);
- return freetextParam;
- }
- internal static HighlightParam GetHighlightParam(CPDFHighlightAnnotation highlightAnnot)
- {
- if (highlightAnnot == null || highlightAnnot.IsValid() == false)
- {
- return null;
- }
- HighlightParam highlightParam = new HighlightParam();
- if (highlightAnnot.Color != null && highlightAnnot.Color.Length == 3)
- {
- highlightParam.HighlightColor = new byte[3]
- {
- highlightAnnot.Color[0],
- highlightAnnot.Color[1],
- highlightAnnot.Color[2]
- };
- }
- if (highlightAnnot.QuardRects != null && highlightAnnot.QuardRects.Count > 0)
- {
- List<CRect> saveList = new List<CRect>();
- foreach (CRect saveRect in highlightAnnot.QuardRects)
- {
- saveList.Add(saveRect);
- }
- highlightParam.QuardRects = saveList;
- }
- GetAnnotCommonParam(highlightAnnot, highlightParam);
- return highlightParam;
- }
- internal static UnderlineParam GetUnderlineParam(CPDFUnderlineAnnotation underlineAnnot)
- {
- if (underlineAnnot == null || underlineAnnot.IsValid() == false)
- {
- return null;
- }
- UnderlineParam underlineParam = new UnderlineParam();
- if (underlineAnnot.Color != null && underlineAnnot.Color.Length == 3)
- {
- underlineParam.UnderlineColor = new byte[3]
- {
- underlineAnnot.Color[0],
- underlineAnnot.Color[1],
- underlineAnnot.Color[2]
- };
- }
- if (underlineAnnot.QuardRects != null && underlineAnnot.QuardRects.Count > 0)
- {
- List<CRect> saveList = new List<CRect>();
- foreach (CRect saveRect in underlineAnnot.QuardRects)
- {
- saveList.Add(saveRect);
- }
- underlineParam.QuardRects = saveList;
- }
- GetAnnotCommonParam(underlineAnnot, underlineParam);
- return underlineParam;
- }
- internal static StrikeoutParam GetStrikeoutParam(CPDFStrikeoutAnnotation strikeoutAnnot)
- {
- if (strikeoutAnnot == null || strikeoutAnnot.IsValid() == false)
- {
- return null;
- }
- StrikeoutParam strikeoutParam = new StrikeoutParam();
- if (strikeoutAnnot.Color != null && strikeoutAnnot.Color.Length == 3)
- {
- strikeoutParam.StrikeoutColor = new byte[3]
- {
- strikeoutAnnot.Color[0],
- strikeoutAnnot.Color[1],
- strikeoutAnnot.Color[2]
- };
- }
- if (strikeoutAnnot.QuardRects != null && strikeoutAnnot.QuardRects.Count > 0)
- {
- List<CRect> saveList = new List<CRect>();
- foreach (CRect saveRect in strikeoutAnnot.QuardRects)
- {
- saveList.Add(saveRect);
- }
- strikeoutParam.QuardRects = saveList;
- }
- GetAnnotCommonParam(strikeoutAnnot, strikeoutParam);
- return strikeoutParam;
- }
- internal static SquigglyParam GetSquigglyParam(CPDFSquigglyAnnotation squigglyAnnot)
- {
- if (squigglyAnnot == null || squigglyAnnot.IsValid() == false)
- {
- return null;
- }
- SquigglyParam squigglyParam = new SquigglyParam();
- if (squigglyAnnot.Color != null && squigglyAnnot.Color.Length == 3)
- {
- squigglyParam.SquigglyColor = new byte[3]
- {
- squigglyAnnot.Color[0],
- squigglyAnnot.Color[1],
- squigglyAnnot.Color[2]
- };
- }
- if (squigglyAnnot.QuardRects != null && squigglyAnnot.QuardRects.Count > 0)
- {
- List<CRect> saveList = new List<CRect>();
- foreach (CRect saveRect in squigglyAnnot.QuardRects)
- {
- saveList.Add(saveRect);
- }
- squigglyParam.QuardRects = saveList;
- }
- GetAnnotCommonParam(squigglyAnnot, squigglyParam);
- return squigglyParam;
- }
- internal static StickyNoteParam GetStickynoteParam(CPDFTextAnnotation stickyAnnot)
- {
- if (stickyAnnot == null || stickyAnnot.IsValid() == false)
- {
- return null;
- }
- StickyNoteParam stickyParam = new StickyNoteParam();
- if (stickyAnnot.Color != null && stickyAnnot.Color.Length == 3)
- {
- stickyParam.StickyNoteColor = new byte[3]
- {
- stickyAnnot.Color[0],
- stickyAnnot.Color[1],
- stickyAnnot.Color[2]
- };
- }
- stickyParam.IconName=stickyAnnot.GetIconName();
- GetAnnotCommonParam(stickyAnnot, stickyParam);
- return stickyParam;
- }
- internal static StampParam GetStampParam(CPDFStampAnnotation stampAnnot)
- {
- if (stampAnnot == null || stampAnnot.IsValid() == false)
- {
- return null;
- }
- StampParam stampParam = new StampParam();
- C_STAMP_TYPE stampType = stampAnnot.GetStampType();
- switch (stampType)
- {
- case C_STAMP_TYPE.STANDARD_STAMP:
- {
- stampParam.StampText = stampAnnot.GetStandardStamp();
- stampParam.StampType = stampType;
- }
- break;
- case C_STAMP_TYPE.TEXT_STAMP:
- {
- string stampText = string.Empty;
- string dateText = string.Empty;
- C_TEXTSTAMP_SHAPE stampShape = C_TEXTSTAMP_SHAPE.TEXTSTAMP_NONE;
- C_TEXTSTAMP_COLOR stampColor = C_TEXTSTAMP_COLOR.TEXTSTAMP_WHITE;
- stampAnnot.GetTextStamp(ref stampText,
- ref dateText,
- ref stampShape,
- ref stampColor);
- stampParam.StampText = stampText;
- stampParam.DateText = dateText;
- stampParam.TextStampShape = stampShape;
- stampParam.TextStampColor = stampColor;
- stampParam.StampType = stampType;
- }
- break;
- case C_STAMP_TYPE.IMAGE_STAMP:
- case C_STAMP_TYPE.UNKNOWN_STAMP:
- {
- stampParam.StampType = stampType;
- CRect rawRect = stampAnnot.GetRect();
- int width = (int)(rawRect.width() / 72D * 96D);
- int height = (int)(rawRect.height() / 72D * 96D);
- if (width > 0 && height > 0)
- {
- Rect rotateRect = new Rect(0, 0, width, height);
- Matrix rotateMatrix = new Matrix();
- rotateMatrix.RotateAt(-90 * stampAnnot.Page.Rotation, width / 2, height / 2);
- rotateRect.Transform(rotateMatrix);
- int imageWidth = (int)rotateRect.Width;
- int imageHeight = (int)rotateRect.Height;
- byte[] ImageArray = new byte[imageWidth * imageHeight * 4];
- stampAnnot.RenderAnnot(imageWidth, imageHeight, ImageArray);
- WriteableBitmap writeBitmap = new WriteableBitmap(
- imageWidth,
- imageHeight,
- 96,
- 96,
- PixelFormats.Bgra32,
- null);
- writeBitmap.WritePixels(new Int32Rect(0, 0, imageWidth, imageHeight), ImageArray, imageWidth * 4, 0);
- PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
- pngEncoder.Frames.Add(BitmapFrame.Create(writeBitmap));
- MemoryStream memStream = new MemoryStream();
- pngEncoder.Save(memStream);
- stampParam.ImageStream = memStream;
- }
- }
- break;
- default:
- return null;
- }
- stampParam.PageRotation = stampAnnot.Page.Rotation;
- stampParam.Rotation = stampAnnot.AnnotationRotator.GetRotation();
- CRect sourceRect = new CRect();
- stampAnnot.GetSourceRect(ref sourceRect);
- stampParam.SourceRect = sourceRect;
- GetAnnotCommonParam(stampAnnot, stampParam);
- return stampParam;
- }
- internal static LinkParam GetLinkParam(CPDFLinkAnnotation linkAnnot, CPDFDocument pdfDoc)
- {
- if (linkAnnot == null || linkAnnot.IsValid() == false)
- {
- return null;
- }
- LinkParam linkParam = new LinkParam();
- CPDFAction linkAction = linkAnnot.GetLinkAction();
- if (linkAction != null)
- {
- switch (linkAction.ActionType)
- {
- case C_ACTION_TYPE.ACTION_TYPE_GOTO:
- {
- CPDFGoToAction gotoAction = linkAction as CPDFGoToAction;
- if (gotoAction != null && pdfDoc != null && pdfDoc.IsValid())
- {
- CPDFDestination dest = gotoAction.GetDestination(pdfDoc);
- if (dest != null)
- {
- linkParam.Action = C_ACTION_TYPE.ACTION_TYPE_GOTO;
- linkParam.DestinationPageIndex = dest.PageIndex;
- linkParam.DestinationPosition = new CPoint(dest.Position_X, dest.Position_Y);
- }
- }
- }
- break;
- case C_ACTION_TYPE.ACTION_TYPE_URI:
- {
- CPDFUriAction urlAction = linkAction as CPDFUriAction;
- if (urlAction != null)
- {
- linkParam.Uri = urlAction.GetUri();
- linkParam.Action = C_ACTION_TYPE.ACTION_TYPE_URI;
- }
- }
- break;
- default:
- break;
- }
- }
- GetAnnotCommonParam(linkAnnot, linkParam);
- return linkParam;
- }
- internal static SoundParam GetSoundParam(CPDFSoundAnnotation stampAnnot)
- {
- if (stampAnnot == null || stampAnnot.IsValid() == false)
- {
- return null;
- }
- SoundParam soundParam = new SoundParam();
- GetAnnotCommonParam(stampAnnot, soundParam);
- return soundParam;
- }
- internal static RedactParam GetRedactParam(CPDFRedactAnnotation redactAnnot)
- {
- if(redactAnnot == null || redactAnnot.IsValid() == false)
- {
- return null;
- }
- RedactParam redactParam = new RedactParam();
- if (redactAnnot.OutlineColor != null && redactAnnot.OutlineColor.Length == 3)
- {
- redactParam.LineColor = new byte[3] { redactAnnot.OutlineColor[0], redactAnnot.OutlineColor[1], redactAnnot.OutlineColor[2] };
- }
- if (redactAnnot.FillColor != null && redactAnnot.FillColor.Length == 3)
- {
- redactParam.BgColor = new byte[3] { redactAnnot.FillColor[0], redactAnnot.FillColor[1], redactAnnot.FillColor[2] };
- }
- if (redactAnnot.TextDa != null)
- {
- if (redactAnnot.TextDa.FontColor != null && redactAnnot.TextDa.FontColor.Length == 3)
- {
- redactParam.FontColor = new byte[3] { redactAnnot.TextDa.FontColor[0], redactAnnot.TextDa.FontColor[1], redactAnnot.TextDa.FontColor[2] };
- }
-
- redactParam.FontName= redactAnnot.TextDa.FontName;
- redactParam.FontSize = redactAnnot.TextDa.FontSize;
- redactParam.Alignment=redactAnnot.TextAlignment;
- }
- if(redactAnnot.QuardRects!=null)
- {
- redactParam.QuardRects = new List<CRect>(redactAnnot.QuardRects);
- }
- redactParam.OverlayText = redactAnnot.OverlayText;
- GetAnnotCommonParam(redactAnnot, redactParam);
- return redactParam;
- }
- internal static PolyLineMeasureParam GetPolyLineMeasureParam(CPDFPolylineAnnotation polylineAnnot)
- {
- if (polylineAnnot == null || polylineAnnot.IsValid() == false || polylineAnnot.IsMeasured()==false)
- {
- return null;
- }
- PolyLineMeasureParam measureParam = new PolyLineMeasureParam();
- CPDFPerimeterMeasure perimeterMeasure = polylineAnnot.GetPerimeterMeasure();
- measureParam.measureInfo= perimeterMeasure.MeasureInfo;
- if (polylineAnnot.LineColor != null && polylineAnnot.LineColor.Length == 3)
- {
- measureParam.LineColor = new byte[3] { polylineAnnot.LineColor[0], polylineAnnot.LineColor[1], polylineAnnot.LineColor[2] };
- }
- measureParam.SavePoints = polylineAnnot.Points;
- measureParam.BorderStyle = polylineAnnot.BorderStyle;
- measureParam.LineWidth=polylineAnnot.LineWidth;
- measureParam.Transparency=polylineAnnot.Transparency;
- measureParam.LineDash=polylineAnnot.Dash;
- CTextAttribute textAttr = polylineAnnot.GetTextAttribute();
- measureParam.FontName = textAttr.FontName;
- measureParam.FontSize = textAttr.FontSize;
- if(textAttr.FontColor!=null && textAttr.FontColor.Length == 3)
- {
- measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
- }
- measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
- measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
- GetAnnotCommonParam(polylineAnnot, measureParam);
- return measureParam;
- }
- internal static PolygonMeasureParam GetPolygonMeasureParam(CPDFPolygonAnnotation polygonAnnot)
- {
- if (polygonAnnot == null || polygonAnnot.IsValid() == false)
- {
- return null;
- }
- PolygonMeasureParam measureParam = new PolygonMeasureParam();
- if(polygonAnnot.IsMeasured())
- {
- CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure();
- measureParam.measureInfo = areaMeasure.MeasureInfo;
- }
- if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3)
- {
- measureParam.LineColor = new byte[] { polygonAnnot.LineColor[0], polygonAnnot.LineColor[1], polygonAnnot.LineColor[2] };
- }
- if(polygonAnnot.BgColor!=null && polygonAnnot.BgColor.Length == 3)
- {
- measureParam.HasFillColor = true;
- measureParam.FillColor = new byte[] { polygonAnnot.BgColor[0], polygonAnnot.BgColor[1], polygonAnnot.BgColor[2] };
- }
- measureParam.SavePoints = polygonAnnot.Points;
- measureParam.BorderStyle = polygonAnnot.BorderStyle;
- measureParam.LineWidth = polygonAnnot.LineWidth;
- measureParam.Transparency = polygonAnnot.Transparency;
- measureParam.LineDash = polygonAnnot.Dash;
- CTextAttribute textAttr = polygonAnnot.GetTextAttribute();
- measureParam.FontName = textAttr.FontName;
- measureParam.FontSize = textAttr.FontSize;
- if (textAttr.FontColor != null && textAttr.FontColor.Length == 3)
- {
- measureParam.FontColor = new byte[] { textAttr.FontColor[0], textAttr.FontColor[1], textAttr.FontColor[2] };
- }
- measureParam.IsBold = CFontNameHelper.IsBold(textAttr.FontName);
- measureParam.IsItalic = CFontNameHelper.IsItalic(textAttr.FontName);
- GetAnnotCommonParam(polygonAnnot, measureParam);
- return measureParam;
- }
- #endregion
- public static bool SetParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- bool successful = false;
- if (cPDFAnnotation == null && !cPDFAnnotation.IsValid() && cPDFDocument == null && !cPDFDocument.IsValid())
- {
- return successful;
- }
- if (cPDFAnnotation.Type == C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
- {
- successful = SetWidgetParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
- }
- else
- {
- successful = SetAnnotParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
- }
- return successful;
- }
- #region SetWidegt
- internal static bool SetWidgetParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- bool successful = false;
- if (cPDFAnnotation is CPDFWidget)
- {
- switch ((cPDFAnnotation as CPDFWidget).WidgetType)
- {
- case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
- successful = SetPushButtonParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_CHECKBOX:
- successful = SetCheckBoxParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
- successful = SetRadioButtonParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
- successful = SetTextBoxParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_COMBOBOX:
- successful = SetComboBoxParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_LISTBOX:
- successful = SetListBoxParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
- successful = SetSignatureParamForPDFAnnot(cPDFAnnotation, param);
- break;
- default:
- successful = false;
- break;
- }
- }
- return successful;
- }
- internal static bool SetPushButtonParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- PushButtonParam CurrentParam = param as PushButtonParam;
- CPDFPushButtonWidget pushbuttonWidget = cPDFAnnotation as CPDFPushButtonWidget;
- bool successful = false;
- if (pushbuttonWidget == null && !pushbuttonWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- pushbuttonWidget.SetFieldName(CurrentParam.FieldName);
- }
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- pushbuttonWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- pushbuttonWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- if (!string.IsNullOrEmpty(CurrentParam.Text))
- {
- pushbuttonWidget.SetButtonTitle(CurrentParam.Text);
- }
- pushbuttonWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- pushbuttonWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- CTextAttribute textAttr = new CTextAttribute();
- byte[] fontColor = new byte[3];
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- fontColor = CurrentParam.FontColor;
- }
- textAttr.FontColor = fontColor;
- textAttr.FontSize = (float)CurrentParam.FontSize;
- textAttr.FontName = ObtainFontName(
- GetFontType(CurrentParam.FontName),
- CurrentParam.IsBold,
- CurrentParam.IsItalic);
- pushbuttonWidget.SetTextAttribute(textAttr);
- switch (CurrentParam.Action)
- {
- case C_ACTION_TYPE.ACTION_TYPE_GOTO:
- {
- CPDFGoToAction gotoAction = new CPDFGoToAction();
- CPDFDestination destination = new CPDFDestination();
- destination.Position_X = CurrentParam.DestinationPosition.x;
- destination.Position_Y = CurrentParam.DestinationPosition.y;
- destination.PageIndex = CurrentParam.DestinationPageIndex;
- gotoAction.SetDestination(cPDFDocument, destination);
- pushbuttonWidget.SetButtonAction(gotoAction);
- }
- break;
- case C_ACTION_TYPE.ACTION_TYPE_URI:
- {
- CPDFUriAction uriAction = new CPDFUriAction();
- uriAction.SetUri(CurrentParam.Uri);
- pushbuttonWidget.SetButtonAction(uriAction);
- }
- break;
- default:
- break;
- }
- pushbuttonWidget.SetRect(CurrentParam.ClientRect);
- pushbuttonWidget.SetFlags(CurrentParam.Flags);
- pushbuttonWidget.SetIsLocked(CurrentParam.Locked);
- pushbuttonWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- pushbuttonWidget.SetIsHidden(CurrentParam.IsHidden);
- pushbuttonWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- pushbuttonWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetCheckBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- CheckBoxParam CurrentParam = param as CheckBoxParam;
- CPDFCheckBoxWidget checkboxWidget = cPDFAnnotation as CPDFCheckBoxWidget;
- bool successful = false;
- if (checkboxWidget == null && !checkboxWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- checkboxWidget.SetFieldName(CurrentParam.FieldName);
- }
- checkboxWidget.SetWidgetCheckStyle(CurrentParam.CheckStyle);
- checkboxWidget.SetChecked(CurrentParam.IsChecked);
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- checkboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- checkboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- checkboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- checkboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- CTextAttribute textAttr = checkboxWidget.GetTextAttribute();
- textAttr.FontColor = CurrentParam.FontColor;
- checkboxWidget.SetTextAttribute(textAttr);
- }
- checkboxWidget.SetRect(CurrentParam.ClientRect);
- checkboxWidget.SetFlags(CurrentParam.Flags);
- checkboxWidget.SetIsLocked(CurrentParam.Locked);
- checkboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- checkboxWidget.SetIsHidden(CurrentParam.IsHidden);
- checkboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- checkboxWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetRadioButtonParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- RadioButtonParam CurrentParam = param as RadioButtonParam;
- CPDFRadioButtonWidget radioWidget = cPDFAnnotation as CPDFRadioButtonWidget;
- bool successful = false;
- if (radioWidget == null && !radioWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- radioWidget.SetFieldName(CurrentParam.FieldName);
- }
- radioWidget.SetWidgetCheckStyle(CurrentParam.CheckStyle);
- radioWidget.SetChecked(CurrentParam.IsChecked);
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- radioWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- radioWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- radioWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- radioWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- CTextAttribute textAttr = radioWidget.GetTextAttribute();
- textAttr.FontColor = CurrentParam.FontColor;
- radioWidget.SetTextAttribute(textAttr);
- }
- radioWidget.SetRect(CurrentParam.ClientRect);
- radioWidget.SetFlags(CurrentParam.Flags);
- radioWidget.SetIsLocked(CurrentParam.Locked);
- radioWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- radioWidget.SetIsHidden(CurrentParam.IsHidden);
- radioWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- radioWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetTextBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- TextBoxParam CurrentParam = param as TextBoxParam;
- CPDFTextWidget textWidget = cPDFAnnotation as CPDFTextWidget;
- bool successful = false;
- if (textWidget == null && !textWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- textWidget.SetFieldName(CurrentParam.FieldName);
- }
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- textWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- textWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- if (!string.IsNullOrEmpty(CurrentParam.Text))
- {
- textWidget.SetText(CurrentParam.Text);
- }
- CTextAttribute textAttr = new CTextAttribute();
- byte[] fontColor = new byte[3];
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- fontColor = CurrentParam.FontColor;
- }
- textAttr.FontColor = fontColor;
- textAttr.FontSize = (float)CurrentParam.FontSize;
- textAttr.FontName = ObtainFontName(
- GetFontType(CurrentParam.FontName),
- CurrentParam.IsBold,
- CurrentParam.IsItalic);
- textWidget.SetTextAttribute(textAttr);
- textWidget.SetJustification(CurrentParam.Alignment);
- textWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- textWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- textWidget.SetMultiLine(CurrentParam.IsMultiLine);
- textWidget.SetRect(CurrentParam.ClientRect);
- textWidget.SetFlags(CurrentParam.Flags);
- textWidget.SetIsLocked(CurrentParam.Locked);
- textWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- textWidget.SetIsHidden(CurrentParam.IsHidden);
- textWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- textWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetComboBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- ComboBoxParam CurrentParam = param as ComboBoxParam;
- CPDFComboBoxWidget comboboxWidget = cPDFAnnotation as CPDFComboBoxWidget;
- bool successful = false;
- if (comboboxWidget == null && !comboboxWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- comboboxWidget.SetFieldName(CurrentParam.FieldName);
- }
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- comboboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- comboboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- comboboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- comboboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- CTextAttribute textAttr = new CTextAttribute();
- byte[] fontColor = new byte[3];
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- fontColor = CurrentParam.FontColor;
- }
- textAttr.FontColor = fontColor;
- textAttr.FontSize = (float)CurrentParam.FontSize;
- textAttr.FontName = ObtainFontName(
- GetFontType(CurrentParam.FontName),
- CurrentParam.IsBold,
- CurrentParam.IsItalic);
- comboboxWidget.SetTextAttribute(textAttr);
- if (CurrentParam.OptionItems != null && CurrentParam.OptionItems.Count > 0)
- {
- int addIndex = 0;
- foreach (string key in CurrentParam.OptionItems.Keys)
- {
- comboboxWidget.AddOptionItem(addIndex, CurrentParam.OptionItems[key], key);
- addIndex++;
- }
- }
- if (CurrentParam.SelectItemsIndex != null && CurrentParam.SelectItemsIndex.Count > 0)
- {
- comboboxWidget.SelectItem(CurrentParam.SelectItemsIndex[0]);
- }
- comboboxWidget.SetRect(CurrentParam.ClientRect);
- comboboxWidget.SetFlags(CurrentParam.Flags);
- comboboxWidget.SetIsLocked(CurrentParam.Locked);
- comboboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- comboboxWidget.SetIsHidden(CurrentParam.IsHidden);
- comboboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- comboboxWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetListBoxParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- ListBoxParam CurrentParam = param as ListBoxParam;
- CPDFListBoxWidget listboxWidget = cPDFAnnotation as CPDFListBoxWidget;
- bool successful = false;
- if (listboxWidget == null && !listboxWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- listboxWidget.SetFieldName(CurrentParam.FieldName);
- }
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- listboxWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- listboxWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- listboxWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- listboxWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- CTextAttribute textAttr = new CTextAttribute();
- byte[] fontColor = new byte[3];
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- fontColor = CurrentParam.FontColor;
- }
- textAttr.FontColor = fontColor;
- textAttr.FontSize = (float)CurrentParam.FontSize;
- textAttr.FontName = ObtainFontName(
- GetFontType(CurrentParam.FontName),
- CurrentParam.IsBold,
- CurrentParam.IsItalic);
- listboxWidget.SetTextAttribute(textAttr);
- if (CurrentParam.OptionItems != null && CurrentParam.OptionItems.Count > 0)
- {
- int addIndex = 0;
- foreach (string key in CurrentParam.OptionItems.Keys)
- {
- listboxWidget.AddOptionItem(addIndex, CurrentParam.OptionItems[key], key);
- addIndex++;
- }
- }
- if (CurrentParam.SelectItemsIndex != null && CurrentParam.SelectItemsIndex.Count > 0)
- {
- listboxWidget.SelectItem(CurrentParam.SelectItemsIndex[0]);
- }
- listboxWidget.SetRect(CurrentParam.ClientRect);
- listboxWidget.SetFlags(CurrentParam.Flags);
- listboxWidget.SetIsLocked(CurrentParam.Locked);
- listboxWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- listboxWidget.SetIsHidden(CurrentParam.IsHidden);
- listboxWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- listboxWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetSignatureParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- SignatureParam CurrentParam = param as SignatureParam;
- CPDFSignatureWidget signWidget = cPDFAnnotation as CPDFSignatureWidget;
- bool successful = false;
- if (signWidget == null && !signWidget.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (!string.IsNullOrEmpty(CurrentParam.FieldName))
- {
- signWidget.SetFieldName(CurrentParam.FieldName);
- }
- if (CurrentParam.HasLineColor)
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- signWidget.SetWidgetBorderRGBColor(CurrentParam.LineColor);
- }
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- signWidget.SetWidgetBgRGBColor(CurrentParam.BgColor);
- }
- }
- signWidget.SetBorderWidth((float)CurrentParam.LineWidth);
- signWidget.SetWidgetBorderStyle(CurrentParam.BorderStyle);
- signWidget.SetRect(CurrentParam.ClientRect);
- signWidget.SetFlags(CurrentParam.Flags);
- signWidget.SetIsLocked(CurrentParam.Locked);
- signWidget.SetIsReadOnly(CurrentParam.IsReadOnly);
- signWidget.SetIsHidden(CurrentParam.IsHidden);
- signWidget.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- signWidget.UpdateFormAp();
- successful = true;
- return successful;
- }
- }
- #endregion
- #region SetAnnot
- internal static bool SetAnnotParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- bool successful = false;
- if (cPDFAnnotation != null)
- {
- switch (cPDFAnnotation.Type)
- {
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
- successful = SetSquareAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
- successful = SetCircleAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
- successful = SetLineAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
- successful = SetInkAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
- successful = SetFreeTextAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
- successful = SetHighlightAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
- successful = SetUnderlineAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
- successful = SetStrikeoutAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
- successful = SetSquigglyAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
- successful = SetTextAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
- successful = SetStampAnnotParamForPDFAnnot(cPDFAnnotation, param);
- break;
- case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
- successful = SetLinkAnnotParamForPDFAnnot(cPDFDocument, cPDFAnnotation, param);
- break;
- default:
- break;
- }
- }
- return successful;
- }
- internal static bool SetSquareAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- SquareParam CurrentParam = param as SquareParam;
- CPDFSquareAnnotation squareAnnot = cPDFAnnotation as CPDFSquareAnnotation;
- bool successful = false;
- if (squareAnnot == null && !squareAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- squareAnnot.SetLineColor(CurrentParam.LineColor);
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- squareAnnot.SetBgColor(CurrentParam.BgColor);
- }
- }
- squareAnnot.SetTransparency((byte)CurrentParam.Transparency);
- squareAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
- squareAnnot.SetRect(CurrentParam.ClientRect);
- List<float> floatArray = new List<float>();
- if (CurrentParam.LineDash != null)
- {
- foreach (float num in CurrentParam.LineDash)
- {
- floatArray.Add(num);
- }
- }
- squareAnnot.SetBorderStyle(CurrentParam.BorderStyle, floatArray.ToArray());
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- squareAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- squareAnnot.SetContent(CurrentParam.Content);
- }
- squareAnnot.SetIsLocked(CurrentParam.Locked);
- squareAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- squareAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetCircleAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- CircleParam CurrentParam = param as CircleParam;
- CPDFCircleAnnotation circleAnnot = cPDFAnnotation as CPDFCircleAnnotation;
- bool successful = false;
- if (circleAnnot == null && !circleAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- circleAnnot.SetLineColor(CurrentParam.LineColor);
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- circleAnnot.SetBgColor(CurrentParam.BgColor);
- }
- }
- circleAnnot.SetTransparency((byte)CurrentParam.Transparency);
- circleAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
- circleAnnot.SetRect(CurrentParam.ClientRect);
- List<float> floatArray = new List<float>();
- if (CurrentParam.LineDash != null)
- {
- foreach (float num in CurrentParam.LineDash)
- {
- floatArray.Add(num);
- }
- }
- circleAnnot.SetBorderStyle(CurrentParam.BorderStyle, floatArray.ToArray());
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- circleAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- circleAnnot.SetContent(CurrentParam.Content);
- }
- circleAnnot.SetIsLocked(CurrentParam.Locked);
- circleAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- circleAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetLineAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- LineParam CurrentParam = param as LineParam;
- CPDFLineAnnotation lineAnnot = cPDFAnnotation as CPDFLineAnnotation;
- bool successful = false;
- if (lineAnnot == null && !lineAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (CurrentParam.HeadLineType != C_LINE_TYPE.LINETYPE_NONE || CurrentParam.TailLineType != C_LINE_TYPE.LINETYPE_NONE)
- {
- lineAnnot.SetLineType(CurrentParam.HeadLineType, CurrentParam.TailLineType);
- }
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- lineAnnot.SetLineColor(CurrentParam.LineColor);
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- lineAnnot.SetBgColor(CurrentParam.BgColor);
- }
- }
- lineAnnot.SetTransparency((byte)CurrentParam.Transparency);
- lineAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
- lineAnnot.SetLinePoints(CurrentParam.HeadPoint, CurrentParam.TailPoint);
- lineAnnot.SetRect(CurrentParam.ClientRect);
- List<float> floatArray = new List<float>();
- if (CurrentParam.LineDash != null)
- {
- foreach (float num in CurrentParam.LineDash)
- {
- floatArray.Add(num);
- }
- }
- lineAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, floatArray.ToArray());
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- lineAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- lineAnnot.SetContent(CurrentParam.Content);
- }
- lineAnnot.SetIsLocked(CurrentParam.Locked);
- lineAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- lineAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetInkAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- InkParam CurrentParam = param as InkParam;
- CPDFInkAnnotation inkAnnot = cPDFAnnotation as CPDFInkAnnotation;
- bool successful = false;
- if (inkAnnot == null && !inkAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (CurrentParam.InkColor != null && CurrentParam.InkColor.Length == 3)
- {
- inkAnnot.SetInkColor(CurrentParam.InkColor);
- }
- inkAnnot.SetThickness((float)CurrentParam.Thickness);
- inkAnnot.SetInkPath(CurrentParam.InkPath);
- inkAnnot.SetTransparency((byte)CurrentParam.Transparency);
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- inkAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- inkAnnot.SetContent(CurrentParam.Content);
- }
- inkAnnot.SetIsLocked(CurrentParam.Locked);
- inkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- inkAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetHighlightAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- HighlightParam CurrentParam = param as HighlightParam;
- CPDFHighlightAnnotation highlightAnnot = cPDFAnnotation as CPDFHighlightAnnotation;
- bool successful = false;
- if (highlightAnnot == null && !highlightAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- highlightAnnot.SetTransparency((byte)CurrentParam.Transparency);
- if (CurrentParam.QuardRects != null)
- {
- highlightAnnot.SetQuardRects(CurrentParam.QuardRects);
- }
- if (CurrentParam.HighlightColor != null && CurrentParam.HighlightColor.Length == 3)
- {
- highlightAnnot.SetColor(CurrentParam.HighlightColor);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- highlightAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- highlightAnnot.SetContent(CurrentParam.Content);
- }
- highlightAnnot.SetRect(CurrentParam.ClientRect);
- highlightAnnot.SetIsLocked(CurrentParam.Locked);
- highlightAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- highlightAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetUnderlineAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- UnderlineParam CurrentParam = param as UnderlineParam;
- CPDFUnderlineAnnotation underlineAnnot = cPDFAnnotation as CPDFUnderlineAnnotation;
- bool successful = false;
- if (underlineAnnot == null && !underlineAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- underlineAnnot.SetTransparency((byte)CurrentParam.Transparency);
- underlineAnnot.SetRect(CurrentParam.ClientRect);
- if (CurrentParam.QuardRects != null)
- {
- underlineAnnot.SetQuardRects(CurrentParam.QuardRects);
- }
- if (CurrentParam.UnderlineColor != null && CurrentParam.UnderlineColor.Length == 3)
- {
- underlineAnnot.SetColor(CurrentParam.UnderlineColor);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- underlineAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- underlineAnnot.SetContent(CurrentParam.Content);
- }
- underlineAnnot.SetIsLocked(CurrentParam.Locked);
- underlineAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- underlineAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetStrikeoutAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- StrikeoutParam CurrentParam = param as StrikeoutParam;
- CPDFStrikeoutAnnotation strikeoutAnnot = cPDFAnnotation as CPDFStrikeoutAnnotation;
- bool successful = false;
- if (strikeoutAnnot == null && !strikeoutAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- strikeoutAnnot.SetTransparency((byte)CurrentParam.Transparency);
- strikeoutAnnot.SetRect(CurrentParam.ClientRect);
- if (CurrentParam.QuardRects != null)
- {
- strikeoutAnnot.SetQuardRects(CurrentParam.QuardRects);
- }
- if (CurrentParam.StrikeoutColor != null && CurrentParam.StrikeoutColor.Length == 3)
- {
- strikeoutAnnot.SetColor(CurrentParam.StrikeoutColor);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- strikeoutAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- strikeoutAnnot.SetContent(CurrentParam.Content);
- }
- strikeoutAnnot.SetIsLocked(CurrentParam.Locked);
- strikeoutAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- strikeoutAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetSquigglyAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- SquigglyParam CurrentParam = param as SquigglyParam;
- CPDFSquigglyAnnotation squigglyAnnot = cPDFAnnotation as CPDFSquigglyAnnotation;
- bool successful = false;
- if (squigglyAnnot == null && !squigglyAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- squigglyAnnot.SetTransparency((byte)CurrentParam.Transparency);
- squigglyAnnot.SetRect(CurrentParam.ClientRect);
- if (CurrentParam.QuardRects != null)
- {
- squigglyAnnot.SetQuardRects(CurrentParam.QuardRects);
- }
- if (CurrentParam.SquigglyColor != null && CurrentParam.SquigglyColor.Length == 3)
- {
- squigglyAnnot.SetColor(CurrentParam.SquigglyColor);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- squigglyAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- squigglyAnnot.SetContent(CurrentParam.Content);
- }
- squigglyAnnot.SetIsLocked(CurrentParam.Locked);
- squigglyAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- squigglyAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetFreeTextAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- FreeTextParam CurrentParam = param as FreeTextParam;
- CPDFFreeTextAnnotation textAnnot = cPDFAnnotation as CPDFFreeTextAnnotation;
- bool successful = false;
- if (textAnnot == null && !textAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- if (CurrentParam.LineColor != null && CurrentParam.LineColor.Length == 3)
- {
- textAnnot.SetLineColor(CurrentParam.LineColor);
- }
- if (CurrentParam.HasBgColor)
- {
- if (CurrentParam.BgColor != null && CurrentParam.BgColor.Length == 3)
- {
- textAnnot.SetBgColor(CurrentParam.BgColor);
- }
- }
- textAnnot.SetTransparency((byte)CurrentParam.Transparency);
- textAnnot.SetLineWidth((byte)CurrentParam.LineWidth);
- textAnnot.SetFreetextAlignment(CurrentParam.Alignment);
- CTextAttribute textAttr = new CTextAttribute();
- byte[] fontColor = new byte[3];
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- fontColor = CurrentParam.FontColor;
- }
- textAttr.FontColor = fontColor;
- textAttr.FontSize = (float)CurrentParam.FontSize;
- textAttr.FontName = ObtainFontName(
- GetFontType(CurrentParam.FontName),
- CurrentParam.IsBold,
- CurrentParam.IsItalic);
- textAnnot.SetFreetextDa(textAttr);
- textAnnot.SetRect(CurrentParam.ClientRect);
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- textAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- textAnnot.SetContent(CurrentParam.Content);
- }
- textAnnot.SetIsLocked(CurrentParam.Locked);
- textAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- textAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetStampAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- StampParam CurrentParam = param as StampParam;
- CPDFStampAnnotation stampAnnot = cPDFAnnotation as CPDFStampAnnotation;
- bool successful = false;
- if (stampAnnot == null && !stampAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- switch (CurrentParam.StampType)
- {
- case C_STAMP_TYPE.STANDARD_STAMP:
- {
- string stampText = CurrentParam.StampText;
- if (stampText == null)
- {
- stampText = string.Empty;
- }
- stampAnnot.SetStandardStamp(stampText, CurrentParam.PageRotation);
- stampAnnot.SetRect(CurrentParam.ClientRect);
- }
- break;
- case C_STAMP_TYPE.TEXT_STAMP:
- {
- string dateText = CurrentParam.DateText;
- string stampText = CurrentParam.StampText;
- if (dateText == null)
- {
- dateText = string.Empty;
- }
- if (stampText == null)
- {
- stampText = string.Empty;
- }
- stampAnnot.SetTextStamp(
- stampText,
- dateText,
- CurrentParam.TextStampShape,
- CurrentParam.TextStampColor,
- CurrentParam.PageRotation);
- stampAnnot.SetRect(CurrentParam.ClientRect);
- }
- break;
- case C_STAMP_TYPE.IMAGE_STAMP:
- {
- byte[] imageData = null;
- int imageWidth = 0;
- int imageHeight = 0;
- PDFHelp.ImageStreamToByte(CurrentParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight);
- if (imageData != null && imageWidth > 0 && imageHeight > 0)
- {
- stampAnnot.SetRect(CurrentParam.ClientRect);
- stampAnnot.SetImageStamp(
- imageData,
- imageWidth,
- imageHeight,
- CurrentParam.PageRotation);
- }
- }
- break;
- default:
- break;
- }
- stampAnnot.SetTransparency((byte)CurrentParam.Transparency);
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- stampAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- stampAnnot.SetContent(CurrentParam.Content);
- }
- stampAnnot.SetIsLocked(CurrentParam.Locked);
- stampAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- stampAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetLinkAnnotParamForPDFAnnot(CPDFDocument cPDFDocument, CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- LinkParam CurrentParam = param as LinkParam;
- CPDFLinkAnnotation linkAnnot = cPDFAnnotation as CPDFLinkAnnotation;
- bool successful = false;
- if (linkAnnot == null && !linkAnnot.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- switch (CurrentParam.Action)
- {
- case C_ACTION_TYPE.ACTION_TYPE_GOTO:
- {
- CPDFGoToAction gotoAction = new CPDFGoToAction();
- CPDFDestination destination = new CPDFDestination();
- destination.Position_X = CurrentParam.DestinationPosition.x;
- destination.Position_Y = CurrentParam.DestinationPosition.y;
- destination.PageIndex = CurrentParam.DestinationPageIndex;
- gotoAction.SetDestination(cPDFDocument, destination);
- linkAnnot.SetLinkAction(gotoAction);
- }
- break;
- case C_ACTION_TYPE.ACTION_TYPE_URI:
- {
- CPDFUriAction uriAction = new CPDFUriAction();
- if (!string.IsNullOrEmpty(CurrentParam.Uri))
- {
- uriAction.SetUri(CurrentParam.Uri);
- }
- linkAnnot.SetLinkAction(uriAction);
- }
- break;
- default:
- break;
- }
- linkAnnot.SetRect(CurrentParam.ClientRect);
- if (!string.IsNullOrEmpty(CurrentParam.Author))
- {
- linkAnnot.SetAuthor(CurrentParam.Author);
- }
- if (!string.IsNullOrEmpty(CurrentParam.Content))
- {
- linkAnnot.SetContent(CurrentParam.Content);
- }
- linkAnnot.SetIsLocked(CurrentParam.Locked);
- linkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- linkAnnot.UpdateAp();
- successful = true;
- return successful;
- }
- }
- internal static bool SetTextAnnotParamForPDFAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam param)
- {
- StickyNoteParam textAnnotParam = param as StickyNoteParam;
- CPDFTextAnnotation textAnnot = cPDFAnnotation as CPDFTextAnnotation;
- if (textAnnot == null && !textAnnot.IsValid() && textAnnotParam == null)
- {
- return false;
- }
- else
- {
- if (textAnnotParam.StickyNoteColor != null && textAnnotParam.StickyNoteColor.Length == 3)
- {
- textAnnot.SetColor(textAnnotParam.StickyNoteColor);
- }
- textAnnot.SetTransparency((byte)textAnnotParam.Transparency);
- textAnnot.SetRect(textAnnotParam.ClientRect);
- if (!string.IsNullOrEmpty(textAnnotParam.Author))
- {
- textAnnot.SetAuthor(textAnnotParam.Author);
- }
- if (!string.IsNullOrEmpty(textAnnotParam.Content))
- {
- textAnnot.SetContent(textAnnotParam.Content);
- }
- textAnnot.SetIsLocked(textAnnotParam.Locked);
- textAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
- textAnnot.UpdateAp();
- return true;
- }
- }
- #endregion
- public static bool SetParamForPDFEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
- {
- bool successful = false;
- if (cPDFEditArea == null && !cPDFEditArea.IsValid())
- {
- return successful;
- }
- switch (cPDFEditArea.Type)
- {
- case CPDFEditType.EditText:
- SetParamForPDFTextEdit(cPDFEditArea, param);
- break;
- default:
- break;
- }
- return successful;
- }
- internal static bool SetParamForPDFTextEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
- {
- TextEditParam CurrentParam = param as TextEditParam;
- CPDFEditTextArea cPDFEditTextArea = cPDFEditArea as CPDFEditTextArea;
- bool successful = false;
- if (cPDFEditTextArea == null && !cPDFEditTextArea.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- cPDFEditTextArea.SetCharsFontTransparency(param.Transparency);
- cPDFEditTextArea.SetFrame(
- DataConversionForWPF.RectConversionForCRect(
- new Rect(CurrentParam.ClientRect.left, CurrentParam.ClientRect.top, CurrentParam.ClientRect.width(), CurrentParam.ClientRect.height())
- ));
- cPDFEditTextArea.SetCharsFontSize((float)CurrentParam.FontSize, true);
- if (CurrentParam.FontColor != null && CurrentParam.FontColor.Length == 3)
- {
- cPDFEditTextArea.SetCharsFontColor(CurrentParam.FontColor[0], CurrentParam.FontColor[1], CurrentParam.FontColor[2]);
- }
- cPDFEditTextArea.SetTextAreaAlign(CurrentParam.TextAlign);
- cPDFEditTextArea.SetCharsFontName(CurrentParam.FontName);
- cPDFEditTextArea.SetCharsFontItalic(CurrentParam.IsItalic);
- cPDFEditTextArea.SetCharsFontBold(CurrentParam.IsBold);
- successful = true;
- return successful;
- }
- }
- internal static bool SetParamForPDFImageEdit(CPDFEditArea cPDFEditArea, PDFEditParam param)
- {
- ImageEditParam CurrentParam = param as ImageEditParam;
- CPDFEditImageArea cPDFEditImageArea = cPDFEditArea as CPDFEditImageArea;
- bool successful = false;
- if (cPDFEditImageArea == null && !cPDFEditImageArea.IsValid() && CurrentParam == null)
- {
- return successful;
- }
- else
- {
- cPDFEditImageArea.SetImageTransparency(param.Transparency);
- cPDFEditImageArea.SetFrame(
- DataConversionForWPF.RectConversionForCRect(
- new Rect(CurrentParam.ClientRect.left, CurrentParam.ClientRect.top, CurrentParam.ClientRect.width(), CurrentParam.ClientRect.height())
- ))
- ;
- cPDFEditImageArea.CutWithRect(
- DataConversionForWPF.RectConversionForCRect(
- new Rect(CurrentParam.ClipRect.left, CurrentParam.ClipRect.top, CurrentParam.ClipRect.width(), CurrentParam.ClipRect.height())
- ));
- successful = true;
- return successful;
- }
- }
- }
- }
|