Crates.io | vl-convert-pdf |
lib.rs | vl-convert-pdf |
version | 1.4.0 |
source | src |
created_at | 2023-10-02 22:43:26.043126 |
updated_at | 2024-04-15 12:56:05.385026 |
description | Crate to convert SVG to PDF with embedded text |
homepage | https://github.com/jonmmease/vl-convert |
repository | https://github.com/jonmmease/vl-convert |
max_upload_size | |
id | 990577 |
size | 44,263 |
This crate builds on top of the excellent svg2pdf project (created by the typst team) to convert SVG images to PDF files with embedded text. svg2pdf supports converting text into geometric paths using the usvg library, but it doesn't yet support embedding text (which is required for text selection, text copying, screen readers, etc.).
This project uses svg2pdf to handle everything in the SVG image except text, and then adds an embedded text layer on top using the pdf-writer library (also created by the typst team). The text embedding logic handles TrueType fonts and is heavily inspired by the implementation in the typst typesetting project.
In the future, it would be great if the text embedding logic in typst could be extracted and used by svg2pdf (making this crate unnecessary), but in the meantime this crate will maintain an independent implementation of text embedding.
Many thanks to the typst team for their support in https://github.com/typst/svg2pdf/issues/21.
See examples/pdf_conversion.rs for example usage