Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline
Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly

Create PDF Files on ASP Web Sites

Posted May 3, 2004

AspPDF 1.0 is an ActiveX component that lets you read, create, and modify Portable Document Format (PDF) files on the fly and send the resulting file to an HTTP stream for a browser or to a directory for storage (see Figure 1). The control is licensed on a per-server basis for rapid generation of PDFs on ASP Web sites, but it should work in any application that supports COM. Note that this product generates PDFs using existing PDF files and/or computer code; it doesn't convert Word documents or PostScript files to PDF.

Consider a manual installation of AspPDF on your production server, because the setup routine creates an unwanted IIS virtual directory and prompts for a Web server restart after registering the COM component. You'll probably need to adjust file permissions or create your own web.config file to run the samples on your localhost. The license agreement shouts that you can only "use this product ON A SINGLE MACHINE," but, according to Persits support, the license actually allows use on two machines—one for development and one for production.

ADVERTISEMENT

The AspPDF object model is well-defined and easy to manipulate. You use the top-level PdfManager object to create other objects such as a document, page, canvas, font, or parameter. Building a complicated PDF exclusively in code is a labor- and code-intensive process: You must retrieve text to insert into cells, add the cells to tables, put the tables into the page, then assemble pages into a document. You can create documents speedily by starting with a PDF page such as a form with blank areas. Use AspPDF's OpenDocument method to get a copy of the form page to use as a template. Then, you can fill in the blank areas with data from a data source or user input.

The hard part is "painting" the data to the exact coordinates on the page. A nice add-on would be a design-time tool that displays a static PDF and stores the coordinates as you visually pinpoint locations to insert data. If you have the full Adobe Acrobat product, it's far easier to assign data-input fields in the template PDF and reference them by name with AspPDF.

Generation of the resulting PDF is fast, whether you build the entire document in code or merge data with an existing PDF. You can write it to a temporary file for download through a hyperlink or push the document out on an HTTP stream. AspPDF supports the security features of the latest PDF releases, including passwords and encryption.

The online documentation for AspPDF is a series of HTML pages with adequate, realistic examples in VBScript and C#, but not VB.NET. HTML Help would be a preferable format because it provides search and index functions. Although the COM-based AspPDF works well for classic ASP sites as well as ASP.NET, a managed-code version for pure .NET applications would be a welcome addition.

AspPDF 1.0
Persits Software
Web:
www.asp-pdf.com
Phone: 800-268-0689; 212-785-1611
Price: $299 for a single-server license
Quick Facts: COM component that reads, generates, and outputs PDF files to an HTTP stream or physical directory using ASP or ASP.NET.
Pros: Creates database-driven PDFs quickly; good samples; supports latest encryption and security standards.
Cons: Building PDFs in code can be labor-intensive; uses older COM technology; documentation doesn't cover VB.NET.

About the Author
Ken Cox is a technical writer and VB.NET developer in Toronto building e-commerce Web applications and XML Web services. Ken is a Microsoft MVP for ASP.NET and a former broadcast journalist. Reach him at .




Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home