Code Monkey home page Code Monkey logo

pdf-watermark's Introduction

PDF Watermark

PDF Watermark provides functionality for applying watermarks to PDF files. This library exclusively utilizes Python and Ghostscript.

Requirements

Linux

Debian

sudo apt-get update
sudo apt-get install ghostscript
gs --version

RedHat

sudo yum install ghostscript
gs --version

Windows

  • Install GhostScript
  • After installation, you need to set up the PATH environment variable to include the directory where Ghostscript is installed.

MacOS

brew install ghostscript
gs --version

Install

pip install git+https://github.com/Kesha123/pdf-watermark.git@v<latest-release-tag-number>

Use

Sync

from pdf_watermark.watermark import File

pdf_file_path = "/path/to/file.pdf"

file = File(file_path=pdf_file_path)
file.watermarking()

Async

import asyncio
from pdf_watermark.watermark import File

pdf_file_path = "/path/to/file.pdf"

file = File(file_path=pdf_file_path)
asyncio.run(file.watermarking_async())

#### Or ####

async def test_async() -> None:
    file = File(file_path=pdf_file_path)
    await file.watermarking_async()

def main() -> None:
    loop = asyncio.get_event_loop()
    loop.run_until_complete(asyncio.gather(
        test_async()
    ))
    loop.close()

if __name__ == '__main__':
    main()

File

Argument Type Default value Description
file_path str None Path to pdf file you want to apply watermark for

File.watermarking() & File.watermarking_async()

Argument Type Default value Description
transparency float 0.5 Watermark transparency level
text str 'TOP SECRET' Watermark text
font str Helvetica-Bold Watermark font
output_file str None Output file name

Ouput

.
├── test.pdf
└── wm_test.pdf

Calculations

X Axis Positioning

Main1

pdf-watermark's People

Contributors

kesha123 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.