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

Add --pdf-outlines option(s) to assign PDF outlines based on pages and Markdown headings #479

Merged
merged 10 commits into from
Sep 20, 2022

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Sep 18, 2022

Resolves #478.

pdf-outlines

Structure

  1. (Marpit plugin) After parsing Markdown, mark markdown-it's heading tokens with unique key, to make recognizable heading items in browser.
  2. (Puppeteer) Before converting Markdown to PDF, the browser finds marked heading items and resolves the rendered positions and displayed texts: offsetLeft, offsetTop, and textContent.
  3. (pdf-lib) Postprocess the output PDF to assign document outlines, from the result of 1 and 2.

setOutline() in utils/pdf.ts supports assigning outlines/bookmarks to PDF, for jumping into the page or the specific position of the page.

ToDo

  • Assign PDF outlines
  • CLI options (--pdf-outlines)
    • Consider about detailed options (e.g. --pdf-outlines.pages, --pdf-outlines.headings)
  • Tests
  • Update README.md

@yhatt yhatt changed the title [WIP] Assign PDF outlines based on pages and Markdown headings Assign PDF outlines based on pages and Markdown headings Sep 18, 2022
@yhatt yhatt marked this pull request as draft September 18, 2022 10:37
@yhatt yhatt changed the title Assign PDF outlines based on pages and Markdown headings Add --pdf-outlines option(s) to assign PDF outlines based on pages and Markdown headings Sep 19, 2022
@yhatt yhatt marked this pull request as ready for review September 20, 2022 14:23
@yhatt yhatt merged commit 5530b03 into main Sep 20, 2022
@yhatt yhatt deleted the pdf-outlines branch September 20, 2022 15:49
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.

Assign PDF metadata of slide outline
1 participant