Skip to main content

uploadkit-pdf

CI Coverage Python

PDF validators, policies, and metadata for UploadKit.

What problem does this solve?

PDF-specific structure, security, and page-limit checks that plug into UploadPolicy.validators without modifying UploadKit Core.

When to use it

Use when uploads must accept PDFs safely (no JavaScript, embeds, or encryption by default).

When not to use it

  • Do not render, edit, merge, or OCR PDFs here.
  • Do not put generic MIME/filename checks here (see uploadkit-security).

Installation

Requires Python 3.10+.

pip install uploadkit-pdf

Quick Start

from uploadkit import Uploader
from uploadkit_pdf import PdfPolicy

uploader = Uploader(PdfPolicy(max_size=5 * 1024 * 1024, max_pages=50), storage=my_storage)

Customize validators

from uploadkit import UploadPolicy
from uploadkit_pdf import default_pdf_validators, PdfPageLimitValidator

policy = UploadPolicy(
    allowed_extensions=frozenset({"pdf"}),
    allowed_mime_types=frozenset({"application/pdf"}),
    validators=default_pdf_validators(max_pages=20, exclude=PdfPageLimitValidator),
)

Inspect metadata

from uploadkit_pdf import inspect_pdf

meta = inspect_pdf(open("doc.pdf", "rb").read())
print(meta.page_count, meta.encrypted, meta.has_javascript)

Public API

Symbol Kind
PdfPolicy Public
PdfMetadata / inspect_pdf Public
PdfStructureValidator Public
PdfSecurityValidator Public
PdfPageLimitValidator Public
default_pdf_validators Public
AsyncPdfStructureValidator Public
AsyncPdfSecurityValidator Public
AsyncPdfPageLimitValidator Public
default_async_pdf_validators Public

Coverage

The coverage badge is a measured total from coverage report --include='src/*', not an aspirational 100%. CI enforces --fail-under=80.

Most of the gap is defensive and format-variant code in metadata.py (malformed PDFs, annotation/JS/embed edge cases). Validators and policies are largely covered. Unlike Core / framework adapters, this package does not claim 100% yet — fixtures for those branches are welcome.

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

Download files

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

Source Distribution

uploadkit_pdf-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

uploadkit_pdf-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uploadkit_pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for uploadkit_pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 94cd9a475a9216b2f6db1c4b34f8299e65c3f80c1f6efbb2c20caea797dbbb81
MD5 a90ae9bb9e735eb86259bd74803e93a3
BLAKE2b-256 32bf2fdd5045ceeb824fef815ab04c22cbd4a76f1fccec71752c644777b6c459

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uploadkit_pdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for uploadkit_pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b5c24666f2cf34ab8b5e4422963f01a89d0fcd662e664b6d70aacab89be9386
MD5 bf76c8c04e9497fc3a60fc8b61725b7b
BLAKE2b-256 cc0bdac996dbab7c0a667c569be2d93be2744ca5792085ae984388f1539afe9f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Supported by

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