• No results found

Client-Server Creation of Complex PDF Documents

N/A
N/A
Protected

Academic year: 2021

Share "Client-Server Creation of Complex PDF Documents"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

Client-Server Creation of

Complex PDF Documents

Gregory Milman

National Institute of Allergy and

Infectious Diseases

[email protected]

(2)

Reasons to Choose PDF

Format Over HTML

„ Incremental change from paper forms „ Multi-platform; consistent printout „ Free Acrobat Reader in browser „ WYSIWYG – nothing to learn

„ Client-side format, validation and calculations „ Server-side upload/download forms and data „ Free Adobe FDFtoolkit for Server functions „ Can merge form and non-form PDF pages

Complex Documents May

Contain:

„

Forms with multiple pages

„

Multiple forms attached together

„

Forms flattened to non-form PDF format

„

Uploaded client PDF documents

„

Uploaded client files in non-PDF format

that are converted into PDF by server

Tools Used to Construct a

Complex Document

„ Form Tools Complete a PDF Form „ PDF Document Tools „ Combine or Extract PDF Documents Tools „ Validate Document Tools

Client Word Processor Pages Form Pages

Complex Document

Our Server-Side Process

„ Microsoft NT Server running https and using

Active Server Pages with VB Script

„ Free software

„ FDFToolkit (www.adobe.com)

„ AspSmartUpload (www.aspsmart.com)

„ Purchased software

„ Acrobat (www.adobe.com)

„ ActivePDF Professional (www.activepdf.com) „ Sequel Server (www.microsoft.com/ms.htm)

(3)

AspSmartUpload

Used to Transfer Files

Server Client Word Processor Files PDF Files PDF Forms FilesPDF FDF Files

Complementary Client-Server

PDF Form Tools

Server Client PDF Form File GetFormFieldData SetFormFieldData Submit FDF Data Rec eive FDF Data PDF Form File PDF Flat File FDF Toolkit

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 – ActivePDF Toolkit

„ SmartUpload – AspSmartUpload

„ DocConverter – ActivePDF Document Converter

Examples:

Some Acrobat Forms Objects

„ Field Object

„ Properties: name, value, type, etc. „ Methods: getArray, deleteItemAt, etc.

„ Document Object

„ Properties: numPages, pageNum, title, etc.

„ Methods: exportAsFDF, getField, submitForm, etc.

„ Event Object

„ Properties: target, name, value, etc.

(4)

Tools Used to Construct a

Complex Document

„ Form Tools Complete a PDF Form „ PDF Document Tools „ Combine or Extract PDF Documents Tools „ Validate Document Tools

Client Word Processor Pages Form Pages

Complex Document

Sample

Forms Tools Page

Start a PDF Form

Server Client D a t a PDF Form File PDF Flat File Select „ Client selects a form.

„ Client enters data in

form.

„ Client saves data to

server.

„ Server creates flat

file.

„ Server sends form

to client.

Save and Retrieve Data on

Server

„ Field entries are transmitted back and forth

between server and client as Form Data File (FDF)

„ FDF files contain only data

„ small size

„ rapid transmission

„ Information on PDF form (e.g., version) can

be transmitted as read-only form field.

„ Server can automatically transmit changed

(5)

ASP Script Snippet

Send Client Selected Form

Set FdfAcX=

Server.CreateObject("FdfApp.FdfApp")

REM Send blank form

Set outFDF = FdfAcX.FDFCreate FDFSetFile=PDFFormFileName Response.ContentType="application/vnd.fdf" Response.BinaryWrite outFDF.FDFSaveToBuf outFDF.FDFClose

Edit a PDF Form

Server Client FDF D ata PDF Form File PDF Flat File Select

„ Client selects form

data.

„ Client edits data. „ Client saves FDF

data to server.

„ Server creates flat

file.

„ Server sends FDF.

FDF D

ata

„ FDF requests and

populates form from Server.

ASP Script Snippet

Send Client Selected Form

Set FdfAcX=

Server.CreateObject("FdfApp.FdfApp")

REM Send FDF data that calls form

Set outFDF = FdfAcX.FDFOpenFromFile (FDFFileName)

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 PDF forms in cache.

