Skip to main content

A library for processing PDFs with OCR and masking sensitive information

Project description

PDF Masking Library

pdf-masking-library is a Python library designed to process PDF files by masking sensitive information using Optical Character Recognition (OCR). It supports masking predefined patterns such as Aadhaar numbers, PAN numbers, and custom patterns provided by the user.

A Simple Example

import base64
from pdf_masking_library import process_pdf

base64_pdf_input = "Your base64 here"
custom_pattern = [r"\b\d{2}\b"]

base64_pdf_output = process_pdf(base64_pdf_input, custom_pattern=custom_pattern)

# Save the masked PDF to a file
with open("masked_output.pdf", "wb") as output_file:
    output_file.write(base64.b64decode(base64_pdf_output))

Masking Information

The library automatically detects and masks the following sensitive information:

  • Aadhaar Numbers: 12-digit Indian identification numbers.
  • PAN Numbers: 10-character alphanumeric Permanent Account Numbers.
  • Custom Patterns: User-defined patterns using regular expressions.

When providing a custom pattern, use the custom_pattern parameter, as shown above.

Command-Line Interface (CLI)

The library includes a CLI tool for easy integration into scripts and workflows.

python -m pdf_masking_library input.pdf output.pdf --custom-pattern "\b\d{2}\b"

  • Mask Aadhaar and PAN Numbers (Default Behavior):

    python -m pdf_masking_library input.pdf output.pdf

If you do not provide a custom pattern, the library will automatically mask Aadhaar numbers and PAN numbers in the PDF.

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

pdf_masking_library-0.1.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_masking_library-0.1.4-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file pdf_masking_library-0.1.4.tar.gz.

File metadata

  • Download URL: pdf_masking_library-0.1.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for pdf_masking_library-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4ffbcbf649fa4fc1ee9f403561c03d18d2f72ded0e7f3e449b18cb3872d6c206
MD5 8b3002e967155724aa64831583c3751f
BLAKE2b-256 ce0f4bb85045f89c85712ce5408024e4ceb6559a1330f3bd8f787c646620b1b7

See more details on using hashes here.

File details

Details for the file pdf_masking_library-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_masking_library-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1c9ec37c5130f4137c17c2655701f1a80c12259f1ccf8cd3f0e3925d84106ebb
MD5 1276895302ee02efb8f009d84c5343d4
BLAKE2b-256 e308fe09350f50212e4c3f20d1a9152fee0484f6ea2ba4e1d277f99e5fcc8042

See more details on using hashes here.

Supported by

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