You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String baseUri = new ClassPathResource("templates").getURL().toExternalForm();
System.out.println("baseUri :" + baseUri);
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode()
.withHtmlContent(html, baseUri)
The "templates" folder is under "src/main/resources". And, the templates folder contains the HTML, CSS and fonts
However, when searching for fonts and css file, openhtmlpdf searches under classes folder instead of templates and gives the error as such
com.openhtmltopdf.load INFO:: Requesting stylesheet: file:/D:/development/project-1/target/classes/resume.css
com.openhtmltopdf.exception WARNING:: Item at URI file:/D:/development/project-1/target/classes/resume.css not found
I assumed it should have used the templates folder as base as below. D:/development/project-1/target/classes/templates/resume.css
Same errors for fonts, they are not found as they are inside src/main/resources/templates
Now, if I move all my html, css and fonts directly under src/main/resources folder, everything works fine.
So, somehow the baseUri seems not to be working as expected.
The text was updated successfully, but these errors were encountered:
NehalDamania
changed the title
baseUri in withHtmlContent is not working
baseUri in withHtmlContent not working as expected
Oct 4, 2020
When we use
The "templates" folder is under "src/main/resources". And, the templates folder contains the HTML, CSS and fonts
However, when searching for fonts and css file, openhtmlpdf searches under classes folder instead of templates and gives the error as such
The baseUri is printed correctly as
I assumed it should have used the templates folder as base as below.
D:/development/project-1/target/classes/templates/resume.css
Same errors for fonts, they are not found as they are inside src/main/resources/templates
Now, if I move all my html, css and fonts directly under src/main/resources folder, everything works fine.
So, somehow the baseUri seems not to be working as expected.
The text was updated successfully, but these errors were encountered: