ApowerfultemplateenginethatconvertsdataintoiTextqualityPDFsWhitePaperV1.
2www.
itextpdf.
com2IntroductionManyorganizationsstrivetomaketemplatingmoreuser-friendly,withoutconstantlypesteringthedevelopmentteamwithadhocrequests.
Whatifyoucouldhaveaneasywaytoconfigureanddesigndata-drivenPDFoutputtemplatesorinputforms,andconnectthesetotheappropriateback-endlogicanddata,ensuringcorrectbusinessresultsandprofessionaloutputThat'swhatiTextDITOisallabout.
WhatisiTextDITOiTextDITOsimplifiestheprocessofcreatingmultipleoutputtemplatesorinputforms.
AnintuitiveWYSIWYG(WhatYouSeeIsWhatYouGet)front-endgivesyoutheabilitytocreateyourowndata-drivenoutputtemplatesorinputforms,tiedtoapowerfulback-end.
iTextDITOhandleseverythingfromHTML5inputformcreationanddataprocessingwithJSON,tothegenerationofPDFs–allwithoutrequiringdeveloperstowriteanycode.
Thisprovidesawaytogetresultswhilereducingworkloadfordevelopersandsavingyoutimeandresources.
iTextDITOisanenterprise-gradetemplateenginebuiltonproventechnology;usingiText7CorewithitspdfHTMLandpdfCalligraphadd-onstoenableseamlessintegrationofHTML5,CSS3,PDF2.
0andgloballanguage/ligaturesupportintoyourdocumentworkflows.
Inthiswhitepaper,wediscussthehowandwhyofiTextDITO.
Startingwithabroadoverviewexplainingthefeaturesoftheframework,wethenlookatwhatiTextDITOcando,andhowitcanhelpyou.
Thisdocumentisaimedatdeveloperswhowillhavetoimplementandmaintainthissolution.
Therefore,we'llgointoextensivetechnicaldetail,explainingadvancedfeatures,configurationoptionsandworkflowimplementation.
WhyuseiTextDITOThereisaclearneedinthemarketforasolutionthatoffersusersthepowerofdynamicdata-drivenformcreation,allowingthemtoquicklydesignPDFoutputtemplatesorinputforms.
iTextDITOisapowerfultemplateenginethatconvertsdataintoiTextqualityPDFs.
Thissolutionallowsuserswithouttechnicalexpertisetodesignanoutputtemplateorinputformandlinkittoadesiredoutputdocument,usingasystemsetupbydevelopersfordataprocessing.
Atitscore,iTextDITObridgesthegapbetweenaninputdocumentandthedesiredoutputformat,usingthedatathathasbeengathered.
Thismeansyou'renotlimitedtoforms;theenginecanacceptanydatathatcanbeconvertedtoJSONandoutputtoeitherPDF,orstructureddatathatcanbewrittentootherdatabases.
Allthisenablesyoutohaveatrulydata-drivendocumentworkflowleadingtosignificantsavingsforyourbusiness.
HowiTextDITOWorks:AhighleveloverviewiTextDITOisatemplateenginewithtwomaincomponents:auser-friendlybrowser-basedapplicationandaJavaSDK.
TheJavaSDKcanbeconfiguredbydeveloperstodotheheavylifting,whilethebrowser-basedapplicationgivesusersaneasytousetooltoleveragethepoweroftheJavaSDK.
Theapplicationitselfcanbeconfiguredtofittheneedsofthebusiness,andtheworkflowcanbeintegratedintoanexistingITenvironment.
Usingthebrowser-basedapplicationuserscanquicklycreateHTML5inputformsandoutputtemplateswhichcanbeutilizedinanumberofways,suchasinputformstocaptureandsubmitdataenteredbyusers(forexampleanapplicationform).
Alternatively,youmightwanttopopulateanoutputtemplateusingexistingdatafromadatabase,togeneratePDFinvoicesorotherdocuments.
Youcanalsolinkinputformstooutputtemplates,tobealteredorcombinedwithotherdatabeforebeingoutputtoaspecificstyleandsavedasaPDF.
Thetemplatesarebuiltusingeasytoaddelementssuchasrichtext,textfields,sub-formsandtables.
StylingcanbeaddedtothoseelementsintheiTextDITObrowser-basedapplication,however,ifyourequirefurtherstylingthenyoucansimplyaddyourownCSStotemplates.
Forexample,companyformattingandbrandingcanbeappliedtothetemplatescreatediniTextDITO.
3Allinputfieldscanbelinkedtoavariableidentifyingtheinputfield.
Thisenablestheusertocombinefieldsintocalculations(e.
g.
Total=PricexQuantity),butalsoallowsoutputdocumentstobecreatedeasily.
Someinputdatawillberelevantasoutput,somemightberelevantasasourceforcalculations,andsomemightevenonlybeusedforauthenticationandservenofurtherpurpose.
Databindingmakesiteasytoincludeinputfromnon-humansourcessuchasdatabasesorRESTfulAPIcalls.
iTextDITOusesdataconvertedintoJSONformatturningitintomuchmorethanaformcreationtool;itcanalsobeusedtostructuredatafromdifferentsourcesintooutputdocuments.
Youcanofcoursealsocombineuserinputwithadditionaldatafromothersources.
Whentheuserissatisfiedwithboththeinputformandoutputtemplate,theycanexporttheresulttoaniTextDITOtemplatepackage.
Thisisessentiallyanarchivefilecontainingallthenecessaryinformationtobuildtheforms,includingallrelevantresourcessuchasfontsandimages.
Tousetheinputformoroutputtemplate,youneedtheiTextDITOSDKwhichisavailableeitherasaDockercontainerforusewithnon-Javaenvironments,orasanativeJavalibraryifyouprefer.
TheSDKistheenginepoweringiTextDITOandisresponsibleforbothpublishingandexecutingthelogictomovefrominputdatatostructuredoutputdata.
TheoutputusuallytakestheformofaPDF,butthankstothedatabindingit'salsopossibletoexporttheinput,forexampletostoreitinadatabase.
TheSDKrunsusingtheiTextDITOtemplatepackageandasetofotherparameters.
Itcanbewrappedintoastandaloneapplication(whichmightberunfromthecommandline),butusuallythefunctionalityoftheSDKwillbeintegratedintoexistingsoftware.
Thismighttranslatetoaneasy-to-usebuttonthatuserscanclickwithouttheneedforanyassistancefromdevelopers,apartfromtheinitialintegrationandimplementation.
iTextDITOenablesapowerfulend-to-endworkflowwhereanyusercaneasilycreateoutputtemplatesorinputformsusingdatafromusers,databasesorboth.
Theycanthenapplythenecessarylogictogetendresultsthatsuittheirneeds.
ThiscanbeaPDFsuchasaninvoiceoralegalrecord,orevennewentriesinadatabase.
YouonlyneedtointegrateiTextDITOandupgradetheimplementationasnecessary(forexamplewithnewCSSstyles).
Bothdevelopersanduserscanworkfarmoreefficiently,requiringfarlessofeachother'stime.
4AdvancedfunctionalitydeepdiveTheeditorThepowerofiTextDITOcomesinpartfromthewebapplication.
Theeasy-to-useyetpowerfulWYSIWYGinterfaceallowsevennon-technicaluserstocreateformsthatoperateexactlyasneeded.
Itisthelogicalconnectionbetweeninputandoutput,andthecomprehensivewayinwhichtocreatethatlogic,thatreallymakestheproductunique.
TheeditorisusedtomakeproprietaryiTextDITOtemplatepackages.
Theycontainallthenecessaryresourcestoproducetheneededoutput,inPDForwrittentoanexistingdatabase.
Theapplicationenablesanyonetocreateuniquetemplates.
Itcanrunlocally,butthewebappisusuallyaccessedthroughalocalserver.
Theeditorconsistsofacentralworkspace;ontherightaresubform-toolssuchastable,imageanddatabindingcontrols,andontheleftisacolumnforadditionalfinetuningofthetemplates,withtemplatestylesheetsandelementsalsodisplayed.
RTFAnyuserfamiliarwithtexteditorsoftwarewillimmediatelyfeelathomeinthecentralworkspacearea.
Richtextoptionsallowthemtoeasilyadjustthestyling,font,colorandoutlineoftext.
Textcanbebothstaticanddynamic.
It'spossibletoinsertdynamicintrusionstakenfromdatatocustomizeeachoutputform.
Obviousexamplesareinvoicenumbers,ornamesofrecipientstakenfromanexistingdatabase.
5SubformsCentraltothefunctionalityofanyformarethesubforms.
Asubformisagroupcontainingdifferentelements.
Byeditingthesubform,allelementswithinitareaffected.
Itispossibletodirectlyaffectthevisualstyleofaformthroughsubforms.
Whencreatinganinvoiceform,forexample,theusercangrouptheitemname,number,quantityandpriceinasubformandcreateaborderaroundalltheseelements.
Visually,thismakesiteasierforanyonefillingtheformtokeepanoverview.
Furthermore,thesubformsallowforsomepowerfuldynamicfeatures,aswe'lldiscussfurtherinthisdocument.
TablesiTextDITOalsosupportstables.
Thisfeatureisespeciallyusefulwhencombinedwithdatabindingofthetablefields.
ItallowsiTextDITOtogetinputdatafromexistingdatabases,oroutputdatagatheredthroughtheformstootherdatabases.
Iftherearemultipleinputvaluesavailableforatablerow,itcanberepeatedasoftenasnecessary.
Auserfillingouttheformcanmanuallyaddnewrows,butiTextDITOcanalsoautomaticallyaddnewitemsasneededwhengettinginputfromaJSONfile.
Intheexampleoftheinvoiceform,youcanimagineatablecontaininganitemname,apriceandaquantityineachrow.
IfyouwanttouseiTextDITOtocreatePDFinvoicesfromadatabase,you'llbeconfrontedwithdifferentcustomersorderingdifferentamountsofitems.
Ifacustomerordersalaptopatacostof500dollars,andakeyboardatacostof10dollars,thetablecanautomaticallycreateasecondrowcontainingtheseconditem.
TextAtextfieldisaverystraightforwardadditiontoanyform.
Itallowstheusertotypewhatevertheywant.
Firstandlastnamesarestraightforwardexamples.
Ausercancreateplaceholdertextthatwillappearinanunfilledtextformbox,toclarifywhatisexpected.
Theycanalsoattachstylesorspecifydatabindings.
ImagesAsaformshouldusuallyreflectthecompanystyle,addingimagesisanessentialfeature.
Youcanaddimagesfromtheinternetoruploadyourown.
UploadedimageswillbearchivedintheiTextDITOtemplatepackageaftercreationofthetemplate.
Themostpopularusecaseforaddingimagesistheinclusionofacompanylogo.
6CheckboxTheadditionofcheckboxesisratherstraightforward.
Ofcourse,it'spossibletospecifythelabelandthestyleaccompanyingthecheckbox.
SubmitbuttonThesubmitbuttonisonlyavailableforinputtemplatesandcan'tcorrespondwithanelementontheoutputtemplate.
Asthenamesuggests,thebuttontriggersthecollectionofthedatafromtheform.
Whenthebuttonisclicked,thedataissenttoapreviouslyselectedURI.
ThedatacannowbeusedtoproduceaPDFoutputtemplate,butitcanalsobestoredinadatabase.
Youcaneasilycustomizetheappearanceofbuttonstofitthetemplatestyle.
InputversusoutputTheworkflowforcreatingtheoutputformisalmostidenticaltothecreationoftheinputform.
It'spossibletoomitcertaininputorperformcalculationsoninputfieldsinordertogenerateoutputfields.
Byadjustingthestyle,theoutputformquicklybecomesaformaldocumentthatstandsonitsownanddoesn'tjustlooklikeacheapreplicaoftheinputform.
Howdifferenttheinputandoutputformslookdependsentirelyonyourbusinessneeds.
FormattingandlogicThebrainofiTextDITOistheSDKwhichusesmanycomponentsoftheiText7code,althoughitisavailableasaseparateproduct.
ThesoftwareisbuiltontheOpenWebPlatformstack,butmorespecifically,HTML,CSSandJavaScriptarethefoundationsofiTextDITO.
ThispowerfulSDKparsesiTextDITOtemplatescreatedwiththeeditorandhasalotofadvancedfunctionswhichmakeitidealfordataprocessing.
Inthissegment,we'lldiscussinsomedetailthewayiTextDITOhandlesdataandlogic,andhowyoucanadddynamicformatting.
Someofthefeaturesbelowarequiteadvancedandareintendedforimplementationbytechnicalusers.
Weprovidethefollowingdocumentationforthebenefitofdevelopers.
DatabindingDatabindingconnectsdatawithtemplateelements.
Bindsmakeitpossibletousedatadynamically;tocreateoutputformsusingdatafrominputforms,tostoredataindatabases,andtoautomaticallyinputdatafromnon-humansources.
Supposeyouwanttocreatecustomticketsforanevent,andyoualreadyhaveallthenecessaryinformationoftheinviteesstoredinadatabase.
Youwanttocreateaninputformtogathertherelevantdatafromthedatabase,andanoutputformthatlookslikethefinalinvitationyou'dbesending.
ThisoutputformisaPDF,builtfromthedatainthedatabase.
Thefirstthingyouneedtoaddisafirstname.
YouneedtocreateJSONdatadefiningthedatabindproperty,followedbythefieldvalue.
TheJSON-datacouldlooklikethis:{"first_name":"John"}first_nameisthevalueofthedatabindpropertyofafield,whilethefieldvaluetakenfromthedatasourceisJohn.
Ifyouspecifyafieldcontainingtextinputandbindthatinputtofirst_name,thefieldwillautomaticallyresolvetoJohn.
7DatabindpropertiesWhenwebindvaluesfromdatatoatemplateitgoesthroughthefollowingtransformation:datavalue->rawvalue->displayvalueTherawvalueistheinternalformatthatiTextDITOuses.
Thedisplayformatcoversthesecondtransformationwhilethebindformatisresponsibleforthefirstone.
Thesamesyntaxisusedforboth.
Bindformatshouldbespecifiedwhendataisexpectedinaformatthatisdifferentfromtheinternalformat.
Intheexampleabove,iTextDITOreadsthedate-timefromdatastoredinBrusselstimezoneformatanddisplaysthetimeinUTC.
ResolvinglogiciTextDITOresolvesinputfollowingasetofrules.
Itisimportanttoknowtheserulesinordertogettheresultsyouwant,whenusingJSONinputdatawithaformtemplate.
ResolvingorderThedataisautomaticallyresolvedagainstthedataboundtothenearestelementinaparentchain,ortotherootdataifnoparentsinthechainareboundtodata.
Supposeyou'vecreatedafieldwithabinding(first_name),nestedwithinasubformwithoutbinding,nestedinturnwithinaparentsubformwithabinding(person).
subform("person"binding)|---subform(nobinding)|---field("first_name"binding)NowimaginetheJSONdataforinputlooksasfollows:{"person":{"first_name":"John"},"first_name":"JaneInthisexample,thefieldwillresolvetoJohn,asthealgorithmlooksforthenearestboundparent,inthiscasethesubformperson.
Youcanchangethisbehaviorbyaddingthe$signinfrontofadatabindvalue.
Theparametertellsthealgorithmtolookforthebindingrelativetothedataroot.
So,theformstructurewouldlooklikethis:8subform("person"binding)|---subform(nobinding)|---field("$.
first_name"binding)Thefieldwouldresolvewiththefirst_namebindingclosesttotherootoftheJSONdataexample,whichisJane.
ResolvingmultipledataentriesResolvingdatatodataboundfieldsiseasywhenthereisexactlyoneentrythatcorrespondswithonefield.
Moreoftenthannot,thenumberofdataentriesisvariable.
Youmighthaveonecustomerwhoorderedtwodifferentitems,andanotherwhoorderedten.
Ifyouwanttoautomaticallycreateinvoicesfromanexistingdatasetcontainingtheorders,yourformneedstocopewiththisvariableinput.
Specifically,youwouldneedtherelevantsubformtoautomaticallymultiplyasmanytimesasneeded.
Thatway,youonlyhavetoaddasinglesubformwithentryfieldsforitem,quantityandprice.
Ifacustomerordersmorethanoneitem,anewlineisadded,asmanytimesasneeded.
Byaddingthe[*]parametertothedatabindvalueofafieldinthewebeditor,thealgorithmknowsitneedstomultiplyasubformasmanytimesastheinputdatarequires.
Apartfromtheparameter,thestructureremainsthesame.
subform("people[*]"binding)|---field("first_name"binding)---field("last_name"binding)Nowthesubformwillmultiplyforeachdataentry.
Iftheinputdataspecifiesthreefirst_nameandlast_namebindslikeintheexamplebelow,theabovesubformwillbeaddedtotheformthreetimes.
{"people":[{"first_name":"John","last_name":"Doe"},{"first_name":"Jane","last_name":"Diluca"},{"first_name":"Han","last_name":"Pak"}]}The[*]parametermeansyouneverhavetoaddthesamesubformmultipletimesmanually,whilealsogivingyourtemplatetheflexibilitytohandleanunknownamountofdataentries.
Ifyouwanttopublishaformformanualfilling,youcancheckacheckboxinthewebeditortoadd+and-buttonsnexttoasubform.
CalculationsandlogicWe'vealreadytalkedaboutperformingcalculationsiniTextDITO.
Sometimes,itmightbeimpossibletoshowthenecessaryinformationontheoutputformusingonlydatabinding.
Youmightforexamplewanttoshowatotalattheendofaninvoice,containingthesumofallitemsorderedintheirrespectivequantities,multipliedbytheVAT.
Inordertosimplifyprocessingofthedatawithouttheneedforpre-processing,iTextDITOcanhandlemanystraightforwardcalculations.
Calculationsallowyoutoassignvaluestocertainfieldsdependingonthevaluesofotherfields.
It'spossibletocalculateafieldusingotherfieldswhicharetheresultsofcalculationsthemselves.
Inasense,youcantreatiTextDITOlikeasimplespreadsheet.
9Inordertoperformcalculationsonthevariablesinafield,youmustnamethefields.
Thefieldnamesactasvariablesthatyoucanuseinmathematicalexpressions.
Ifyouhaveafieldnamedpriceandanotheronenamedquantity,youcancreateafieldshowingthetotalofanorderbydefiningitasprice*quantity.
The[*]parametercanbeusedinthiscontextaswell.
Theparameterallowsyoutoperformacalculationusingavariablenumberoffields.
If,forexample,youwanttocalculateagrandtotalbasedontheorderofanunknownnumberofdifferentitems,you'dneedthesumofthepricefieldofallthoseitems.
Youcandothisbyusingthefollowingnotation:sum(price[*])iTextDITOsupportsthefollowingfunctions:-sum-product-concatAndthefollowingoperators:DataMappingModeTheeditorhasanadditionalviewmodetoseeandconfiguredatabinding.
Youcanswitchtothedatamappingmodebyclickingthefollowingbuttonintheeditor:Thiswillgiveyouaviewlikethis:10VisualstylesandformattingWealreadytalkedaboutsomeeasy-to-usevisualoptionswithinthewebeditor,butiTextDITOhasfarmoreupitssleeve.
YoucandefineveryspecificpersonalstylesusingCSScode,andyoucanevenmakeasingleformlocallyresponsivebasedontheregioninwhichyouwanttouseit.
ValueformattingValueformattingfunctionsarepowerfultoolsthatenableyoutodisplayvaluesinspecificwaysintheoutputform.
Youcanusethefunctionstospecifythedesiredformat.
Currently,iTextDITOsupportsnumberandcurrencyformatting.
Numberformattingisrepresentedasastring,precededbythenumoperator.
Aformattingstringmightlooklikethis:num('$#,##0.
00','de-de')Intheaboveexample,therearetwoarguments.
Thefirstonespecifiesthepattern;thesecondargumentaddsalocale.
Alocale-parameterisoptional,butveryhandywhenyouwanttodeployasingleforminmultiplegeographicalregions.
Itaffectsgrouping,decimalseparatorsandcurrencysymbols.
Forexample,aformatof#,###.
00andatextof4500.
20willlookasfollowswithalocaleof"de":4.
500,20Andasfollowswithalocaleof"us":4,500.
20Therearesixspecialcharactersyoucanusetodefineformatting.
Allothercharactersinaformattingstringwillbeleftintact.
-0(Digit)-#(Digit,zeroshowsasabsence)-.
(Decimalseparator)--(Negativesign)-,(Groupingseparator)-%(Percent,multipliesnumberby100)Time/dateformattingFortime/dateformatting,aswithnumberformattingtherearetwoargumentsthatspecifythepattern,andthe(optional)timezoneID.
IfnotimezoneIDisspecified,thenthelocalonewillbeused.
AnexampleshowingthelocaltimeanddateinPariswouldbeformattedasfollows:date('YYYY-MM-DDHH:mm:ssZZ','Europe/Paris')TheZZinthisexampledisplaystheUTC(CoordinatedUniversalTime)offsetfromtheselectedtimezone.
Thepatternconsistsofspecialcharactersaswellasanyothercharacters,specialcharacterscanbeescapedwith[]brackets.
11Specialcharacters:Month:M-12.
.
.
1112Mo-1st2nd.
.
.
11th12thMM-0102.
.
.
1112MMM-JanFeb.
.
.
NovDecMMMM-JanuaryFebruary.
.
.
NovemberDecemberQuarter:Q-1234Qo-1st2nd3rd4thDayofMonth:D-12.
.
.
3031Do-1st2nd.
.
.
30th31stDD-0102.
.
.
3031DayofYear:DDD-12.
.
.
364365DDDo-1st2nd.
.
.
364th365thDDDD-001002.
.
.
364365DayofWeek:d-01.
.
.
56do-0th1st.
.
.
5th6thdd-SuMo.
.
.
FrSaddd-SunMon.
.
.
FriSatdddd-SundayMonday.
.
.
FridaySaturdayDayofWeek(ISO):E-12.
.
.
67WeekofYear:w-12.
.
.
5253wo-1st2nd.
.
.
52nd53rdww-0102.
.
.
5253WeekofYear(ISO):W-12.
.
.
5253Wo-1st2nd.
.
.
52nd53rdWW-0102.
.
.
5253Year:YY-7071.
.
.
2930YYYY-19701971.
.
.
20292030Y-19701971.
.
.
9999+10000+10001WeekYear:gg-7071.
.
.
2930gggg-19701971.
.
.
20292030WeekYear(ISO):GG-7071.
.
.
2930GGGG-19701971.
.
.
20292030AM/PM:A-AMPMa-ampmHour:H-01.
.
.
2223HH-0001.
.
.
2223h-12.
.
.
1112hh-0102.
.
.
1112k-12.
.
.
2324kk-0102.
.
.
2324Minute:m-01.
.
.
5859mm-0001.
.
.
5859Second:s-01.
.
.
5859ss-0001.
.
.
5859FractionalSecond:S-01.
.
.
89SS-0001.
.
.
9899SSS-000001.
.
.
998999SSSS.
.
.
SSSSSSSSS-0000.
.
0010.
.
.
.
.
9980.
.
9990.
.
TimeZone:z/zz-ESTCST.
.
.
MSTPSTZ--07:00-06:00.
.
.
+06:00+07:00ZZ--0700-0600.
.
.
+0600+0700UnixTimestamp:X-1360013296UnixMillisecondTimestamp:x-136001329612312Notesontime/dateformatting:Formonthformatting,usingtheMMMMpatternwillnotresultinfour-lettermonths,butwillinsteadreturnfullmonthnames.
Ifanincompatibletimeisparsed(onewithtwoconflictinghoursdeclarationsforexample)thenanexceptionwillbethrownIfthepatterndoesn'tcontainmorespecificinformation(e.
g.
itcontainsayearbutdoesn'tcontainamonth)thenformorespecificinformationtheinitialvaluewillbeused(firstmonth,firstdayetc.
)Ifthepatterndoesn'tcontainmorebroadinformation(e.
g.
itcontainsamonthanddaybutdoesn'tcontainayear)thentheclosestpossiblelocalinformationwillbeused(e.
g.
2019fortheyearetc.
)IfthepatternhasaUTC(CoordinatedUniversalTime)offsetthenitwillbeused,andthetimezonewillbeignored.
DuetoDST(daylightsavingtime),thereisapossibilitythatatimeeitherdoesnotexist,orithaspreviouslyexisted.
Ifyoutrytoparseatimethatneverexisted,itwillskipforwardbytheamountoftheDSTgap(usually1hour).
Ifyoutrytoparseaduplicatedtime,thentheearlierinstancewillbetaken.
StylesheetsandclassesiTextDITOtemplatesmakeuseoftheOpenWebPlatform.
ThetemplatesarethereforetoagreatextentcompatiblewithCSSstylesheets.
AdvanceduserscancustomizealmostallvisualpropertiesofatemplatewithCSS.
However,sincetheiTextDITOwebeditorismeanttobeusedbynon-technicalusers,CSSknowledgeisnotrequired.
Anyonecanmodifythevisualstylingwiththedesignertool,butCSSofcourseoffersmoreflexibility.
YoucanalsoembedpersonalizedstylesheetswhileintegratingiTextDITOintothecompanyinfrastructure.
Youcanaddtherelevantstylesonce,allowingtheusertoselectthestyleneedingtounderstandCSS.
Youcanaddanewembeddedstylesheetoruseanexternalone.
Thestylesheetscanbelinkedwithelementsthroughelementclasses.
It'salsopossibletospecifystyleswithoutexplicitlylinkingtothem.
Forexample:*[data-dito-element="rich-text"]{color:red;Inthisexample,allthetextinrichtextelementswoulddefaulttored,unlesstheuserexplicitlyoverridesthetextcolorbychangingthelay-out.
InstallationandintegrationiTextDITOisnotanout-of-the-boxapplication.
TheframeworkneedstobeintegratedwithanexistingITinfrastructure.
Whileanyonecanusetheframeworktocreatetemplatesandforms,theintegrationneedstobedonebyanexperienceddeveloper.
ThedevelopercandefineoptimalworkflowsbyintegratingwiththeexistingITinfrastructure.
iTextDITOisonlyavailableforJavaandrequiresJava8torunthewebeditorapplication.
FormsarepublishedanddataisprocessedwiththeJavaSDK.
TheSDKalsoproducesthePDFoutput.
iTextguaranteessoftwarecompatibilitywithboththeOracleJREandOpenJRE.
Youneedversion8withupdate152.
iTextDITOmightnotworkproperlyonolderversions.
WebeditorinstallationYoucandownloadtheJARfilefromtheiTextArtifactory.
Inordertorunthewebeditorapplication,you'llneedaconfigurationfilesuchasthisone:13server:applicationConnectors:-type:httpport:8080adminConnectors:-type:httpport:8081logging:level:INFOworkDirectory:path:D:/DITOWorkAsyoucansee,theeditorusestwoports.
Thefirstone(8080intheaboveexample),isusedtoaccessthewebeditoritself.
Usersoftheapplicationwillconnectthroughthisport.
Thesecondport(8081)isusedforaccesstoadministrativefeatures.
Youcanofcourseconfiguretheportsmanually,aslongastheeditorandtheadministratorconnectoruseadifferentone.
Youshouldmakesuretheadminportisn'taccessiblefromoutsidethelocaltrustednetwork.
TheworkDirectoryparameterspecifiesthedirectorythatwillbeusedfortemporarystorage.
Thisparameterisrequiredforthewebeditorapplicationtoworkcorrectly,makesurethepathisvalid.
iTextDITOusestheDropwizardwebserverintheback-end.
Ifyouneeddocumentationdetailinghowtosetupthehttpsconnectionandhowtoaddhttpscertificates,youcanrefertotheDropwizardconfigurationmanual,availableonline.
Inordertoruntheeditorapplication,youneedthefollowingcommand:java-jardito-server.
jar{server,check}config.
ymlTheservercommandstartsthewebapplication.
Assoonasit'sstarted,itshouldbeavailablethroughthespecifiedport.
Thecheckcommandmakessuretheconfigurationfileoffersvalidconfigurationdata.
Ifsomethingisnotworkingproperly,you'llseetheerrorsprinted.
Asanadministrator,youcanaccessthehealthcheckfeature.
Healthcheckshelpyouidentifythecauseofproblemswiththeapplication.
Thefeatureisavailablethroughtheadministratorport:http://localhost:8081/healthcheckTheresultofahealthcheckisreturnedinJSONformat.
{"deadlocks":{"healthy":true},"workDirectory":{"healthy":true}}Assumingeverythingworkswell,you'llsee{"healthy":true}forallchecks.
Ifthereisaproblem,theJSONdatawillcontainamessagedescribingtheproblem.
Forexample:"workDirectory":{"healthy":false,"message":"Workdirectorydoesnotexist"}JavaSDKTheJavaSDKistheheartandbrainsoftheiTextDITOframework.
TheSDKdeploystheinputform,producesoutputPDFsfromoutputtemplates,processescalculationsandformatting,andprocessesinputandoutputfromandtoexternaldatabases.
14InstallingwithMavenTheJavaSDKisavailableasaMavenmodule.
Inordertoinstallit,youneedthenecessarydependencyfromtheiTextArtifactory.
First,youneedtoaddtherepositorytotheMavenPOMfileasfollows:ditoDITORepositoryhttps://repo.
itextsupport.
com/ditoSubsequentdeploymentiseasy.
JustaddthedependencytoyourPOMfilelikethis:com.
itextpdf.
ditosdk-java${dito.
sdk.
version}Thedito.
sdk.
versionstatementisavariablespecifyingyourcurrentversionoftheframework.
Thevaluecanforexamplebe1.
0.
0.
InstallingwithGradleToreferencetheJavaSDKfromGradle,youneedthenecessarydependencyfromtheiTextArtifactory.
First,youneedtoaddtherepositorytotheGradlebuildfileasfollows:repositories{mavenCentral()maven{url"https://repo.
itextsupport.
com/dito"}maven{url"https://repo.
itextsupport.
com/releases"}}Referencingthedependencyisnoweasy.
Justaddthecorrespondingentrytothedependenciessection:dependencies{compilegroup:'com.
itextpdf.
dito',name:'sdk-java',version:ditoSdkVersion}TheditoSdkVersionstatementisavariablespecifyingyourcurrentversionoftheframework.
Thevaluecanforexamplebe1.
0.
0.
WorkflowintegrationEveryiTextDITOworkflowstartswiththecreationofaformtemplate,exportedtoaniTextDITOtemplatepackage.
Thisfilewillbeatthecenteroftherestoftheworkflow.
You'llprobablywanttodeployinputforms,acceptdatasubmissionsforthoseforms,andfinallycreateoutputPDFsusingtheinputdata,followingtheoutputtemplate.
LoadingthelicensekeyBeforeyoucanusetheJavaSDK,youneedtoinstallthelicensekey.
Thisiseasilymanagedbyusingthefollowingcommands:FilelicenseKeyFile=".
.
.
";DitoLicense.
loadLicenseFile(licenseKeyFile);15ForvolumelicensecustomersWeadvisequeryingyourremainingvolumefrequentlyandsendingawarningmessagetoyourownapplication/systembeforethelimitisreachedandstopsworking.
ForcustomersusingthenativeiTextDITOJavaSDKyoucancallgetRemainingProducePagesEventsusingtheAPIandthisfunctionwillreturnthenumberofpagesremainingonyourvolumelicensekey.
Ifyouhaveaperpetuallicense,thiscallwillreturnnull.
ForiTextDITOSDKforDockerusersitisevensimpler.
Simplycall/api/licensetodisplaytheexpirationDateofyourlicensekeyaswellastheremainingvolume.
InputformdeploymentAssoonasauserhascreatedatemplatepackageusingtheeditor,thepackagecanbedeployedinyourwebserverenvironment.
TheJavaSDKwillprocessthepackageintoaninputform.
YouneedtheInputTemplateDeployerclassfromthecom.
itextpdf.
dito.
sdk.
inputpackage.
Fourparametersarerelevant.
Youneedtospecifythepathtothetemplatepackageyouwanttouse,thenameoftheinputtemplateinsidethepackage,analiasfortheinputformandanoutputfolder.
Thedeployedformwillbestoredinthislocation.
FileprojectFile=newFile("templatePackage.
dito");StringtemplateName="input";FiledeployFolder=newFile("deployed");InputTemplateDeployer.
deployTemplateFromPackage(projectFile,templateName,deployFolder);Insidethefolderspecifiedfordeployment,youcanfindaninputfile.
Thisfilecontainstheactualformyou'vecreated.
Thefilenamewillbeidenticaltothetemplatename,asspecifiedintheTemplateNameargument.
Astheformisnowcreated,you'refreetorenameitintoanythingyoulike.
Thefolderwillalsocontainasubfoldernamedjs.
Inside,theJavaSDKhasputthefilesnecessarytosupportinteractivefeaturesoftheform.
Ifapplicableforthetemplateyou'veused,you'llalsofindaresourcesfolderhere.
Youcanhostallfilesdirectlyfromthedeploymentfolder.
iTextDITOallowsforflexiblepublicationoftheform.
Youcan,forinstance,createadedicatedwebpageanddirectusersthere,oryoucanembeditinsideanexistingwebpageusingan.
AcceptingdatafromformsWhendesigningthetemplate,youcanspecifyaURI.
Datacollectedbytheform,willbesentthereusingPOSTorPUT,asspecifiedduringthedesignofthetemplate.
Thetypeofthedatapayloadisapplication/x-dito-data-submission,butyoucaneasilyconvertthedatatoatypethat'seasiertoworkwith.
Fornow,onlyJSONissupported.
DatasubmissionsarehandledbytheDataSubmissionclassfromthecom.
itextpdf.
dito.
sdk.
submissionpackage.
TheexamplebelowillustrateshowtogetsubmissiondatainJSONformatfromtheInputStream,whichrepresentsthepayload:Stringjson=DataSubmission.
fromInputStream(is).
asJsonString();16PDFcreationOneoftheprimaryfunctionsofiTextDITOistheautomaticcreationofstylishandusefulPDFsbasedondatagatheredbytheinputform.
Ifthetemplatepackagecontainsanoutputtemplate,allyouneedisthePdfProducerclassfromthecom.
itextpdf.
dito.
sdk.
outputpackage.
CreatingaPDFusinganoutputtemplateandJSONdatamightlooklikethis:FiletemplatePackageFile=newFile(templatePackagePath);StringtemplateName="output";FileOutputStreamfos=newFileOutputStream(newFile(outFilePath))StringjsonPdfProducer.
convertTemplateFromPackage(templatePackageFile,templateName,fos,newJsonData(json));YoucanalsocombineacceptingdatasubmissionsandcreatingPDFs.
Thatway,aPDFwillbecreatedforeachfilledoutform.
Theexamplebelowshowshowyoucanautomatetheworkflow:Stringjson=DataSubmission.
fromInputStream(is).
asJsonString();FiletemplatePackageFile=newFile(templatePackagePath);StringtemplateName="output";FileOutputStreamfos=newFileOutputStream(newFile(outFilePath))StringjsonPdfProducer.
convertTemplateFromPackage(templatePackageFile,templateName,fos,newJsonData(json));UsingiTextDITOWehavenowcoveredtheiTextDITOframeworkquiteextensively.
We'vealsodiscussedtheneedforadata-drivensolutionlikeiTextDITO,thepossibilitiesoftheframework,andwe'vetouchedonthemostimportanttechnicalaspects.
Below,you'lldiscoverasimpleexampleofaworkflowusingiTextDITO,usingasanexamplethecreationofaninvoicetemplate.
AusecaseexampleAninvoicetemplateisastraightforwardexampleofaniTextDITOusecase.
Youcaneasilyimagineasalesrepresentativeinthefieldusingatablettoinputordersforacustomer.
Thesalesrepwouldneedaneasytoolattheirfingertips,whilethecustomerrequiresaprofessionallookingandeasilyunderstandableinvoiceforpayment.
Inthisscenario,theheadofsalescanuseiTextDITOtodevelopaformforusebythesalesrep.
Thedynamicformallowsthemtoaddproductstoanorder,specifyhowmanyproductsareordered,andexpandtheorderwithmultipleproductsasnecessary.
Bycompletingtheinputform,thesalesrepcanthenplacetheorder.
Ofcourse,itwouldn'tdotosendthecustomerascreenshotoftheform.
Eventhoughitlookscleanandeasytouse,it'snowheregoodenoughtoserveasaninvoice.
Furthermore,arealinvoiceneedstohavespecificinformationincluded,suchasanaccountnumberoraddresses.
Lastly,thecustomerexpectstheirinvoicetoarriveviaemailinPDFformat,asPDFoffersawidelycompatibleyetunchangeabledigitalfilethatcarrieswithitasenseofauthority.
WithiTextDITO,theordermadebythesalesrepresentativeisautomaticallyconvertedtoaPDFfilethat'sreadytobeemailedtothecustomer.
What'smore,iTextDITOhandlesthedatagatheredthroughtheinputforminsuchawaythatitcanbesharedwithotherpartsofthecompany'sITinfrastructure.
Imaginetheordergoingstraighttotheorderpickersinthewarehouse,forfastdelivery.
WheniTextDITOhasbeenimplementedcorrectly,theheadofsaleswouldnotneedthehelpofadevelopertocreateboththeformandthePDFoutput.
Theycouldeasilybuildatemplateforboth,followingthecompanystyleandformatting.
17ComprehensivewalkthroughNow,let'shavealookathowtheaboveusecasewouldtranslateintoapracticalworkflow.
Thetemplatewearecreatingmightbeusedbyasalesperson.
Theycanfillouttheformwithordersfortheircustomer.
Aftersubmittingtheorder,iTextDITOwillautomaticallycreateaprofessionallookinginvoiceinPDF.
We'llusesampledatatotryoutourform:{"invoice_no":"12345","company_name":"ABC,Inc.
","address":"12Weststreet,NY,USA","items":[{"name":"Bluepen","price":"20.
1","quantity":10},{"name":"Blackpencil","price":"0.
1","quantity":1},{"name":"Redpen","price":"20","quantity":78},{"name":"Bluepencil","price":"0.
15","quantity":13}]}Thecreationofthetemplatestartsinthewebeditor.
Westartournewprojectbyuploadingthecompanylogo.
Ontheleftoftheeditor,youcanfindtheresourcespanel.
Here,youcaneitheraddanimagefromtheweboruploadyourown.
Assoonastheimageisadded,youcandragittotheeditingarea.
Theeditorwillautomaticallycreateanewelementcontainingtheimage.
Next,wealigntheimagetotherightofourform.
Inordertodoso,wemustfirstwrapitintoasubform.
Clickthesubformiconinthetoolboxanddragtheimageintothesubform.
Nowwecanapplytherighttextalignmentfromtheparagraphstyleproperties.
Theresultlooksasfollows:18Theinvoicewearecreatingwillhaveauniquenumber,shownatthetopoftheform.
Inordertoaddthisheader,weneedanewstatictextelement.
Youcaneasilyadditandusethestylecontrolstoeditthevisualappearanceofthetext.
Ourformmusttaketheinvoicenumberfromtheinputdata.
Inordertodoso,weinsertadatabindingintrusionwiththevalueinvoice_no.
Clicktheunderlinedbuttonontherightofthetoolbartoaddthebinding.
Youcanaddstatictextelementscontainingthecompanynameandaddressinasimilarway.
Wealignthecontactinformationtotheright,soitsitsneatlyunderneaththelogo.
Sincewealreadyhavesomedatabindinggoingon,it'sagoodideatodoapreview.
Atthetopoftheeditorwindow,youcanfindthepreviewbutton.
iTextDITOneedssampledataforthepreviewSowecanusethedataprovidedatthebeginningofthissegment.
TheJSONdatacontains"invoice_no":"12345"asthefirstentry.
Thevalue12345correspondswiththeinvoice_novariable,whichweusedasadatabindinourform.
Thepreviewshowstheexpectedresult:Ineditingmode,it'stimetoaddthebulkofourinputform.
Weneedatablecontainingthenameoftheitembeingbought,theunitprice,thequantityoftheorder,andthetotalforthatitem.
Underneath,weaddafieldwiththegrandtotalfortheentireorder.
Thetableaboverequiressomeconfiguration.
Weneedtodefinetherelationshipbetweentheindividualfieldsandtheinputdata,butalsobetweenthefieldsthemselves.
Wenotonlyneedtoapplydatabindingtothefields,butwemustalsonamethem.
Thatway,wecaninvokethevalueofthefieldsasvariablesforfurthercalculations.
Theitemname,itempriceanditemquantityfieldsallneedadatabindandaname.
Youcanusename,priceandquantityforboth.
Theexamplebelowshowshowthepropertiesoftheitemnamefieldneedtobefilled.
Theitemtotalfieldwillbefilledusingdataprovidedbytheitempriceanditemquantityfields.
Therefore,itdoesnotneedadatabind.
Thefielddoesneedanamethough,aswearegoingtoperformcalculationsonintheGrandtotalfield.
Wecallititem_total.
UnderCalculation,weselectproduct.
Inordertocalculatethetotalamountowed,thefieldmustcontaintheproductofpriceandquantity.
19BeforewecanmoveontotheGrandtotalfield,weneedtotellourformthateachitemfromtheinputdataneedstohaveitsownrowinthetable.
Inotherwords:thetableneedstoextenditselfwithadditionalrowsasmanytimesasthereareitemdataentriesintheJSONdata.
Thismakestheformflexible;itwillbeabletohandleorderscontainingonlyoneitemaswellasorderscontainingmultipleitems.
Selectthesecondtablerow(theonecontainingthefields)fromtheelementstreeontheleft,andspecifythemultiplieditems[*]binding.
Anotherpreviewwillillustratetheresultofthisbinding.
AstherearefourentriesunderItems,theformwillautomaticallyaddfourrowsinthetable.
TheItemtotalwillalsobefilledasaproductofquantityandpriceforeachitem.
Thisworksperfectly,assumingallinputcomesfrompreviouslygathereddata.
Ofcourse,oursalesrepresentativeshouldbeabletousetheformmanuallytoputinaclient'sorder.
Ifwewantthemtobeabletoaddmultipleitemstooneinvoice,weneedtoaddinteractivecontrols.
Thesecontrolswillappearnexttoarowinthetable.
Byclicking'+',therepresentativewillbeabletoaddanewrowmanually.
Withthe'-'button,theycanremovearow.
SelectthesecondrowofthetableagainandlookfortheAddinteractiverepeatablecontrolsoption.
Clickthecheckboxtoenablethefeature.
Lastly,weneedasubmissionbutton.
Byclickingthisbutton,datawillbesenttothedestinationofourchoice.
Addthebutton,andtrypreviewingtheformwithoutanyinputdata,soyoucanseethevanillaformthatwillbepresentedtothesalesrep.
20Theformstilllooksrathercrude,butalltherequiredfunctionalityisthere.
Nowyoucantryandpolishtheform,oryoucanapplycustomCSSstylestoreallywrapitinthecompanystyle.
Nowyoucancopytheinputtemplatetotheoutputtemplate.
Youmustgetridofthebuttonstomanuallyaddorremoverows,andthesubmitbuttonisalsouselesshere.
TheoutputformwillbeconvertedtoPDFandserveasanofficialinvoice,soitshouldlookaccordingly.
Youcanpreviewtheoutputwiththesampledatatoseehoweverythingwilllook.
Whenyou'resatisfied,youcanexportthetemplatetoaniTextDITOtemplatepackagereadyforusebytheJavaSDK.
Conclusion:TakingactionwithiTextDITOiTextDITOisapowerfultoolthatempowersbusinessuserswhiledecreasingthetimedevelopersmustspendperformingnonessentialtasks.
Inbusinessestoday,userswanttousetechnologytoachieveagoal.
Theyknowwhattheyneedbutmaylackthetechnicalknowledgeandbackgroundtotranslatetheirvisionintoreality.
Developershavethisknowledgebutaren'talwaysfamiliarwiththespecificneedsoftheenduser.
Bothofthemtryingtoworkoutasolutiontoaproblemisn'tveryefficient.
ThemaingoalofiTextDITOistoprovideuserswiththetoolstoturntheirowndata-drivenformsvisionintoreality,withoutneedingtoinvolveadeveloper.
Valuabletimegetssaved,whilethepaceofinnovationisincreased.
TherestillisanimportantroleforthedeveloperintheearlystagesoftheimplementationofiTextDITO.
TheymustdotheactuallegworkofintegratingtheframeworkintheexistingITinfrastructureandconfiguringittobeused.
Butafterthisinitialconfiguration,thetoolisreadytogo.
iTextDITOistheonlyframeworkavailabletodaythatempowersenduserstocreateadvancedandfunctionalformscombinedwithPDFoutput.
WithiTextDITOinstalled,userscancreateavarietyofformsinthelookandfeeloftheirchoice.
Theinputoftheformsiseasilystructured,canbeoutputtoadatabase,andofcourseconvertedtoPDFtobeeitherusedorarchived.
SoundinterestingContactustolearnmoreat:https://itextpdf.
com/en/products/itext-dito.
AboutiTextiTextistheworld'sforemostplatformtocreatePDFfilesandintegratethemincorporateapplications.
Originallyreleasedin2000,iTextisavailableasanopensourceproductwithcommunitysupport,aswellasacommercialproduct,worldwidesupportedbytheiTextGroupNV(withofficesinEurope,NorthAmericaandAsia).
In2016,thepopulariText5versionwassucceededbythefullyre-writtenandre-architecturediText7platform,withadvancedadd-onoptions.
iTextrepresentsauniquecapabilityoffacilitatingtheuseofdynamicandcomplexPDFdocumentsincorporatedocumentworkflows,throughoutthewholedocumentlifecycle.
对于Megalayer云服务器提供商在之前也有对于他们家的美国服务器和香港服务器进行过评测和介绍,但是对于大部分网友来说需要独立服务器和站群服务器并不是特别的普及,我们很多网友使用较多的还是云服务器或者VPS主机比较多。在前面也有在"Megalayer新增香港VPS主机 1GB内存 50GB SSD 2M带宽 月59元"文章中有介绍到Megalayer商家有新增香港CN2优化VPS主机。那时候看这...
商家介绍:创梦云是来自国内的主机销售商,成立于2018年4月30日,创梦云前期主要从事免备案虚拟主机产品销售,现在将提供5元挂机宝、特惠挂机宝、香港云服务器、美国云服务器、低价挂机宝等产品销售。主打高性价比高稳定性挂机宝、香港云服务器、美国云服务器、香港虚拟主机、美国虚拟主机。官方网站:http://cmy0.vnetdns.com本次促销产品:地区CPU内存硬盘带宽价格购买地址香港特价云服务器1...
NameSilo是通过之前的感恩节优惠活动中认识到这家注册商的,于是今天早上花了点时间专门了解了NameSilo优惠码和商家的详细信息。该商家只销售域名,他们家的域名销售价格还是中规中矩的,没有像godaddy域名标价和使用优惠之后的价格悬殊很大,而且其特色就是该域名平台提供免费的域名停放、免费隐私保护等功能。namesilo新注册域名价格列表,NameSilo官方网站:www.namesilo....
999ddd.com为你推荐
johncusack有喜欢演员JOHN CUSACK的吗?从哪部片子开始喜欢他的?至今为止他主要参与的电影作品有哪些?www.hao360.cn搜狗360导航网址是什么百花百游百花蛇草的作用百花百游百花净斑方多少钱一盒钟神发跪求钟神发名言出处,A站大神看过来777k7.comwww.777tk.com.怎么打不 开www.zjs.com.cn怎么查询我的平安信用卡寄送情况javbibitreebibi是什么牌子的杨丽晓博客明星的最新博文www.bbb551.com广州欢乐在线551要收费吗?
域名交易 什么是二级域名 net主机 私人服务器 gateone css样式大全 镇江联通宽带 什么是刀片服务器 服务器维护方案 国外免费asp空间 网通服务器托管 银盘服务是什么 免费邮件服务器 视频服务器是什么 免费asp空间 东莞服务器托管 数据库空间 畅行云 阿里云手机官网 买空间网 更多