„ If Client 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

(6)

Edit a PDF Form

Low Bandwidth Option

Server Client FDF D ata PDF Form File PDF Flat File Select

„ Client selects form

data.

„ Client edits data. „ Client saves FDF

data to server.

„ Server creates flat

file.

„ Server sends FDF.

FDF D

ata

„ FDF requests and

populates form from Client.

Creating FDF File to Access

Form on Client

„ Client must

„ Save form on client machine (use AspSmartUpload). „ Provide full path and file name of form to server.

„ Server script example

Set FdfAcX= Server.CreateObject("FdfApp.FdfApp") Set outFDF = FdfAcX.FDFOpenFromFile (FDFFileName) outFDF.FDFSetFile “file:/// c:\\forms\\PDFform.pdf”

Response.ContentType="application/vnd.fdf" Response.BinaryWrite outFDF.FDFSaveToBuf outFDF.FDFClose

Client Saves to Server

Server Modifies Form

Server Client FDF D ata PDF Form File

„ Client initiates save

to server.

FDF D

ata

„ JavaScript in Form

selects and sends field values in FDF.

„ Server creates and

returns new FDF to modify form.

„ Multiple iterations

possible.

JavaScript in Form

Sends Fields to Server

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 } }

(7)

ASP Script Snippet

Get Client Data

Set FdfAcX= Server.CreateObject("FdfApp.FdfApp") Set inFDF = FdfAcx.FDFOpenFromBuf

(Request.BinaryRead(Request.TotalBytes)) inFDF.FDFSaveToFile(FDFFileName)

inFDF.FDFClose

REM Return a new field value to form

Set outFDF = FdfAcX.FDFCreate

outFDF.FDFSetValue “FormFieldName",NewValue,False Response.ContentType="application/vnd.fdf"

Response.BinaryWrite outFDF.FDFSaveToBuf outFDF.FDFClose

Client Saves to Server

Server Modifies Form

Server Client FDF D ata PDF Form File

„ Client initiates save

to server.

FDF D

ata

„ JavaScript in Form

selects and sends field values in FDF.

„ Server creates and

returns new FDF to modify form. „ Multiple iterations possible. FDF D ata FDF D ata

Example:

Scripts for Multiple Interations

Form Validate JavaScript*

Box1: “desired action” Box2: submitForm

