danfickle / danfickle/openhtmltopdf
Generation of pdf is too slow for large html
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
I am now using version 1.0.2, but the pdf build is still hang.
The size of html is 13241929
I have tried many times and increased the heap size to 4G.
My running machine is i5 4460, 16G RAM.
Attafched with the test html
[test.txt](https://github.com/danfickle/openhtmltopdf/files/4752989/test.txt)
My code for pdf generation is as follow:
```
public byte[] generateFromHtml(String html) throws Exception {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFont(getFont(PMingLiU), "PMingLiU");
builder.useFont(getFont(PMingLiUExtB), "PMingLiU-ExtB");
builder.useFont(getFont(seguiemj), "Segoe UI Emoji");
builder.withHtmlContent(html, null);
builder.useFastMode();
builder.toStream(byteArrayOutputStream);
builder.run();
return byteArrayOutputStream.toByteArray();
}
}
```
_Originally posted by @Infinity821 in https://github.com/danfickle/openhtmltopdf/issues/180#issuecomment-640995477_
Contributor guide
No contributing guide indexed for this repository
Research direction
Begin with the attached test.txt and the generateFromHtml entry point, then reproduce the PDF build using the reported 13241929-size HTML and current heap settings. Done means identifying a reproducible bottleneck in PdfRendererBuilder or the generation path and documenting a measurable improvement for large HTML inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100