DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: software to build ebook by importing PDF files and creating table of contents  (Read 10,029 times)

HankFriedman

  • A computer nerd whose also a psychic & astrologer
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 147
I have a lot of articles that I've written that I want to assemble into one or more ebooks.

I can easily format each as a PDF file, but I don't know what software to use to merge them all, in the correct order, and at the same time create a table of contents that updates every time I add a new file.

Can anyone help me?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
I don't know an answer, but i think dc member ewemoa has looked into such tools.  maybe he can post his discoveries..

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

HankFriedman

  • A computer nerd whose also a psychic & astrologer
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 147
I looked into Calibre and it doesn't really have that capability

xtabber

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 618
I have a lot of articles that I've written that I want to assemble into one or more ebooks.

I can easily format each as a PDF file, but I don't know what software to use to merge them all, in the correct order, and at the same time create a table of contents that updates every time I add a new file.

Can anyone help me?
Take a look at PDF EX-Change Pro. It's extremely powerful, although its user interface is not always intuitive. Many features are hard to find and the documentation dense and not that easy to navigate.

PDF EXchange Editor provides an option to automatically create a top level bookmark pointing to each new document inserted into an existing document, as well as a bookmark editor and macro facility that should be enough to do what you want. The Pro version costs nearly twice as much, but adds tools that would allow you to more fully automate the process.

HankFriedman

  • A computer nerd whose also a psychic & astrologer
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 147
I will do that.

I've been searching for the past hour and hope to find an easy to use and good solution.

It doesn't have to be freeware if it works well.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
I do not know enough about eBooks to discern if this utility would be helpful.  But it is open source and may be worth a look:

Scriba

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Would it perhaps be easier to copy/paste your articles into something like Google Docs, adjust the formatting a bit (as needed) so it knows how to update the table of contents, and then export as PDF?

It might not take very long in each article to select the title and headings and change their formatting as appropriate, especially if you use keyboard shortcuts.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
I have a lot of articles that I've written that I want to assemble into one or more ebooks.

I can easily format each as a PDF file, but I don't know what software to use to merge them all, in the correct order, and at the same time create a table of contents that updates every time I add a new file.

Hi Hank. This might help, but only if you with ebook had in mind a merged .pdf file rather than .epub (reflowing text).

I updated an older autohotkey script of mine. It now uses pdftk to merge many pdf files to one big pdf with one bookmark per component pdf file. the order is set in a plain txt file so it is easy to add/rearrange.

Code: ( autohotkey)
#SingleInstance,Force
;PdfMergeMark  (by nod5  version 160924)
;Merge (concatenate, join) pdf files and add bookmarks

;How to use:
;1 Install PDFtk Server for Windows, https://www.pdflabs.com/tools/pdftk-server/
;2 Create pdflist.txt in same folder as PdfMergeMark.ahk
;3 Add one pdf file path per line, in the order you want. Save.
;4 Run PdfMergeMark.ahk  --> outputs yyyymmddhhmmss.pdf

;pdflist.txt example:
;C:\test\file name.pdf
;C:\folder\another.pdf
;C:\some other folder\this file.pdf

;optional: custom path to pdftk
pdftk =
out := A_ScriptDir "\" a_now ".pdf"
if !FileExist(pdftk)
  pdftk := A_ScriptDir "\pdftk.exe"
if !FileExist(pdftk)
  pdftk = C:\Program Files (x86)\PDFtk Server\bin\pdftk.exe
if !FileExist(pdftk) or !FileExist(A_ScriptDir "\pdflist.txt")
 exitapp
clip := ClipBoardAll
clipboard =
p := 1
Loop, Read, %A_ScriptDir%\pdflist.txt
{
SplitPath, A_LoopReadLine, name,,ext, noext
If !FileExist(A_LoopReadLine) or (ext!="pdf")
 continue
tooltip, Reading... %A_LoopReadLine%
runwait %comspec% /c ""%pdftk%" "%A_LoopReadLine%" dump_data | clip",,hide
RegExMatch(clipboard, "NumberOfPages: (\d+)\R",pages)  ;NumberOfPages: 154 -> 154
bm .= "`nBookmarkBegin"
bm .= "`nBookmarkTitle: " noext
bm .= "`nBookmarkLevel: 1"
bm .= "`nBookmarkPageNumber: " p
p := p + pages1
pdfstring .= A_Space """" A_LoopReadLine """"
}
FileAppend, %bm%, %out%_txt
tooltip, Concatenating...
runwait "%pdftk%" %pdfstring% cat output "%out%_temp",,hide    ;concatenate pdfs
runwait "%pdftk%" A="%out%_temp" cat A1-end output "%out%_temp2",,hide ;del old bookmarks
tooltip, Bookmarking...
runwait "%pdftk%" "%out%_temp2" update_info "%out%_txt" output "%out%",,hide  ;new bookmarks
FileDelete, %out%_* ; clear temp files
clipboard := clip   ;restore clipboard
tooltip, FINISHED
sleep 1000
tooltip

The pdflist.txt can be created and edited in Notepad. Put the path of each pdf file to merge in the order you want.
Code
C:\test\file name.pdf
C:\folder\another.pdf
C:\some other folder\this file.pdf

Some limitations:
All bookmarks are on the same level, in other words no tree view of bookmarks (chapter 1, 1.1,  ...)
No bookmark numbering (unless the user adds numbers to the filenames)
May fail if pdflist is very, very long (when exceeding maximum line string length for cmd)

I might add some more stuff later on and make a small NANY release out of it.

kilele

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 243
I think this one can do what you asked for
http://www.sejda.com/desktop

Original address: https://www.donationcoder.com/forum/index.php?topic=43027.0