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.

PascalCase aliases

The method names above mirror fpdf2, so its documentation applies unchanged. Because that reads oddly in VBScript, every multi-word method also answers to its PascalCase name — use whichever you prefer:

VBScript stylefpdf2 style
AddPageadd_page
SetMarginsset_margins
SetAutoPageBreakset_auto_page_break
SetFontset_font
SetTextColor / SetDrawColor / SetFillColorset_text_color / set_draw_color / set_fill_color
SetLineWidthset_line_width
SetXYset_xy
FillPagefill_page
MultiCellmulti_cell
WriteHtmlwrite_html

The single-word methods need no alias: member lookup is case-insensitive, so pdf.Cell, pdf.Image, pdf.Ln, pdf.Text and pdf.Output already work.

Misspell one and the error names the closest match, e.g. Unknown member: SETMARGINZ on PdfDoc (did you mean 'SetMargins'?).

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
%>