pdf

Library for making pdf EZ

0 downloads owners: imabd645

Install

ez install pdf

Dependencies (1.0.0)

PackageRange
No dependencies.

Readme

EZ PDF Generation Library (pdf)

pdf is a robust, full-featured PDF generation library for the EZ language. It uses the native pdfgen C library via FFI (Foreign Function Interface), providing blazingly fast PDF creation with full support for text, colors, drawing, and shapes.

Installation

ez install pdf 1.0.0

Basic Usage

To generate a PDF, you create a PDF object, add pages, add your content, and finally save it.
Note: All coordinates (x, y) originate from the bottom-left of the page (standard PDF coordinate system).

use "pdf"

# 1. Create a PDF instance (A4 size by default)
doc = PDF("invoice.pdf")

# 2. Add a new page
doc.addPage()

# 3. Add text (x, y, text, size, color)
doc.text(50, 750, "Hello World!", 16, doc.rgb(0,0,0))

# 4. Save and export the PDF
doc.save()

Styling and Colors

Colors are packed into 32-bit integers. You can generate them easily using the rgb() helper:

RED = doc.rgb(255, 0, 0)
BLUE = doc.rgb(0, 0, 255)
GREEN = doc.rgb(0, 255, 0)

You can change the font at any time before drawing text. Supported standard fonts include:

doc.setFont("Helvetica-Bold")
doc.text(50, 700, "Bold Text", 12, RED)

Drawing Shapes and Lines

pdf supports a wide array of geometric shapes:

# Draw a Line: (x1, y1, x2, y2, thickness, color)
doc.line(50, 600, 200, 600, 2, BLUE)

# Draw an Empty Rectangle: (x, y, w, h, borderThickness, color)
doc.rect(50, 500, 100, 50, 1, RED)

# Draw a Filled Rectangle: (x, y, w, h, fillColor, borderColor, borderThickness)
doc.filledRect(200, 500, 100, 50, GREEN, RED, 2)

# Draw a Circle: (x, y, radius, borderThickness, borderColor, fillColor)
# (Pass 0 for fillColor to make it transparent)
doc.circle(100, 400, 40, 2, BLUE, 0)

Embedding Images

You can embed local image files (.jpg, .png, .bmp) directly into the PDF:

# Embed an image: (x, y, width, height, path)
doc.image(50, 200, 150, 100, "logo.png")

Professional Helpers

pdf includes built-in helper functions to rapidly build reports and invoices:

# Generates a large bold title with an underline
doc.header("Monthly Sales Report")

# Generates a table header row with an underline
doc.tableHeader(700, ["Item", "Quantity", "Price"], [50, 200, 400])

# Generates a standard data row 
doc.tableRow(680, ["Apples", 50, "$2.00"], [50, 200, 400])

Architecture

pdf is powered by the pdfgen C library, compiled natively as a 64-bit DLL (dll\pdf.dll). It utilizes EZ's os_load_lib and os_call for high-performance memory-safe FFI binding.

Versions

VersionSizeDownloadsPublished
1.0.0 258.4 KB 0 1 hour ago

Integrity

sha256  af11baf676eac4410d84a1556a872b19e9e50e548560fedc20bdb0c1f95ca3a7