danfickle / danfickle/openhtmltopdf
font-weight bold not respected when rendering images.
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
(Subject and problem changed. See below.)
For various reasons we are inlining external resources before rendering PDF / PNG.
```css
@font-face {
font-family: "Roboto";
src: url(data:font/ttf;base64,AAEAAAASAQAABAAgR0RFRrRCsIIAAidIAAACYkdQT1P/...=);
...
````
This works great when rendering PDFs.
```
com.openhtmltopdf.load INFO:: Loaded document in ~153ms
com.openhtmltopdf.load INFO:: TIME: parse stylesheets 246ms
com.openhtmltopdf.match INFO:: media = print
com.openhtmltopdf.match INFO:: Matcher created with 161 selectors
com.openhtmltopdf.load INFO:: >>> Loading font(Roboto) from InputStream supplier now. <<<
com.openhtmltopdf.general INFO:: Using fast-mode renderer. Prepare to fly.
...
```
Using the exact same html as input, but rendering an image, the font doesn't load. (Notice no "Loading font..." log entry **and** the resulting font in the image is false.
```
com.openhtmltopdf.load INFO:: TIME: parse stylesheets 296ms
com.openhtmltopdf.match INFO:: media = print
com.openhtmltopdf.match INFO:: Matcher created with 161 selectors
Process finished with exit code 0
```
The code is as straight forward as it can get.
```java
BufferedImagePageProcessor bufferedImagePageProcessor = new BufferedImagePageProcessor(BufferedImage.TYPE_INT_RGB, 1.0);
Java2DRendererBuilder builder = new Java2DRendererBuilder();
builder.toSinglePage(bufferedImagePageProcessor);
builder.useSVGDrawer(new BatikSVGDrawer());
builder.withHtmlContent(html, null);
builder.runFirstPage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedImagePageProcessor.getPageImages().get(0), type, baos);
byte[] ba = baos.toByteArray();
...
```
Not sure what or if I am doing anything wrong...
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.