I have a requirement to be able to generate PDFs from a Spring Boot Template. For this, I am using a PDF rendering library (FlyingSaucer) which mostly does the job correctly. There is one issue, however: when I have "href" tags on the page, they do not resolve correctly when the PDF renderer tries to render the HTML. For example, if I have the following code:
<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}" />
It resolves correctly in the browser, but when I try to retrieve this as a ClassPath resource using the following code:
new ClassPathResource("/css/index").getInputStream()
Spring Boot says that the file does not exist. This is odd to me, as I thought that Spring Boot adds all static content to the classpath.
Below is the folder structure of my project, which (I think) follows the correct Spring Boot convetion:
Can I get a handle on some Spring resource (through autowiring, the application context, etc) to resolve these URLs just as it does when the browser requests them? I could probably get around this by hardcoding "resources/static/" to the beginning of the url string, but I'd prefer a more dynamic solution.
