diff --git a/pom.xml b/pom.xml index 11d96c9e7..a1f496d09 100644 --- a/pom.xml +++ b/pom.xml @@ -92,12 +92,21 @@ utils-mail-dkim 2.0.1 + + org.xhtmlrenderer flying-saucer-pdf 9.8.0 + + + org.jsoup + jsoup + 1.17.2 + + org.apache.poi diff --git a/src/main/java/sirius/web/templates/pdf/TagliatellePDFContentHandler.java b/src/main/java/sirius/web/templates/pdf/TagliatellePDFContentHandler.java index 55059c8ad..c1619bc89 100644 --- a/src/main/java/sirius/web/templates/pdf/TagliatellePDFContentHandler.java +++ b/src/main/java/sirius/web/templates/pdf/TagliatellePDFContentHandler.java @@ -8,6 +8,9 @@ package sirius.web.templates.pdf; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Entities; import org.xhtmlrenderer.pdf.ITextRenderer; import sirius.kernel.di.std.Part; import sirius.kernel.di.std.Register; @@ -53,7 +56,7 @@ public boolean generate(Generator generator, OutputStream out) throws Exception ITextRenderer renderer = new ITextRenderer(); renderer.getSharedContext() .setReplacedElementFactory(new ImageReplacedElementFactory(renderer.getOutputDevice())); - renderer.setDocumentFromString(content); + renderer.setDocumentFromString(cleanHtml(content)); renderer.layout(); renderer.createPDF(out); out.flush(); @@ -61,6 +64,30 @@ public boolean generate(Generator generator, OutputStream out) throws Exception return true; } + /** + * Cleans the given HTML content for use as input to the PDF generator. + *

+ * This is done by first generally removing all {@code