-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svg input differs to pdf output #63
Comments
False alarm. Inkscape is better than you. |
I'm not following, is there an SVG that is converted differently from what you expected? I tried the |
Then please help me with which settings you did that. I have now set up the code like this and all the labels are now gone.
|
See the documentation for use std::fs::write;
use svg2pdf::{Options, usvg};
use svg2pdf::usvg::{fontdb, PostProcessingSteps, TreeParsing, TreePostProc};
fn main() {
let data = [
(2.327473685, "Rust-bio"),
(38.339006423950195, "Python"),
(0.258953, "Julia"),
];
let svg = poloto::build::bar::gen_simple("", data, [0.00])
.label(("Comparison of Programming Language Runtime", "Runtime in Seconds", "Languages"))
.append_to(poloto::header().light_theme())
.render_string().unwrap();
let mut tree = usvg::Tree::from_str(&svg, &usvg::Options::default()).unwrap();
let mut db = fontdb::Database::new();
db.load_system_fonts();
tree.postprocess(PostProcessingSteps::default(), &db);
let pdf = svg2pdf::convert_tree(&tree, Options::default());
write("bar.pdf", pdf).unwrap();
} |
That's weird. The labelling is still missing. Are you loading the library with a different version number? |
I have now rewritten the code as follows and as you can see by simply calling up the two generated files in Firefox, the outputs are not congruent.
This can also be observed using the following link. |
Hmm, as I said, for me the text shows up fine... I suspect that it's a font fallback issue. Are you sure you have Install Then run You can also verify that |
What do you mean by |
.poloto{
stroke-linecap:round;
stroke-linejoin:round;
font-family:Roboto,sans-serif;
font-size:16px;
} |
That would be super weird, because the svg is created correctly and also has all the features and only the pdf is suddenly without labelling. I'll give it a try. Since I have a Nixos, I have to compile the operating system for new packages every time. So see you soon. |
OK, I've installed it. Still not working. I mean, it's not that bad. I can still turn an .svg into a .pdf using inkscape. |
Hmm, yeah, sorry then... It's hard for me to debug if I can't reproduce it locally. But I'm still 99% sure it's some kind of font issue, because apart from font loading, everything should work independently from the platform... |
Since I'm 99% sure it's a font loading/fallback issue, I'll close this in favor of #65. |
I thought you might be interested. I am currently creating .svg files using Poloto and was wondering why my plots suddenly become informationless when I save them as .pdf. You can have a look at the files from my gitlab project for comparison. The .svg were first translated with your library and then again with inkscape. So from my point of view you are just as good as inkscape at translating .svg to .pdf.
The text was updated successfully, but these errors were encountered: