Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Input for PDF Generation #1455

Merged
merged 5 commits into from
Sep 5, 2024

Conversation

jakobvogel
Copy link
Member

@jakobvogel jakobvogel commented Sep 4, 2024

Description

The Flying Saucer PDF renderer requires XHTML as input, and we rely on the invoker to provide valid content. However, luckily, the world has moved on from XHTML. In order to relax the requirements and facilitate reuse of HTML templates, this PR introduces an additional processing step that removes problematic elements and ensures XHTML automatically.

Marked as breaking as PDF rendering should be checked after upgrading.

Additional Notes

  • This PR fixes or works on following ticket(s): OX-10783

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices

The PDF renderer requires XHTML as input, and we used to rely on the invoker to provide valid content. However, luckily, the world has moved on from XHTML. In order to relax the requirements and facilitate reuse of HTML templates, this commit introduces an additional processing step that removes problematic elements and ensures XHTML automatically.

OX-10783
@jakobvogel jakobvogel added the 🧬 Enhancement Contains new features label Sep 4, 2024
@@ -53,14 +55,37 @@ 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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Maybe this could be enabled optionally? Don't know if it could break stuff in S2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, how? As an additional pseudo-parameter in the context? As a system-wide setting? Both do not seem to be particularly elegant 😇

Let's see what S2 is going to say about this PR, okay? We can also flag it as breaking, but it should process all previously valid input as it was, and only affect the behaviour in case of faulty input.

@jakobvogel jakobvogel added the 💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code label Sep 5, 2024
@jakobvogel jakobvogel merged commit 42be846 into develop Sep 5, 2024
4 checks passed
@jakobvogel jakobvogel deleted the feature/jvo/OX-10783-XHTML-for-PDFs branch September 5, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🧬 Enhancement Contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants