Coder Social home page Coder Social logo

booky's Introduction

booky

This script creates bookmarks of a pdf from a simple text file. The tool pdftk can already do this infact internally I am using that tool itself. But pdftk requires a format which is too tedious to write. So I have written this script to enter bookmarks data in a simple format.

Dependencies

  • bash
  • python3
  • pdftk
  • dirname
  • basename
  • GNU sed (OSX users take note, you may have BSD sed. Install gsed instead)

Bookmark format

  • Every level starts with a { on a separate line.

  • Bookmarks have title with page number separated by comma.

  • Both title and page number should be on the same line.

  • All these are equivalent(i.e. the script is whitespace agnostic).

    title1, 1
    title1,             1
          title1     ,         1
    

    Example

    {
      Title1, 1
      Title2, 2
      {
        Subtitle1, 3
        Subtitle2, 4
        {
          SubSubtitle1, 5
          ...
        }
      }
    }
    

How To Use it?

  • First clone this repository and change your directory. Execute this in a terminal

    git clone https://github.com/SiddharthPant/booky.git
    cd booky
    
  • Now copy your pdf file to this directory

  • Create a new text file and write your bookmarks in the given format

  • Now your directory should contain 4 files: booky.sh, booky.py, your_pdf_file.pdf, your_text_file.txt

  • Write the following commands in the terminal

    ./booky.sh your_pdf_file.pdf your_text_file.txt
    

This creats a new pdf file your_pdf_file_new.pdf with your bookmarks.

This is going to work in *nix systems if instead you are on a Windows machine. Then first install python3 and pdftk just use the booky.py file in the repo to convert bkmrks.txt to pdftk compatible format

python3 booky.py < bkmrks.txt > output.txt

use the export command to generate a dumped data file.

pdftk C:\Users\Sid\Desktop\doc.pdf dump_data output C:\Users\Sid\Desktop\doc_data.txt

Remove the previous bookmarks from that file and insert content of output.txt instead using a simple copy paste. And then import that data back.

pdftk C:\Users\Sid\Desktop\doc.pdf update_info C:\Users\Sid\Desktop\doc_data.txt output C:\Users\Sid\Desktop\updated.pdf

If this does not update your bookmarks check that your pdftk version is greater than 1.45

booky's People

Contributors

jez avatar neariot avatar siddharthpant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.