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.1.tar.gz (12.0 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.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uploadkit_pdf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 25cd159b22fa2ef37d3a9967dadc248dc7c7cad6ce00ba328b639207f515f4a5
MD5 f83ffdf0941a964d544597e32d00d7ae
BLAKE2b-256 4090dcec12cf34431426df1362c598dfc8845f6d0602529008505ecea8fafc2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uploadkit_pdf-0.1.1-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.14

File hashes

Hashes for uploadkit_pdf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe29eab3a17c65f5d587c3d8de09417d377c7ab6c380a07f6f963da1d38bdfaa
MD5 48a9c0c6468befa84f9c8e3c8fedac72
BLAKE2b-256 e6fdef5ed86036e9dc43401f204a20be89dfdb6e217c790177d0e76d26e2afce

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

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