设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 站长学院 > Asp教程 > 正文

用asp生成PDF文件(英文)

发布时间:2020-12-25 08:43 所属栏目:120 来源:网络整理
导读:Creating a PDF with ASP By Ty Button Introduction Adobe''s PDF format has become the lingua franca of cross-platform reporting for many agencies and companies. While I was no great fan of the product,I have to admit it probably does a bett

Creating a PDF with ASP

By Ty Button

Introduction
Adobe''s PDF format has become the lingua franca of cross-platform reporting for many agencies and companies. While I was no great fan of the product,I have to admit it probably does a better job of producing a compact document with loads of formatting than Word ever will.?
Getting Started
Working for a staffing firm,I have written all of our front-end software to run over the Internet so we can share common databases with our smaller branch offices. The biggest problem we faced,however,was reporting. How do we get live documents (applications,etc.) to generate themselves when an applicant sits down at the kiosk and fills out their on-line employment application? While we''re doing a great job of capturing the data,we still need an applicant to sign the application,W-4,etc.
I tried a number of things,but the limits seem to be:

If I could produce it fast,it was an HTML form derivative and looked terrible when printed.
If I could produce it looking right,it was clunky and slow. This is because I settled on RTF as my best initial option and ended up using the File System Object to write RTF files based on a template and parse my info into them. The disk reads and writes took their toll.
Remember,we抮e not talking about tabular data or an Excel spreadsheet. We want the application with our logo to be processed.

Finally,I settled on Adobe. I hate the viewer and wish I didn''t have to mess with it. However,the formatting looks good and the files are thin. Most users have it on their system,and all my users do.

So I searched and searched for ways to pass data from HTML forms to PDF files. I tried using Adobe forms,but didn''t really like working with the validation,etc.,and then would still have to figure out how to incorporate the database calls. This wasn''t at all what I wanted. I wanted to pass data directly from my HTML form to a database while generating the field data into the PDF file for display or printing.

Finally,there was a clue on UseNet. A link posted by Jeremy Hunter contained much of what I will address here. http://partners.adobe.com/asn/developer/acrosdk/forms.html

REQUIRED SOFTWARE
ADOBE (the full version) is required on the workstation defining the fields. (Not the server)

This is the link to the Adobe Forms Acrobat Toolkit. From there it was easy going.

Step 1. Download the toolkit and unzip it to your directory of choice.

When you do,you''ll find that all the source code is included in VB and C++. We''re not going to worry about that here,but the code is there if you need it.

Step 2. Register your dlls.

Two dlls need to be copied to your server. The first is in the Visual Basic sub folder and is named fdfacx.dll. The second is in the Visual C subfolder and is named fdftk.dll. Run refsvr32 on the fdfacx.dll file. It will take care of registering the other itself. I put both in c:winntsystem32 and from that directory typed regsvr32 fdftk.dll. If you get an error message,check to make sure both files are really there. If not,we''re set to go.

Step 3. Create the form.

We''ll use a form everyone is too familiar with for this demonstration - the W-4. This one is readily available on http://www.irs.gov and gives us enough fields to show what we can do.


<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<H1>Adobe FDF Example</H1>
<FORM NAME=W4Help ACTION=W4.asp METHOD = POST>
<TABLE>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>First Name</TD>
??<TD><INPUT TYPE=TEXT NAME=txtFirstName>
??</TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Middle Initial
??</TD>
??<TD><INPUT TYPE=TEXT NAME=txtMI>
??</TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>LastName</TD>
??<TD><INPUT TYPE=TEXT NAME=txtLastName>
</TD>
?</TR>
??<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Social</TD>
??<TD><INPUT TYPE=TEXT NAME=txtSocial1 SIZE=3>-
<INPUT TYPE=TEXT NAME=txtSocial2 SIZE=2>-
<INPUT TYPE=TEXT NAME=txtSocial3 SIZE=2></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Street Address</TD>
??<TD><INPUT TYPE=TEXT NAME=txtStreetAddress></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>City
??</TD>
??<TD><INPUT TYPE=TEXT NAME=txtCity></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>State</TD>
??<TD><INPUT TYPE=TEXT NAME=txtState SIZE=2 MAXLENGTH=2></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Zip</TD>
??<TD><INPUT TYPE=TEXT NAME=txtZip SIZE=10></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Filing Status</TD>
??<TD>
??<INPUT TYPE=RADIO NAME=radFilingStatus VALUE="1">Single
??<BR>
??<INPUT TYPE=RADIO NAME=radFilingStatus VALUE="2">Married
??<BR>
??<INPUT TYPE=RADIO NAME=radFilingStatus VALUE="3">
??Married but withholding at the higher single rate.
??<BR></TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Allowances Claimed</TD>
??<TD><INPUT TYPE=TEXT NAME=txtAllowances SIZE=2 MAXLENGTH=2>?</TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>Additional amount to withhold (if any)</TD>
??<TD><INPUT TYPE=TEXT NAME=txtAdditional SIZE=2 MAXLENGTH=2>
??</TD>
?</TR>
?<TR>
??<TD ALIGN=RIGHT VALIGN=TOP>I want to file Exempt from Withholding
??</TD>
??<TD><INPUT TYPE=CHECKBOX NAME=chkExempt></TD>
?</TR>
</TABLE>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>


Step 4. Define the Adobe form fields.

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读