@@ -13,23 +13,23 @@ will still be turned into a vector graphic), so no quality is lost.
1313This example reads an SVG file and writes the corresponding PDF back to the disk.
1414
1515```
16- # fn main() -> Result<(), Box<dyn std::error::Error>> {
17- use svg2pdf::usvg::fontdb;
18- use svg2pdf::Options ;
19-
20- let input = "tests/svg/custom/integration/matplotlib/stairs.svg";
21- let output = "target/stairs.pdf";
22-
23- let svg = std::fs::read_to_string(input)?;
24- let options = svg2pdf::usvg::Options::default();
25- let mut db = fontdb::Database::new();
26- db.load_system_fonts();
27- let tree = svg2pdf::usvg::Tree::from_str(&svg, &options, &db)?;
28-
29- let pdf = svg2pdf::to_pdf(&tree, Options::default(), &db);
30- std::fs::write(output, pdf)?;
31- # Ok(()) }
32- ```
16+ * # fn main() -> Result<(), Box<dyn std::error::Error>> {
17+ * use svg2pdf::usvg::fontdb;
18+ * use svg2pdf::ConversionOptions ;
19+ *
20+ * let input = "tests/svg/custom/integration/matplotlib/stairs.svg";
21+ * let output = "target/stairs.pdf";
22+ *
23+ * let svg = std::fs::read_to_string(input)?;
24+ * let options = svg2pdf::usvg::Options::default();
25+ * let mut db = fontdb::Database::new();
26+ * db.load_system_fonts();
27+ * let tree = svg2pdf::usvg::Tree::from_str(&svg, &options, &db)?;
28+ *
29+ * let pdf = svg2pdf::to_pdf(&tree, Options::default(), &db);
30+ * std::fs::write(output, pdf)?;
31+ * # Ok(()) }
32+ * ```
3333
3434## Supported features
3535In general, a very large part of the SVG specification is supported, including
@@ -80,8 +80,8 @@ static GRAY_ICC_DEFLATED: Lazy<Vec<u8>> =
8080pub struct Options {
8181 /// Whether the content streams should be compressed.
8282 ///
83- /// The smaller PDFs generated by this are generally more practical but it
84- /// increases runtime a bit.
83+ /// The smaller PDFs generated by this are generally more practical, but it
84+ /// might increase run-time a bit.
8585 ///
8686 /// _Default:_ `true`.
8787 pub compress : bool ,
@@ -93,11 +93,22 @@ pub struct Options {
9393 ///
9494 /// _Default:_ 1
9595 pub raster_scale : f32 ,
96+
97+ /// Whether text should be embedded as actual selectable text inside
98+ /// the PDF. If this option is disabled, text will be converted into paths
99+ /// before rendering.
100+ ///
101+ /// _Default:_ `true`.
102+ pub embed_text : bool ,
96103}
97104
98105impl Default for Options {
99106 fn default ( ) -> Self {
100- Self { compress : false , raster_scale : 1.0 }
107+ Self {
108+ compress : false ,
109+ raster_scale : 1.0 ,
110+ embed_text : true ,
111+ }
101112 }
102113}
103114
0 commit comments