pystitcher stitches your PDF files together, generating nice customizable bookmarks for you using a declarative markdown file as input

Overview

pystitcher

pystitcher stitches your PDF files together, generating nice customizable bookmarks for you using a declarative input in the form of a markdown file. It is written in pure python and uses PyPDF3 for reading and writing PDF files.

Description

pystitcher is a command line tool, with very few cli options:

usage: pystitcher [-h] [--version] [-v] [--cleanup | --no-cleanup] spine.md output.pdf

Stitch PDF files together

positional arguments:
  spine.md              Input markdown file
  output.pdf            Output PDF file

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose         log more things
  --cleanup, --no-cleanup
                        Delete temporary files (default: True)

Given this input:

existing_bookmarks: remove
title: Complete Guide to the Personal Data Protection Bill
author: Medianama
keywords: privacy, surveillance, personal data protection
subject: Personal Data Protection Bill
# A Complete Guide to the Personal Data Protection Bill

- [Cover](cover.pdf)

# The Bills

- [Personal Data Protection Bill, 2019](https://example.com/2019-bill.pdf)
- [Personal Data Protection Bill, 2018](https://example.com/2018-bill.pdf)

# Other key reading material

- [Srikrishna Committee Report](2.a.pdf)
- [Dvara Research's Personal Data Protection Bill](2.b.pdf)
- [MP Shashi Tharoor's Data Protection Bill](2.c.pdf)
- [MP Jay Panda's Data Protection Bill](2.d.pdf)
- [SaveOurPrivacy.in bill](2.e.pdf)
- [TRAI recommendations on privacy](2.f1.pdf)
- [Comments on TRAI recommendations on privacy](2.f2.pdf)

Will generate a PDF with proper bookmarks:

https://i.imgur.com/qPVpZGt.png

And the correct metadata:

Title:          Complete Guide to the Personal Data Protection Bill
Subject:        Personal Data Protection Bill
Keywords:       privacy, surveillance, personal data protection
Author:         Medianama
Creator:        pystitcher/1.0.0
Producer:       pystitcher/1.0.0

Configuration options can be specified with Meta data at the top of the file.

Option Notes
fit Default fit of the bookmark. Can be overwritten per bookmark See wiki for more details.
author PDF Author
keywords PDF Keywords
subject PDF Subject
title PDF Title. If left unspecified, first Heading (h1) in the document is used.
existing_bookmarks What to do with existing bookmarks in individual files. Options are keep, flatten, and remove. See docs for more details.

Additionally, PDF links specified in markdown can have attributes to alter the PDFs before merging. The below attribute will rotate the second PDF file by 90 degrees clockwise before merging:

[Part 1](1.pdf)
[Part 2](2.pdf){: rotate="90"}

And the below attribute will merge only pages 2 to 5, both inclusive, from the second PDF file:

[Part 1](1.pdf)
[Part 2](2.pdf){: start=2 end=5}

The list of available attributes are:

Attribute Notes
rotate Rotate the PDF. Valid values are 90, 180, 270
start Start page number for PDF page selection
end End page number for PDF page selection

Documentation

Additional documentation is maintained on the project wiki on GitHub.

Comments
  • Installation instructions: please update the readme front page

    Installation instructions: please update the readme front page

    Thanks for your work providing this tool. I ended up here looking for an alternative to python stapler.

    There's a lot of good and important stuff on the README.

    Please add one or two lines, at the top of the README with the most important stuff. How to install it.

    It might be obvious to you, a python developer, but not for a potential end user. Is it using "pip install xyz" ? Will it work with pipx ? Are there any "official" packages for Linux distro xyz ?

    Thanks in advance.

    opened by m040601 5
  • Added PDF rotation filter

    Added PDF rotation filter

    Closes #1

    Added a test input in book-rotate.md as well.

    I've been using pdftk a lot recently, but pystitcher definitely works better for me. Thanks for working on it!

    opened by Vonter 3
  • Python 3.9 required?

    Python 3.9 required?

    Thanks for the great code, it worked well for me putting books back together from chapters in Elsevier. The only issue I had was that it required using Python 3.9 at a minimum. I initially had an error under Python 3.7, complaining about line 56 of skeleton.py with reference to argparse.BooleanOptionalAction ; I lost the actual error message e.g see here for related.

    bug 
    opened by jd-foster 2
  • Add Tests

    Add Tests

    Starting Integration tests. Currently tracks:

    • [x] Sticher functionality by generating all test files
    • [x] Number of pages in these test files
    • [x] Bookmarks (title/destination page number)
    • [x] Bookmark level
    • [x] PDF metadata
    • [x] Attributes: Rotation
    • [x] Attributes: Page Selection
    • [x] Run CI tests on GitHub Actions
    • [x] Generate coverage reports

    Missing testcases:

    • [ ] Remote fetching (Will take this up later)
    • [x] Custom Title
    • [x] H2/H3 as bookmarks
    • [x] Disable cleanup and validate
    enhancement 
    opened by captn3m0 1
  • Specify Zoom level for links in markdown

    Specify Zoom level for links in markdown

    [Personal Data Protection Bill, 2019](1.a.pdf){: zoom=FitWidth}
    

    Other options:

        Inherit - Inherit zoom
        FitPage - Fit page width+height
        FitWidth - Fit page width
        FitHeight - Fit page height
        ##% - Zoom to ##% eg 50% = 50% zoom
    
    opened by captn3m0 0
  • Support external URLs to fetch PDF

    Support external URLs to fetch PDF

    # Title
    
    - [chapter 1](https://example.com/chapter1.pdf)
    - [chapter 2](https://example.com/chapter2.pdf)
    

    Download the PDFs, cache them and merge accordingly.

    opened by captn3m0 0
  • Auto Page numbering support

    Auto Page numbering support

    Want to be able to add page numbers to the generated PDF with font configuration. Use case - Printouts. Once this is done, easy to add a Table of Contents too. #6

    I was exploring and found this as one option: https://github.com/vlad-anisov/numbering2pdf/blob/main/numbering2pdf/numbering2pdf.py It uses reportlab to generate empty numbered PDFs and merges those pages with the existing pages one by one.

    Happy to work on this issue, if you suggest a preferred method (given your research) to implement this.

    enhancement 
    opened by lprsd 1
  • Fix current working directory hack

    Fix current working directory hack

    Currently, we switch our CWD to the markdown file directory, and don't reset it back. Playing around with chdir is bad and causes issues.

    Fix this to instead use paths relative from the markdown file directory.

    bug 
    opened by captn3m0 0
  • Render Markdown inline

    Render Markdown inline

    Within the markdown, provide a way to declare pages that get rendered as stand-alone pages as well.

    <!-- This only goes in bookmark-->
    # Cover
    
    ![Cover](cover.pdf)
    
    # Colophon
    
    ```
    # Hobbit
    ## There and back again
    ## By JRR Tolkein
    ```{: inline=1}
    
    ![Foreword](foreword.pdf)
    

    Renders a cover, a single page with the 3 lines as above, and then the foreword. So the colophon ends up linking to the middle text section

    opened by captn3m0 3
  • Fetch HTML online and render

    Fetch HTML online and render

    # Title
    
    - [chapter 1](https://example.com/chapter1.html)
    - [chapter 2](https://example.com/chapter2.html)
    

    Download the source HTML, run it through readability, then render as PDF and merge accordingly.

    opened by captn3m0 0
Releases(v1.0.4)
  • v1.0.4(Dec 31, 2021)

    Changed

    • Switched from html5 to html5lib as a dependency, since the former is unmaintained.

    Added

    • Python 3.10 support

    Removed

    • Python 3.6 support
    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jul 16, 2021)

    • Added tests and code coverage
    • PDFs can be directly fetched from Remote URLs
    • PDFs can be filtered to have start and end pages
    • Support for Python 3.6-3.8
    • Removed --cleanup argument, since that is default

    Published on PyPI: https://pypi.org/project/pystitcher/1.0.3/

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jul 16, 2021)

Table automatically extraction from PDF Document

PDF Table Extractor Table automatically extraction from PDF Document Our Icon 📌 Name : PDF Table Extractor 📌 Authors : Minku Koo Jiyong Park 📌 Deve

1 Jan 10, 2022
A bot for PDF for doing Many Things....

Telegram PDF Bot A Telegram bot that can: Compress, crop, decrypt, encrypt, merge, preview, rename, rotate, scale and split PDF files Compare text dif

Mr. Developer 60 Dec 27, 2022
OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched or copy-pasted. ocrmypdf

8k Jan 08, 2023
Camelot is a Python library that can help you extract tables from PDFs!

A Python library to extract tabular data from PDFs

1.8k Jan 03, 2023
Generate a preview image for a PDF.

PDF ➡️ Preview A simple tool to save me time on Illustrator. Generates a preview image for a PDF file. Useful for sneak peeks to academic publications

David Chuan-En Lin 51 Sep 22, 2022
Generate a bunch of malicious pdf files with phone-home functionality. Can be used with Burp Collaborator

Malicious PDF Generator ☠️ Generate ten different malicious pdf files with phone-home functionality. Can be used with Burp Collaborator. Used for pene

Jonas Lejon 1.9k Jan 01, 2023
PDFSanitizer - Renders possibly unsafe PDF files and outputs harmless PDF files

PDFSanitizer Renders possibly malicious PDF files and outputs harmless PDF files

9 Jan 30, 2022
Python script that split PDF files.

Automatic PDF Splitter This script can create new single-page PDFs files from multipaged PDFs. Requirements Python 3.0+ # Debian distros sudo apt-get

Leandro Padula 5 Apr 02, 2022
Auto Convert PDFs to png files in python

This python tool, which is an application of PyMuPDF module, could auto convert PDFs to png files

Bo-Yu 4 Dec 05, 2021
Merge multiple PDF files into one.

PDF Merger Merge multiple PDF files into one. Usage % python pdf_merger.py -h usage: pdf_merger.py [-h] [-o OUTPUT] [-f [FILES ...]] optional argumen

Duo Apps 6 Oct 03, 2022
A python library for extracting text from PDFs without losing the formatting of the PDF content.

Multilingual PDF to Text Install Package from Pypi Install it using pip. pip install multilingual-pdf2text The library uses Tesseract which can be ins

Shahrukh Khan 49 Nov 07, 2022
An application which enables the users to perform simple yet intriguing PDF operations

AstutePDF A repository containing the GUI for an application which enables the users to perform simple yet intriguing PDF operations. These include, M

Raghav S 5 Jan 22, 2022
pystitcher stitches your PDF files together, generating nice customizable bookmarks for you using a declarative markdown file as input

pystitcher pystitcher stitches your PDF files together, generating nice customizable bookmarks for you using a declarative input in the form of a mark

Nemo 387 Dec 10, 2022
Extract the table in the PDF,outputs the data similar to the json format

extract the table in the PDF,outputs the data similar to the json format

3 Nov 25, 2021
Scans pdfs for links written in plaintext and checks if they are active or returns an error code.

Scans pdfs for links written in plaintext and checks if they are active or returns an error code. It then generates a report of its findings. Extract references (pdf, url, doi, arxiv) and metadata fr

Marshal Miller 22 Nov 21, 2022
WeasyPrint is a smart solution helping web developers to create PDF documents.

WeasyPrint is a smart solution helping web developers to create PDF documents. It turns simple HTML pages into gorgeous statistical reports, invoices, tickets…

Kozea 5.4k Jan 08, 2023
Excalibur: A web interface to extract tabular data from PDFs

Excalibur: A web interface to extract tabular data from PDFs Excalibur is a web interface to extract tabular data from PDFs, written in Python 3! It i

1.2k Jan 04, 2023
Simple python tool created for downloading PDF.

PDFdownloader Usage Open PDF in full-screen mode Run scan.exe Enter how many pages you want to scan Focus PDF After scanning is done, run merge.exe En

5 Oct 27, 2021
Pdfencrypt is a tool to encrypt/lock PDFs

Pdfencrypt Pdfencrypt is a tool to encrypt/lock PDFs Installation $ apt update $ apt upgrade $ apt install git $ apt install python $ git clone https:

Anontemitayo 5 Nov 28, 2021
PyPDF2 is a pure-python PDF library capable of splitting, merging together, cropping, and transforming the pages of PDF files.

PyPDF2 is a pure-python PDF library capable of splitting, merging together, cropping, and transforming the pages of PDF files. It can also add custom data, viewing options, and passwords to PDF files

Matthew Stamy 5k Jan 04, 2023