第四、定义Adobe表单字段。
在Adobe Acrobat中打开文档后选择表单工具,描述你的第一个表单字段(First Name)。
在你定义后它将让你命名,我这里命名为“FirstName”。注意这里有几个标准的附加格式选项,除了字体大小,我选择进行合法性检查和格式化我的ASP文档。由于这是一个快速演示,我选择跳过任何检查,但是我将在客户端的表单进行处理,并在传递变量前在服务端格式化ASP页面。
继续其他字段,每一个都要注意命名并可能格式化字体大小或属性。
在服务器上保存你的修改。
第五、编写ASP页面。
在开始这一步之前你要注意到FDF套装工具阐述的一个主要对象——“FDFApp.FDFApp”。它开放了许多方法,手册上概述了其他的可能方法。我们主要关心两个方法——fdfSetValue和fdfSetFile。接下来切入正题。
<%@ Language=VBScript %> <% Response.Buffer = true%> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <% ' ' Retrieve the user responses ' FirstName = Request.form("txtFirstName") MI = Request.form("txtMI") LastName = Request.form("txtLastName") SS1 = Request.form("txtSocial1") SS2 = Request.form("txtSocial2") SS3 = Request.form("txtSocial3") StreetAddress = Request.form("txtStreetAddress") City = Request.form("txtCity") State = Request.form("txtState") Zip = Request.form("txtZip") FilingStatus = Request.form("radFilingStatus") Allowances = Request.form("txtAllowances") Additional = Request.form("txtAdditional") Exempt = Request.form("chkExempt") If Exempt = "on" Then Exempt = "EXEMPT" Else Exempt = "" End If ' ' Create an instance of the Object ' Set FdfAcx = Server.CreateObject("FdfApp.FdfApp") ' ' Use the fdfApp to feed the vars ' Set myFdf = FdfAcx.FDFCreate ' ' Stuff the variables ' myFdf.fdfsetvalue "FirstName", FirstName, false myFdf.fdfsetvalue "MI", MI, false myFdf.fdfsetvalue "LastName", LastName, false myFdf.fdfsetvalue "SS1", SS1, false myFdf.fdfsetvalue "SS2", SS2, false myFdf.fdfsetvalue "SS3", SS3, false myFdf.fdfsetvalue "StreetAddress", StreetAddress, false myFdf.fdfsetvalue "City", City, false myFdf.fdfsetvalue "State", State, false myFdf.fdfsetvalue "Zip", Zip, false If FilingStatus = 1 Then MyFdf.fdfsetValue "StatusSingle", "X", false End If If FilingStatus = 2 Then MyFdf.fdfsetValue "StatusMarried", "X", false End If If FilingStatus = 3 Then MyFdf.fdfsetValue "MarriedBut", "X", false End If myFdf.fdfsetvalue "Allowances", Allowances, false myFdf.fdfsetvalue "Additional", Additional, false myFdf.fdfsetvalue "Exempt", Exempt, false ' ' Point to your pdf file ' myFDF.fdfSetFile "http://www.servername.com/workorder/w4.pdf" Response.ContentType = "text/html" ' ' Save it to a file. If you were going to save the actual file past the point of printing ' You would want to create a naming convention (perhaps using social in the name) ' Have to use the physical path so you may need to incorporate Server.mapPath in ' on this portion. ' myFDf.FDFSaveToFile "C:\inetpub\wwwroot\workorder\CheckThis.fdf" ' Now put a link to the file on your page. Response.Write "<a href=http://www.servername.com/workorder/CheckThis.fdf>pdf</A>" ' ' Close your Objects ' myfdf.fdfclose set fdfacx = nothing %>
第六、没有必要成为PDF专家,这是我目前的建议。套装工具的用户指导概述了所有方法,看上去在这个入门介绍之外还有很多可能的方法。就像你所看到的一样,你可以很容易添加数据库命令来收集数据或向数据库记录数据。
|