Generate a PDF file with ASP

zhaozj2021-02-17  38

Creating a pdf with ask the aspby type

Print this Article

Email this Article to a colleague

IntroductionAdobe'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 StartedWorking 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 Zhen 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. Hove, the formatting looks good and the files are thir 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 did not really like working with the validation, etc., and then would still have to figure out how to incorporate the database Calls. This isn'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.FinalLinally, There Was A Clue on UseNet. a Link Posted by Jeremy Hunter Contained Much of What Will Address Here. http://partners.adobe.com/aSn/developer/acroSDK /FORMS.HTML

Required SoftwareAdobe (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....

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 include in vb and c . We're not going to worry about here, but the code is there. 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:.. / winnt / system32 / 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 eveningone is to familiar with for this demonstration - The W-4. This One is ready, on http://www.irs.gov and gives us enough Fields to show what we can do.

<% @Language = VBScript%>

Adobe FDF EXAMPLE
first name
Middle Initial
Lastname
Social - -
Street Address
city
State
Zip

Right Valign = TOP> Filing Status

Single
married
Married But Useholding at The Higher Single Rate.
ALLOWANCES CLAIMED
Additional Amount To withhold (if any)
I want to file exempt from withholding Step 4. Define The Adobe Form Fields.

Open the document in Adobe Acrobat. Click the form tool. Paint your first form field (First Name). As soon as you've defined it you are asked to name it. I named mine FirstName. Note that there are several additional formatting options . Other than font size, I choose to do my validation and formatting in my ASP document. As this is just a quick demo, I have opted to skip any validation. However, I would handle it on the client side in my form and any formatting server side in my ASP page before I pass the variables. Continue with the remaining fields, naming each and possibly formatting the font size or attributes. Save your work to wherever you want on your Web server. Step 5. Write the ASP page. Before you start, realize that there is one main object exposed by the FDF toolkit - ". FDFApp.FDFApp" there are many methods exposed, and the manual outlines some other possibilities We're mainly concerned with two methods, fdfSetValue and fdfSetFile.. Here We Go,

<% @Language = VBScript%> <% response.buffer = true%>

1 Then MyFdf.fdfsetValue "StatusSingle", "X", falseEnd IfIf FilingStatus = 2 Then MyFdf.fdfsetValue "StatusMarried", "X", falseEnd IfIf FilingStatus = 3 Then MyFdf.fdfsetValue "MarriedBut", "X", falseEnd IfmyFdf. fdfsetvalue "Allowances", Allowances, falsemyFdf.fdfsetvalue "Additional", Additional, falsemyFdf.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 " PDF " '' close Your Objects'myfdf.fdfclosset fdfacx = Nothing%>

转载请注明原文地址:https://www.9cbs.com/read-29900.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.051, SQL: 9