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

PDF Bookmark Support #1462

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public boolean generate(Generator generator, OutputStream out) throws Exception
private String cleanHtml(String html) {
Document document = Jsoup.parse(html);

// the parser is very strict in terms of what elements are accepted within the <head> element, and it does not
// know about additional valid elements like <bookmarks> that are valid for flying saucer; we need to move them
// back from the <body> to the <head> element
document.select("body > bookmarks").forEach(bookmarks -> {
document.head().appendChild(bookmarks);
});

// in theory, the following two lines should be possible with a single CSS selector; however, in practice, Jsoup
// does not select the style elements correctly when attempting that
document.select("script").remove();
Expand Down
Loading