Skip to main content

Simple tool to mark/add highlights to pdf documents.

Project description

CI

pdfmarker

Simple PDF marker written in Python. Based on the PyMuPDF/fitz library.

Features

Highlight text in pdf files using this very simple utility. The very unclear and untyped PyMuPDF API motivated me to write this package.

Installation

pip install pdfmarker

Usage

Using pdfmarker takes 3 simple steps:

  1. Read a file into a Marker object using:
    • Marker.from_disk(): A file stored on disk.
    • Marker.from_bytes(): A bytes object in memory. E.g. a downloaded pdf.
  2. Add words/phrases to be highlighted.
    • marker.add(Highlight("Example"))
    • Supports default and custom colors.
    • Supports subwords.
    • Supports grouping. Useful when highlighting topics/themes with different colors in one document. This adds a legend to the top of each page.
  3. Mark & save using:
    • Marker.to_disk(): Write to disk.
    • Marker.to_bytes(): Returns the modified pdf as bytes object.
from pdfmarker import Colors, Highlight, Marker

marker = Marker.from_disk(path="tests/data/test.pdf")

marker.add(
    [Highlight("Sample", group="test"), Highlight("con", group="test", color=Colors.red, subwords=True)]
)

marker.add(Highlight("simple", group="max"))

marker.to_disk("example_marked.pdf")

To-do

  1. Add codecov

Contributing

Contributions are welcome! If you would like to contribute to pdfmarker, please follow these steps:

  1. Fork the repository on GitHub.
  2. Clone your forked repository to your local machine.
  3. Create a new branch for your changes.
  4. Make your changes and commit them with descriptive commit messages.
  5. Push your changes to your forked repository.
  6. Submit a pull request to the main repository.

Please ensure that your code follows the project's coding conventions and includes appropriate tests. Also, provide a clear description of the changes you have made in your pull request.

Thank you for contributing to pdfmarker!

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

pdfmarker-0.1.2.tar.gz (15.9 kB view hashes)

Uploaded Source

Built Distribution

pdfmarker-0.1.2-py3-none-any.whl (16.9 kB view hashes)

Uploaded Python 3

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