ASPPY.pdf

The ASPPY.pdf namespace is powered by the Python fpdf2 library. It allows you to construct robust PDF documents natively from your VBScript files.

Namespace Methods

PdfDoc Object Methods

Method Description
add_page(orientation="")Adds a new page to the document.
set_font(family, style="", size=12)Sets the font (e.g. "Arial", "B", 16).
set_text_color(r, [g], [b])Sets the text color using RGB.
set_draw_color(r, [g], [b])Sets the draw color for lines and shapes.
set_fill_color(r, [g], [b])Sets the fill color for filled cells and shapes.
cell(w, h=0, text="", border=0, ln=0, align="", fill=False, link="")Prints a cell with optional borders, background color, and text alignment.
multi_cell(w, h, text, border=0, align="", fill=False)Prints text with line breaks across multiple lines.
write_html(html)Renders basic HTML markup (bold, italic, headers) into the PDF.
image(path, [x], [y], [w], [h])Places an image onto the PDF canvas.
output(path)Saves the resulting PDF to a physical disk path.

Sample Code

<%
Dim pdf
' Create a new portrait A4 document measured in millimeters
Set pdf = ASPPY.pdf.New("P", "mm", "A4")

' Add a page
pdf.add_page()

' Set font and add title
pdf.set_font "Arial", "B", 16
pdf.set_text_color 0, 51, 102
pdf.cell 0, 10, "ASPPY PDF Document", 0, 1, "C"

' Paragraph
pdf.ln 10
pdf.set_font "Arial", "", 12
pdf.set_text_color 0, 0, 0
pdf.multi_cell 0, 10, "This PDF was generated natively from VBScript using the fpdf2 Python library underneath!"

' Render some HTML markup
pdf.ln 10
pdf.write_html "<b>Bold</b>, <i>Italic</i>, and <u>Underline</u> are supported. You can even include <h1>Headers</h1>!"

' Output to disk
Dim outputPath
outputPath = Server.MapPath("/pdfs/sample.pdf")
pdf.output outputPath

Response.Write "PDF created successfully at: " & outputPath
%>