danfickle / danfickle/openhtmltopdf
PdfRendererBuilder's run method closes the OutputStream passed using the toStream method
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
The documentation of the ```PdfRendererBuilder```'s ```toStream``` method states that when calling the ```run``` method, the passed ```OutputStream``` will not be closed.
That's not true in practice : the ```createPdf``` / ```createPdfFast``` methods of the ```PdfBoxRenderer``` class both call ```_pdfDoc.save(os);```, which itself closes the OutputStream.
My workaround is to wrap my outputstream in a FilterOutputStream on which I override the close method :
```java
OutputStream pdfOutput = ... //my original outputstream
OutputStream nonCloseablePdfOutput = new FilterOutputStream(pdfOutput) {
@Override
public void close() throws IOException {
//openhtmltopdf has a bug where it closes the stream at the end of the "run" method
//even though the documentation states otherwise.
}
};
builder.toStream(nonCloseablePdfOutput);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.