pystitcher/README.rst

144 lines
6.2 KiB
ReStructuredText
Raw Normal View History

2021-05-26 12:37:57 +00:00
==========
pystitcher
==========
2022-01-26 05:24:23 +00:00
.. image:: https://img.shields.io/pypi/v/pystitcher
:target: https://pypi.org/project/pystitcher/
:alt: PyPI Version
.. image:: https://img.shields.io/pypi/l/pystitcher
:target: LICENSE.txt
:alt: Repository License
.. image:: https://img.shields.io/github/checks-status/captn3m0/pystitcher/main
:target: https://github.com/captn3m0/pystitcher/actions?query=branch%3Amain
:alt: GitHub branch checks status
.. image:: https://img.shields.io/codecov/c/gh/captn3m0/pystitcher
:target: https://app.codecov.io/gh/captn3m0/pystitcher/
:alt: Codecov
|
2021-05-28 16:08:53 +00:00
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 <https://pypi.org/project/PyPDF3/>`_ for reading and writing PDF files.
2021-05-26 12:37:57 +00:00
Installation
============
You can install it easily using `pipx <https://pypa.github.io/pipx/>`_::
pipx install pystitcher
The Wiki has `Alternative Installation Instructions <https://github.com/captn3m0/pystitcher/wiki/Installation>`_.
2021-05-26 12:37:57 +00:00
Description
===========
2021-05-28 19:04:36 +00:00
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)
2021-05-26 12:37:57 +00:00
Given this input::
2021-05-28 19:10:46 +00:00
existing_bookmarks: remove
2021-05-28 16:08:53 +00:00
title: Complete Guide to the Personal Data Protection Bill
author: Medianama
keywords: privacy, surveillance, personal data protection
subject: Personal Data Protection Bill
2021-05-26 12:37:57 +00:00
# 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)
2021-05-26 12:37:57 +00:00
# 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:
2021-05-26 15:02:42 +00:00
.. image:: https://i.imgur.com/qPVpZGt.png
2021-05-26 12:37:57 +00:00
2021-05-28 16:08:53 +00:00
And the correct metadata::
2021-05-28 12:29:35 +00:00
2021-05-28 16:08:53 +00:00
Title: Complete Guide to the Personal Data Protection Bill
Subject: Personal Data Protection Bill
Keywords: privacy, surveillance, personal data protection
Author: Medianama
2021-05-28 18:23:04 +00:00
Creator: pystitcher/1.0.0
Producer: pystitcher/1.0.0
2021-05-28 12:29:35 +00:00
2021-05-28 17:42:48 +00:00
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 |
2021-05-28 18:23:04 +00:00
| | See `wiki <https://github.com/captn3m0/pystitcher/wiki/Zoom-Levels>`_ |
2021-05-28 17:42:48 +00:00
| | 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 |
2021-05-28 18:23:04 +00:00
| | `docs <https://github.com/captn3m0/pystitcher/wiki/Existing-Bookmarks>`_ |
2021-05-28 17:42:48 +00:00
| | for more details. |
+---------------------+--------------------------------------------------------------------------+
2021-06-26 12:27:51 +00:00
2021-06-26 17:26:38 +00:00
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::
2021-06-26 12:27:51 +00:00
[Part 1](1.pdf)
[Part 2](2.pdf){: rotate="90"}
2021-06-26 17:26:38 +00:00
And the below attribute will merge only pages 2 to 5, both inclusive, from the second PDF file::
2021-06-26 12:27:51 +00:00
2021-06-26 17:26:38 +00:00
[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 |
+---------------------+-----------------------------------------------+
2021-06-26 17:26:38 +00:00
| start | Start page number for PDF page selection |
+---------------------+-----------------------------------------------+
2021-06-26 17:26:38 +00:00
| end | End page number for PDF page selection |
+---------------------+-----------------------------------------------+
2021-06-26 12:35:24 +00:00
Documentation
=============
Additional documentation is maintained on the `project wiki <https://github.com/captn3m0/pystitcher/wiki>`_ on GitHub.