1

I am currently using the following:

const pdfmerger = require('pdfmerger')
var pdfStream = pdfmerger(array_of_pdf_paths)
var writeStream = fs.createWriteStream(final_pdf_path)
pdfStream.pipe(writeStream)
pdfmerger(array_of_pdf_paths, final_pdf_path)

What I need is to automatically generate inside the final pdf a Table of Content tree (or Bookmarks) which has entries in the TOC to easily jump to each pdf file. Since it's a combine of 50 pdf documents. Any ideas?

See below an example of Bookmarks in Acrobat

enter image description here

1
  • ---- I've tried to install node-pdfbox, I'm hitting an error on: > node-gyp rebuild CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o In file included from ../src/java.cpp:1: ../src/java.h:7:10: fatal error: 'jni.h' file not found #include <jni.h> gyp ERR! node -v v10.15.3 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm WARN [email protected] No description npm WARN [email protected] No repository field. Commented Mar 10, 2019 at 10:39

1 Answer 1

1

Have you tried using node-pdfbox? It is a bridge to PDFBox that allows full PDF manipulation: https://pdfbox.apache.org/

From what I've seen going through their java examples - you should be able to set bookmarks in the final PDF file after you have added your PDFs by going through the array and getting page counts and PDF filenames.

Sign up to request clarification or add additional context in comments.

2 Comments

I'll check it right now. Indeed their java api has a CreateBookmark sample. I'll see if it's implemented in the node-pdfbox version. memorynotfound.com/apache-pdfbox-bookmark-pdf-example/…
I've tried to install node-pdfbox, I'm hitting an error on: > node-gyp rebuild CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o In file included from ../src/java.cpp:1: ../src/java.h:7:10: fatal error: 'jni.h' file not found

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.