- Creation of Complex Documents Gregory Milman National Institute of Allergy and Infectious Diseases gmilman@niaid.nih.gov http(s)://grants.niaid.nih.gov
Reasons to Choose at Over HTML Incremental change from paper forms Multi-platform; consistent printout Free Acrobat Reader in browser WYSIWYG nothing to learn -side format, validation and calculations -side upload/download forms and data Free Adobe FDFtoolkit for functions Can merge form and non-form pages Complex Documents May Contain: s with multiple pages Multiple forms attached together s flattened to non-form format Uploaded client documents Uploaded client files in non- format that are converted into by server Tools Used to Construct a Complex Document Our -Side Process Complex Document Pages Tools Complete a Document Tools Combine or Extract Documents Tools Validate Document Tools Microsoft NT running https and using Active Pages with VB Script Free software FDFToolkit (www.adobe.com) AspSmartUpload (www.aspsmart.com) Purchased software Acrobat (www.adobe.com) Active Professional (www.activepdf.com) Sequel (www.microsoft.com/ms.htm) Word Processor Pages
AspSmartUpload Used to Transfer s Complementary - Tools FDF Toolkit FDF s s s s Word Processor s Flat GetFieldData Receive Submit SetFieldData Short Notes on Object Programming An object has: Properties characteristics of object Methods enables object to do something Other objects components Objects created and used by our server FdfAcx FDF ActiveX Toolkit APT Active Toolkit SmartUpload AspSmartUpload DocConverter Active Document Converter Examples: Some Acrobat s Objects Field Object Properties: name, value, type, etc. Methods: getarray, deleteitemat, etc. Document Object Properties: numpages, pagenum, title, etc. Methods: exportasfdf, getfield, submit, etc. Event Object Properties: target, name, value, etc. Methods: format, validate, mouse exit, etc.
Tools Used to Construct a Complex Document Sample s Tools Page Complex Document Pages Tools Complete a Document Tools Combine or Extract Documents Tools Validate Document Tools Word Processor Pages Start a Save and Retrieve Data on Flat Select D a t a selects a form. sends form to client. enters data in form. saves data to server. creates flat file. Field entries are transmitted back and forth between server and client as Data (FDF) FDF files contain only data small size rapid transmission Information on form (e.g., version) can be transmitted as read-only form field. can automatically transmit changed forms to client.
ASP Script Snippet Send Selected Edit a Set FdfAcX=.CreateObject("FdfApp.FdfApp") REM Send blank form Set outfdf = FdfAcX.FDFCreate FDFSet=Name Response.ContentType="application/vnd.fdf" Response.BinaryWrite outfdf.fdfsavetobuf outfdf.fdfclose Flat Select selects form data. sends FDF. FDF requests and populates form from. edits data. saves FDF data to server. creates flat file. ASP Script Snippet Send Selected Set FdfAcX=.CreateObject("FdfApp.FdfApp") REM Send FDF data that calls form Set outfdf = FdfAcX.FDFOpenFrom (FDFName) Response.ContentType="application/vnd.fdf" Response.BinaryWrite outfdf.fdfsavetobuf outfdf.fdfclose Access Issues with Low Bandwith Connections Acrobat (version 4.05 and lower) stores FDF files but not forms in cache. If jumps to link outside form, then on return the form must reload from server. Cache FDF data will populate the form. Complex forms (1MB) will take 5-15 minutes to load at low bandwith (28K) Waiting this long for a form to load is usually unacceptable.
Edit a Low Bandwidth Option Creating FDF to Access on Flat Select selects form data. sends FDF. FDF requests and populates form from. edits data. saves FDF data to server. creates flat file. must Save form on client machine (use AspSmartUpload). Provide full path and file name of form to server. script example Set FdfAcX=.CreateObject("FdfApp.FdfApp") Set outfdf = FdfAcX.FDFOpenFrom (FDFName) outfdf.fdfset file:/// c:\\forms\\form.pdf Response.ContentType="application/vnd.fdf" Response.BinaryWrite outfdf.fdfsavetobuf outfdf.fdfclose Saves to Modifies initiates save to server. JavaScript in selects and sends field values in FDF. creates and returns new FDF to modify form. Multiple iterations possible. JavaScript in Sends Fields to var FieldsToSend= new Array() var F for (i=1; i<numfields; i++) { F=getField(getNthFieldName(i)) if (F.value!=F.defaultValue) { FieldsToSend[n]= F.name n=n+1 } } submit ("Script.asp#FDF",true,false,FieldsToSend)
ASP Script Snippet Get Data Set FdfAcX=.CreateObject("FdfApp.FdfApp") Set infdf = FdfAcx.FDFOpenFromBuf (Request.BinaryRead(Request.TotalBytes)) infdf.fdfsaveto(fdfname) infdf.fdfclose REM Return a new field value to form Set outfdf = FdfAcX.FDFCreate outfdf.fdfsetvalue FieldName",NewValue,False Response.ContentType="application/vnd.fdf" Response.BinaryWrite outfdf.fdfsavetobuf outfdf.fdfclose Saves to Modifies initiates save to server. JavaScript in selects and sends field values in FDF. creates and returns new FDF to modify form. Multiple iterations possible. Example: Scripts for Multiple Interations Creating Flat from Box1 (text) Box2 (text) Validate JavaScript* Box1: desired action Box2: submit ( Box.asp#FDF",true,true, "Box1") * Validate action occurs only when value of field changes. Script Box.asp#FDF sboxvalue = infdf.fdfgetvalue("box1") if sboxvalue = "1" then infdf.fdfsetvalue "Box1","0",false else infdf.fdfsetvalue "Box1","1",false end if Use Active Toolkit to place FDF data in image layer. Resulting Flat Can be saved to client computer, But cannot be edited. Use modified template for flat file. Resulting flat file is ½ size of form file.
Modify Template for Flat to Achieve Minimum Size Creating Flat from Delete global and field JavaScript. Adjust field colors (white). Replace combo and drop boxes with text fields. Use FDF data that does not contain empty or default value fields. Flat Template SetFieldData form sends FDF data to server that contains no empty or default value fields. uses FDF toolkit to step through and obtain FDF fields values. uses Active toolkit to writes values to same field names in template, and to flatten remaining fields. How to Store the in the Flat ASP Script Snippet Open Toolkits Multiple Fields Flatten Leave one hidden field in flat file and use to store FDF data Data Set FdfAcX=.CreateObject("FdfApp.FdfApp") Set infdf = FdfAcx.FDFOpenFromBuf (Request.BinaryRead(Request.TotalBytes)) Set APT =.CreateObject("APToolkit.Object") r = APT.OpenOutput(OutputName) r = APT.OpenInput(TemplateName) strfieldname = "" CurrentField = ""
ASP Script Snippet Flatten Field and Close Sample Document Tools Page Do strfieldname = infdf.fdfnextfieldname(currentfield) If strfieldname = "" then exit DO FieldValue = infdf.fdfgetvalue(strfieldname) APT.SetFieldData strfieldname,fieldvalue,-997 CurrentFieldName = strfieldname Loop APT.SetFieldData "Data", infdf.fdfsavetostr, 0 APT.FlattenRemainingFields = true x = APT.Copy(0,0) APT.CloseInput() APT.CloseOutput() Document Tools Word Processor to Narrative at Narrative WP at uploads word processor document which converts to. uploads document for merge. views documents on. Use AspSmartUpload to upload files. Use Active DocConverter on server to convert uploaded files to. Currently support Word (with active links) and WordPerfect. Expect to include hundreds of other file types.
ASP Script Snippet Smart Upload Response.Buffer = true server.scripttimeout = 180 Set SmartUpload =.CreateObject("aspSmartUpload.SmartUpload") SmartUpload.AllowedsList = "doc,txt,wpd" SmartUpload.Upload For each file In U.s file.saveas(name) intcount = intcount + 1 Next Set SmartUpload = nothing ASP Script Snippet Convert Document to Set DocConverter =.CreateObject("APdocConv.Object") lret = DocConverter.Submit (IPAddress,Port,ToConvert, OutputDirectory,ErrorsDirectory, OrigDirectory,ScriptName,ScriptLang, SuportsZip,ProcessorOptions) Rem Add script to catch errors Set DocConverter = nothing Sample Merge Documents Page Merged or Extracted Pages Combine or Extract Documents Tools Select Flat s WP in at selects and orders documents. merges documents into new file. selects pages from document. extracts pages into a new file.
Merge and Extract Pages Use Active Toolkit to complete document by merging flat file copy of form pages with pages from uploaded word processor document and Other uploaded pages ASP Script Snippet Merge s set =.CreateObject("APToolkit.Object").AddBookmarks = false.numbering = 1 r =.OpenOutput(sMergedPath) REM For each file to merge r =.Merge(sPdf,Request.(sPageFrom), Request.(sPageTo)).CloseOutput() set = Nothing Some Closing Remarks Simple and Complex s Simple On-Line completion Single page and few fields (<50) Simple calculations with built-in Adobe functions usually accessed on server Complex Off-Line completion Multiple pages and many fields (>200) Calculations require JavaScript as Validate function may be stored on client with slow speed connection