Skip to main content

No project description provided

Project description

Add margins to PDFs

I have a tablet with a pen as ebook-reader. I like to make notes on the side of the PDFs when reading. Often there is not enough space on the margins.

I also like to draw diagrams and notes on the PDF. There is not enough space at the top and bottom. This leads to bad nodes and diagrams I can not decypher later.

This tool adds margins around the text. With this I have enough space for my thoughts and ideas and space to learn.

Features

  • Add marigins around the text
  • Fixed points as margin (e.g. 100)
  • Relative margin (e.g. left=0.3)

Before:

before

After:

after

## Installation

To install the `pdfmargins` package, use one of the following commands:

**CLI Only**:
If you only need the command-line interface, run:
```bash
pip3 install pdfmargins

CLI + Gradio App: If you want to include the Gradio app as well, use:

poetry install pdfmargins[app]

CLI + FastAPI API: To include the FastAPI API, run:

poetry install pdfmargins[api]

All Components (CLI, Gradio App, FastAPI API): If you want to install everything, use:

poetry add pdfmargins[all]

From within the project: If you cloned the project, run in the project root:

poetry install --with all

Verifying the Installation

To verify that the installation was successful, you can run the CLI command:

pdfmargins --help
pdfmargins-app --help # if installed
pdfmargins-api --help # if installed

This should display the help information for the command-line interface.

Usage

See scripts/example_usage.sh for a runnable script, that is also checked by the test-suite (e2e).

Common use-case is to run

python3 cli.py path/to/pdf-file.pdf

This creates a file called path/to/pdf-file.margins.pdf as output.

Or you can process a directory via

python3 cli.py path/to/dir/with/pdfs/

If there is a path/to/dir/with/pdfs/a.pdf there is now a path/to/dir/with/pdfs/a.margins.pdf as output.

If you want to know more, check

python3 cli.py --help

More information

If you nee to know details, check out pdfmargins/cli.py. It is pretty straightforward.

Limitations and next Steps

  • Output-directory, not only suffix for output-files
  • FastAPI server in Dockerfile to make installation easy (with Gradio UI)
  • Make it intallable (as python-package)
  • Add nix-package
  • Detect if 2 columns and be smart where to add margins (1 column, only right margin)
  • Add background, like raster, dots, etc.

Next steps

  • Make it installable
  • Push to pypi
  • Set into metadata that margins were added
  • One or two columns?

Thank you

This is just a wrapper around

  • pypdf

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfmargins-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

pdfmargins-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pdfmargins-0.1.0.tar.gz.

File metadata

  • Download URL: pdfmargins-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.1.96

File hashes

Hashes for pdfmargins-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d35eacf232b5c1b0d4097bf81d3f7e526a317bba17535cdd30660f4dc91991b1
MD5 773274fcf6927810b806b5a2c8350057
BLAKE2b-256 3777ad697d5247b2fea63fab35155751a624a133846ed742f922c3c93119300a

See more details on using hashes here.

File details

Details for the file pdfmargins-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pdfmargins-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.1.96

File hashes

Hashes for pdfmargins-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ece07484fdffd5c1d6de3bf73cbb47d92d0d150ad697831d4574d61195a4890
MD5 0e82104d55453e0e7b191090ff2cc233
BLAKE2b-256 ac9e0c874a6ec75e8c39d28296fd8fe6a06035770927c1f91f564b639d639784

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page