Getting started
Install the package, create the first PDF and learn the coordinate system.
Install#
Install the package with RingPM, the Ring package manager, in one step:
ringpm install pdflib from ringpackagesQuick start#
load "pdflib.ring"
pdf = new PDFWriter()
pdf.setTitle("My First PDF")
pdf.setFont(PDF_HELVETICA_BOLD, 24)
pdf.drawText("Hello, World!", 72, 700)
pdf.save("hello.pdf")Quick function#
load "pdflib.ring"
quickPDF("output.pdf", "My Document", [
[:title = "Page 1", :body = "Content for page 1..."],
[:title = "Page 2", :body = "Content for page 2..."]
])Coordinate System#
PDF uses a bottom-left origin:
- (0, 0) is the bottom-left corner of the page
- X increases to the right
- Y increases upward
- 1 point = 1/72 inch
For A4 paper (595 × 842 pt), the top of the page is y ≈ 842. For typical document layout, start drawing at y = 750 and decrease y for each new line.