Regression: "An unknown error occurred during the conversion. This could indicate a bug in svg2pdf."
Hi,
svg2pdf (and typst) crash on one of my file, it is a svg file created using `pdf2svg` from a graphio graph exported to pdf:
```error: failed to convert SVG to PDF: An unknown error occurred during the conversion. This could indicate a bug in svg2pdf```
A quick git bisect seem to show commit v0.12.0~7 as the culprit, more precisely this hunk:
```diff
@@ -13,18 +15,23 @@ pub fn render(
content: &mut Content,
ctx: &mut Context,
rc: &mut ResourceContainer,
-) -> Option<()> {
+) -> Result<()> {
// TODO: Add a check so that huge regions don't crash svg2pdf (see huge-region.svg test case)
- let layer_bbox = group.layer_bounding_box().transform(group.transform())?;
+ let layer_bbox = group
+ .layer_bounding_box()
+ .transform(group.transform())
+ .ok_or(UnknownError)?;
let pixmap_size = Size::from_wh(
layer_bbox.width() * ctx.options.raster_scale,
layer_bbox.height() * ctx.options.raster_scale,
- )?;
+ )
+ .ok_or(UnknownError)?;
let mut pixmap = tiny_skia::Pixmap::new(
pixmap_size.width().round() as u32,
pixmap_size.height().round() as u32,
- )?;
+ )
+ .ok_or(UnknownError)?;
let initial_transform =
Transform::from_scale(ctx.options.raster_scale, ctx.options.raster_scale)
```
I am not familiar with Rust nor the project so I am probably missing something, but the error seem to come from `tiny_skia::Pixmap::new` that return an error on 0.
Here are the smallest file that i could create that reproduce the error :
[minimal.pdf](https://github.com/user-attachments/files/20646436/minimal.pdf)

the original file :
[virtual_memory.pdf](https://github.com/user-attachments/files/20646437/virtual_memory.pdf)

Thank you for your work !
关闭于 2025-06-08 3 条评论