Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment

Home Page:https://pdf-lib.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Find headings in pdfs

vekunz opened this issue · comments

Hello,
I'm not sure if this is even possible, therefore I ask for it. I'm using pdf-lib in a pipeline where I first create pdfs from markdown and then merge some pdfs together. Currently, I have to create a table of contents manually and I have to update it every time I make changes to the source.
So my question is, is it possible to make a feature to detect on which page a specific heading is?

Hello @vekunz!

I'm afraid this is not really possible to do with pdf-lib today. It would require a lot of custom code to be written to extract and parse text. And this is not an easy or straightforward thing to do with PDFs (see #93 and #137).

To be clear, it is technically possible to do. And libraries like pdf.js that are designed for reading PDF documents (as opposed to creating/editing them) can do it. It's just that pdf-lib doesn't have the facilities to make this easy as of today.