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.
hostkey应该不用说大家都是比较熟悉的荷兰服务器品牌商家,主打荷兰、俄罗斯机房的独立服务器,包括常规服务器、AMD和Intel I9高频服务器、GPU服务器、高防服务器;当然,美国服务器也有,在纽约机房!官方网站:https://hostkey.com/gpu-dedicated-servers/比特币、信用卡、PayPal、支付宝、webmoney都可以付款!CPU类型AMD Ryzen9 ...
LOCVPS发来了针对元旦新年的促销活动,除了全场VPS主机8折优惠外,针对德国/荷兰KVM #1/美国KVM#2 VPS提供终身7折优惠码(限量50名,先到先得)。LOCVPS是一家成立于2012年的国人VPS服务商,提供中国香港、韩国、美国、日本、新加坡、德国、荷兰、俄罗斯等地区VPS服务器,基于KVM或XEN架构(推荐优先选择KVM),均选择直连或者优化线路,国内延迟低,适合建站或远程办公使...
CloudCone 商家产品还是比较有特点的,支持随时的删除机器按时间计费模式,类似什么熟悉的Vultr、Linode、DO等服务商,但是也有不足之处就在于机房太少。商家的活动也是经常有的,比如这次中国春节期间商家也是有提供活动,比如有限定指定时间段之前注册的用户可以享受年付优惠VPS主机,比如年付13.5美元。1、CloudCone新年礼物限定款仅限2019年注册优惠购买,活动开始时间:1月31...
999ddd.com为你推荐
金评媒朱江喜剧明星“朱江”的父亲叫什么?特朗普取消访问丹麦特朗普访华后还会去那里?www.hao360.cn主页设置为http://hao.360.cn/,但打开360浏览器先显示www.yes125.com后转换为www.2345.com,搜索注册表和比肩工场命比肩多 是什么意思啊?同一服务器网站同一服务器上的域名/网址无法访问sss17.com为什么GAO17.COM网站打不开了www.119mm.comwww.993mm+com精品集!5xoy.comhttp://www.5yau.com (舞与伦比),以前是这个地址,后来更新了,很长时间没玩了,谁知道现在的地址? 谢谢,www.22zizi.com乐乐电影天堂 http://www.leleooo.com 这个网站怎么样?16668.com香港最快开奖现场直播今晚开
网站空间商 高防服务器租用 域名服务dns的主要功能为 ipage idc评测 ix主机 抢票工具 windows2003iso 申请个人网页 三拼域名 有奖调查 789电视网 重庆双线服务器托管 hktv 服务器监测 购买国外空间 支持外链的相册 闪讯官网 中国linux 日本代理ip 更多