phenx/php-svg-lib
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
sabberworm/php-css-parser | v8.5.1 | - | MIT | prod |
The phenx/php-svg-lib is a versatile library designed to handle Scalable Vector Graphics (SVG) files within PHP. Its main function serves to read, parse, and export SVGs into Portable Document Format (PDF) effectively. This library essentially rasterizes SVG into a surface that could be an image or more commonly a PDF, through the \Svg\Surface
PHP interface. The inception of this project was primarily to render SVG documents embedded within PDF files for the DomPdf project, highlighting its importance in manipulating SVG files for dynamic web applications.
To integrate the phenx/php-svg-lib into your projects, you would first need to install it using Composer, a dependency manager for PHP. Please make sure that you have Composer installed on your machine. Run the command below to include the library in your project:
composer require phenx/php-svg-lib
Once it's installed, you can use the \Svg\Surface
PHP interface provided by the library for SVG rasterization.
Here is a basic usage example:
use Svg\Surface;
// create a surface instance
$surface = new Surface();
// load SVG file
$svg = file_get_contents('path_to_your_svg_file.svg');
// parse and rasterize SVG file
$surface->parse($svg);
// export SVG to PDF
$surface->export('path_to_output_pdf_file.pdf');
Remember to replace path_to_your_svg_file.svg
with the path to the actual SVG file you want to parse, and path_to_output_pdf_file.pdf
with the output path where the PDF file will be created.
Unfortunately, based on the given GitHub repository, it seems that the documents for phenx/php-svg-lib package aren't explicitly provided. However, users can utilize the source code, specifically the \Svg\Surface
PHP interface for learning purposes. Additionally, you can check the GitHub repository's issue tracker for any potential queries or issues experienced by other users and their resolutions. The usage example provided can serve as a starting point to familiarize yourself with the package. As always, for open-source projects, please feel free to contribute to the documentation if you can!