(“Box.asp#FDF",true,true, "Box1")

* Validate action occurs only when value of field changes.

Server 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 Box1 (text) Box2 (text)

Creating PDF “Flat File” from

PDF Form

„

Use ActivePDF Toolkit to place FDF File

data in PDF image layer.

„

Resulting PDF “Flat File”

„ Can be saved to client computer, „ But cannot be edited.

„

Use modified template for flat file.

„

Resulting flat file is ½ size

of form file.

(8)

Modify Template for Flat File

to Achieve Minimum File Size

„

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.

Creating PDF “Flat File” from

PDF Form

Server Client SetFormFieldData PDF Template File PDF Flat File FDF D ata

„ Client form sends FDF data

to server that contains no empty or “default value” fields.

„ Server uses FDF toolkit to

step through and obtain FDF fields values.

„ Server uses ActivePDF

toolkit to writes values to same field names in template, and to flatten remaining fields.

How to Store the FDF Data in

the Flat File

Multiple Fields Leave one hidden field in flat file and use to store FDF data

FormData

Flatten

ASP Script Snippet

Open Toolkits

Set FdfAcX= Server.CreateObject("FdfApp.FdfApp") Set inFDF = FdfAcx.FDFOpenFromBuf

(Request.BinaryRead(Request.TotalBytes)) Set APT = Server.CreateObject("APToolkit.Object") r = APT.OpenOutputFile(OutputFileName)

r = APT.OpenInputFile(TemplateFileName) strFieldName = ""

(9)

ASP Script Snippet

Flatten PDF Field and Close

Do

strFieldName = inFDF.FDFNextFieldName(CurrentField) If strFieldName = "" then exit DO

FieldValue = inFDF.FDFGetValue(strFieldName) APT.SetFormFieldData strFieldName,FieldValue,-997 CurrentFieldName = strFieldName

Loop

APT.SetFormFieldData "FormData", inFDF.FDFSaveToStr, 0

APT.FlattenRemainingFormFields = true x = APT.CopyForm(0,0)

APT.CloseInputFile() APT.CloseOutputFile()

Sample

PDF Document Tools Page

PDF Document Tools

„ Client uploads word

processor document which Server converts to PDF.

„ Client uploads PDF

document for merge.

„ Client views PDF documents on Server. Client Server Narrative WP Format Narrative PDF Format Client PDF File Client PDF File

Word Processor to PDF

„

Use AspSmartUpload to upload files.

„

Use ActivePDF DocConverter on server

to convert uploaded files to PDF.

„ Currently support Word (with active links)

and WordPerfect.

„ Expect to include hundreds of other file

(10)

ASP Script Snippet

Smart Upload

Response.Buffer = true server.ScriptTimeout = 180 Set SmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload") SmartUpload.AllowedFilesList = "doc,txt,wpd" SmartUpload.Upload

For eachfile In UFile.Files file.SaveAs(FileName) intCount = intCount + 1 Next

Set SmartUpload = nothing

ASP Script Snippet

Convert Document to PDF

Set DocConverter = Server.CreateObject("APdocConv.Object") lRet = DocConverter.Submit (IPAddress,ServerPort,FileToConvert, OutputDirectory,ErrorsDirectory, OrigDirectory,ScriptName,ScriptLang, SuportsZip,ProcessorOptions)

Rem Add script to catch errors Set DocConverter = nothing

Sample

Merge Documents Page

Combine or Extract PDF

Documents Tools

„ Client selects and

orders PDF documents.

„ Server merges

documents into new PDF file.

„ Client selects pages

from PDF document.

„ Server extracts pages

into a new file.

Server Flat PDF File Client WP File in PDF Format Client PDF Files Merged or Extracted Pages Select Client

(11)

Merge and Extract PDF Pages

„

Use ActivePDF Toolkit to complete

document by merging

„ “flat file” copy of form pages with

„ PDF pages from uploaded word processor

document and

„ Other uploaded PDF pages

ASP Script Snippet

Merge PDF Files

set PDF = Server.CreateObject("APToolkit.Object") PDF.AddBookmarks = false

PDF.FormNumbering = 1

r = PDF.OpenOutputFile(sMergedFilePath)

REM For each file to merge…

r = PDF.MergeFile(sPdfFile,Request.Form(sPageFrom), Request.Form(sPageTo))

PDF.CloseOutputFile() set PDF = Nothing

Some Closing Remarks

Simple and Complex Forms

Simple Form

„ On-Line completion „ Single page and few

fields (<50)

„ Simple calculations with

“built-in” Adobe functions

„ Form usually accessed

on server

Complex Form

„ Off-Line completion „ Multiple pages and

many fields (>200)

„ Calculations require

JavaScript as “Validate” function

„ Form may be stored on

client with slow speed connection

References

Related documents

There are, however candidates for further Cretan endemic Gelechiidae, partly among the species only identified to genus, and partly among species identified on the basis

Thus, considering the construct multidimensionality of syntactic complexity (Norris &amp; Ortega, 2009), and the critical role of phrasal complexity features (e.g., noun phrases)

Batch Scan (Continuous scanning (Continuous scanning ) ) Saving scanned data as PDF files. Saving scanned data as PDF files Saving scanned data as

In the present study NBS-profiling approach was applied in pepper populations segregating for 3 different L alleles (L1, L3, L4) of Tobamovirus-resistance, with the aim of

Bilezikian, Gilbert. GrandRapids: Zondervan, 1997. This book discusses principles that became foundations for the community of the Willow Creek Community Church, and it emphasizes

José Eber is a UK based company taking hair products to the next level by introducing the new and improved collection of hair quality tools.. Our business mission is hair styling

The 3-Heights™ Scan to PDF Server is a central service that converts locally scanned files and associated index files into the standardized PDF/A file format within a company.. To

If you have chosen Listed Events Home Insurance, we will cover your buildings or contents for loss or damage as a result of the incidents listed on pages 11 to 16.. If you make