Closed jcorbett55 closed 6 years ago
Are you on Windows? Gonna try to reproduce this later today.
@jcorbett55 I could not reproduce. This test passes on a Windows 10 machine:
@Test
public void itReleasesHandleToPdfFileWhenConversionIsDone() throws IOException {
File file = tempFolder.newFile();
HtmlToPdf.create()
.object(HtmlToPdfObject.forHtml("<p>test</p>"))
.convert(file.getPath());
assertTrue(file.renameTo(file));
}
I was also able to delete the file manually while this test was in a Thread.sleep
.
It would be very helpful if you could provide a snippet that I could run that reproduces the behavior.
Closing due to inactivity. Welcome to re-open if you have more input.
Found out another process was getting called via another library and that was locking it. So it was invalid. Thanks.
it shows fine in the html, but it's empty in the pdf? am I missing something?
@jcorbett55 try playing around with HtmlToPdfObject#loadImages
and HtmlToPdfObject#javascriptDelay
here's my code. I will try with the javascriptDelay. see if that works. HtmlToPdfObject htmlObject = HtmlToPdfObject.forHtml(document); htmlObject.loadImages(true); HtmlToPdf htmlToPdf = HtmlToPdf.create().object(htmlObject); Boolean success = htmlToPdf.convert(TEMP_FOLDER_LOCATION + pdfFileName);
During public boolean convert(String path), the generated file remains locked in the IO stream and cannot be manipulated during runtime,. My inital guess is that the following is not closing up all connections when run. finally { wkHtmlToPdf.wkhtmltopdf_destroy_converter(converter); }