Hi Nicola, On Tue, 2021-10-26 at 12:07 +0000, Nicola Cisternino wrote: > Hi all > I've an html resource (e.g. "pagecontent.html" stored in "apps" JCR > structure and mapped as sling:resourceType in a "content" node (e.g. > /content/test/page1). > So, using a browser, a request of: > http://localhost:8080/test/page1 returns a text stream containing > html tags ... while a request of > http://localhost:8080/test/page1.html is normally parsed and > correctly displayed. > Can Sling return a PDF rendering of my HTML resource? (something like > http://localhost:8080/test/page1.pdf... or > http://localhost:8080/test/page1.html.pdf)
If you are looking for a way to have Sling automatically render your resources in PDF format like it does for HTML, see Konrad's answer. If you want to add support yourself, it's quite easy to add a renderer for a different extension, see for instance [1] in the Sling project archetype. You can register a Servlet for the 'pdf' extension and generate the output using whatever PDF library you prefer. Hope this helps, Robert [1]: https://github.com/apache/sling-project-archetype/blob/master/src/main/resources/archetype-resources/core.example/src/main/java/servlet/ZipServlet.java
