danfickle / danfickle/openhtmltopdf

BatikSVGDrawer does not load custom-protocol raster images through provided FSStreamFactory

Open
#787 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Given an HTML document which embeds the same image having a custom-protocol URL 2 times, once through an HTML `` tag and once through an SVG `` tag in an inline SVG image:

```html


```

And given an implementation of `FSStreamFactory` handling `foo:` URLs is provided:

```java
public class FooStreamFactory implements FSStreamFactory {
//...
}
new PdfRendererBuilder()
.useProtocolsStreamImplementation(new FooStreamFactory(), "foo")
.useSVGDrawer(new BatikSVGDrawer(SECURE, Set.of("foo")))
.withHtmlContent(HTML, "")
.toStream(out)
.run();
```

When rendering this with Open PDF to HTML then a document showing 2 flying saucers images should be created.

But the resulting document contains only 1 flying saucers image and this warning message is logged:

```
com.openhtmltopdf.exception WARNING:: Couldn't draw SVG. => org.apache.batik.transcoder.TranscoderException:: null
Enclosed Exception:
null:0
The URI "foo:/flyingsaucer.png"
on element can't be opened because:
The URI can't be opened:
Unable to make sense of URL for connection
```

[Sample project with all code to reproduce above example](https://github.com/danfickle/openhtmltopdf/files/7579448/ohtp-svg-raster-images.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.