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

Create bookmarks from HTML outline automatically #103

Merged
merged 1 commit into from Nov 21, 2016

Conversation

stanio
Copy link
Contributor

@stanio stanio commented Nov 20, 2016

  1. Doesn't need non-standard elements in the <head> which most likely duplicate the HTML outline
  2. Doesn't require explicit anchors present
  3. Simple usage – automatic, and allows for fine customization with data-pdf-bookmark attribute hints

When bookmarks have been already defined using <bookmarks> – no result change. To suppress the automatic bookmarks generation completely one could specify:

<html data-pdf-bookmark="none">...

@stanio
Copy link
Contributor Author

stanio commented Nov 20, 2016

See also 00e76d9

I guess this PR needs to include the same "pdf-itext5" changes, also. The new source file likely needs a file header including the license. I'll gladly address all of this once I'm given a preliminary feedback on the functional change I'm suggesting.

@stanio
Copy link
Contributor Author

stanio commented Nov 20, 2016

As a demo one could try this rather tough document:

https://www.w3.org/TR/xmlschema-1/

@stanio
Copy link
Contributor Author

stanio commented Nov 20, 2016

As a side note, I've first thought this could/should be best controlled via style sheet extensions, like (possible user-agent styles):

h1 { -pdf-bookmark: 1 }
h2 { -pdf-bookmark: 2 }
h3 { -pdf-bookmark: 3 }
h4 { -pdf-bookmark: 4 }
h5 { -pdf-bookmark: 5 }
h6 { -pdf-bookmark: 6 }

/* Exclude outline of nested sectioning roots. */
blockquote :any(h1, h2, h3, h4, h5, h6),
td :any(h1, h2, h3, h4, h5, h6) {
  -pdf-bookmark: none;
}

(See :any)

Possible user styles:

/* Exclude individual heading from outline. */
h3.extra { -pdf-bookmark: none }

/* Establish non-heading bookmark. */
tr.extra {
  -pdf-bookmark: 4 attr(data-bookmark-name);
}

The last one would mean establish an implicit section of level/rank 4, and set the bookmark name to the value of the "data-bookmark-name" attribute of the element (vs. using the element text content).

All this require more thought on how the given property cascades, etc., and I don't currently have enough knowledge of the CSS implementation in flyingsaucer.

@pbrant
Copy link
Member

pbrant commented Nov 21, 2016

Looks good! Thanks. This is a much better approach than before.

@pbrant pbrant merged commit 3fb03d7 into flyingsaucerproject:master Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants