AspPDF is an ActiveX server component for dynamically creating, reading and modifying Portable Document Format (PDF) files.
| <% 'ASP example |
| |
| Set Pdf = Server.CreateObject("Persits.Pdf") |
| Set Doc = Pdf.CreateDocument |
| Doc.Title = "AspPDF Chapter 3 Hello World Sample" |
| Doc.Creator = "John Smith" |
| |
| Set Page = Doc.Pages.Add |
| |
| Set Font = Doc.Fonts("Helvetica") |
| |
| Params = "x=0; y=650; width=612; alignment=center; size=50" |
| Page.Canvas.DrawText "Hello World!", Params, Font |
| |
| Filename = Doc.Save( Server.MapPath("hello.pdf"), False ) |
| |
| Response.Write "Success! Download your PDF file <A HREF=" & Filename & ">here</A>" |
| |
| %> |
| |
C# Example
| IPdfManager objPdf = new PdfManager(); |
| IPdfDocument objDoc = objPdf.CreateDocument(Missing.Value); |
| |
| objDoc.Title = "AspPDF Chapter 3 Hello World Sample"; |
| objDoc.Creator = "John Smith"; |
| |
| IPdfPage objPage = objDoc.Pages.Add(Missing.Value, Missing.Value, Missing.Value); |
| IPdfFont objFont = objDoc.Fonts["Helvetica", Missing.Value]; |
| |
| String strParams = "x=0; y=650; width=612; alignment=center; size=50"; |
| objPage.Canvas.DrawText( "Hello World!", strParams, objFont ); |
| |
| String strFilename = objDoc.Save( Server.MapPath("hello.pdf"), false ); |
| |
| lblResult.Text = "Success! Download your PDF file <A HREF=" + strFilename + ">here</A>"; |
| |
NOTE: To use AspPDF in ASP.NET, you must place the wrapper assembly ASPPDFLib.dll (included with the installation) in the /Bin directory of your .NET application, and use the following directive in your source files:
<%@ Import Namespace="ASPPDFLib" %>
Article ID: 328, Created: 4/24/2009 at 10:04 AM, Modified: 4/25/2009 at 11:10 AM