danfickle / danfickle/openhtmltopdf
sizing of inline SVGs ignored
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
hey,
i am generating a PDF file from HTML string including inline svgs.
i am setting svg width and height via css as well as trying to set width and height via svg tag attribute. both seems to be ignored. what can i do to scale the inline svgs?
here is my html:
html including inline svgs
```html
@page {
/*size: 3508px 2480px;*/
margin: 0;
}
body {
background-color: #fff;
color: #000;
margin: 25px;
}
table {
width: 100%;
}
td {
text-align: center;
vertical-align: middle;
}
.entry {
width: 66%;
overflow: hidden;
border: 5px solid black;
border-radius: 25px;
display: flex;
flex-direction: column;
align-items: center;
text-align: justify;
}
.entry .hint {
padding: 25px;
background-color: black;
color: white;
font-size: 28px;
text-align: center;
width: 100%;
}
svg {
width: 300px;
height: 300px;
display: block;
}
```
html output aka expected output:

pdf output:

i am using the PdfRenderer like this (in Kotlin):
```kotlin
private fun JsoupDocument.toPdf(): ByteArrayOutputStream = ByteArrayOutputStream().use {
PdfRendererBuilder().apply {
withW3cDocument(W3CDom().fromJsoup(this@toPdf), "/")
toStream(it)
useSVGDrawer(BatikSVGDrawer())
run()
}
it
}
```
i am using following related dependencies:
```kotlin
implementation("com.openhtmltopdf:openhtmltopdf-pdfbox:1.0.10")
implementation("com.openhtmltopdf:openhtmltopdf-java2d:1.0.10")
implementation("com.openhtmltopdf:openhtmltopdf-svg-support:1.0.10")
implementation("com.openhtmltopdf:openhtmltopdf-slf4j:1.0.10")
implementation("org.jsoup:jsoup:1.13.1")
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.