$ show mogest/prawn-svg
prawn-svg is a Ruby library that renders SVG (Scalable Vector Graphics) documents into PDF format using the Prawn PDF library. It extends Prawn::Document with an svg() method that parses SVG input, applies CSS styles, handles external resources (images, fonts), and converts SVG elements into Prawn drawing commands. The architecture is modular with separate components for SVG parsing, CSS handling, attribute processing, coordinate transformation, and rendering of various SVG elements including shapes, paths, text, gradients, patterns, clipping paths, and masks. It supports most of the SVG 1.1 specification and provides configurable options for positioning, sizing, and resource loading.
The LLM identified 2 files worth highlighting for reuse:
Implements the mathematical conversion from SVG elliptical arcs to BΓ©zier curves following the W3C specification. This self-contained module handles the complex trigonometric calculations needed to approximate arcs with cubic BΓ©zier curves, making it reusable in any graphics library that needs to process SVG path data.
Calculates the length of SVG paths including lines and BΓ©zier curves using adaptive subdivision with lookup tables for efficiency. This component solves the non-trivial problem of measuring parametric curves and could be extracted for use in any project requiring path length calculations or text-on-path functionality.