rlpycairo

0.4.0 · active · verified Fri Apr 10

rlpycairo is a plugin backend renderer for the `reportlab.graphics.renderPM` module, designed to replace the legacy `_renderPM` C extension which experienced issues with complex documents. It extends the ReportLab PDF Toolkit, enabling the creation of rich PDF documents and charts in various bitmap and vector formats. Currently at version 0.4.0, the library is in a 'Pre-Alpha' development status, with periodic updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure ReportLab to use `rlpycairo` as its rendering backend and then generate a simple PNG image using ReportLab's graphics module. This verifies the `rlpycairo` plugin is active and functional.

from reportlab.lib.pagesizes import A4
from reportlab.lib.units import inch
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPM
import reportlab.rl_config
import os

# Enable rlPyCairo backend
reportlab.rl_config.renderPMBackend = 'rlPyCairo'

# Create a simple ReportLab drawing
d = Drawing(200, 100)
d.add(String(50, 50, "Hello, rlPyCairo!", fillColor='red'))

output_filename = 'hello_rlpycairo.png'
# Render the drawing to a PNG file using the configured backend
renderPM.drawToFile(d, output_filename, 'PNG')

print(f"Generated '{output_filename}' using rlPyCairo backend.")
print(f"File path: {os.path.abspath(output_filename)}")

view raw JSON →