uploadkit-pdf adds PDF structure, security, and page-limit checks that plug into UploadPolicy.validators without modifying UploadKit Core. Do not use it to render, edit, merge, or OCR PDFs — put generic MIME/filename checks in Security.
Install
Shell
pip install uploadkit-pdf
Shell
uv add uploadkit-pdf
Shell
poetry add uploadkit-pdf
Quick start
upload.py
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
policy.py
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),
)
Async pipelines use default_async_pdf_validators and the AsyncPdf* validator classes on async_validators.
Inspect metadata
inspect.py
from uploadkit_pdf import inspect_pdf
meta = inspect_pdf(open("doc.pdf", "rb").read())
print(meta.page_count, meta.encrypted, meta.has_javascript)
Shared policy and error conventions: Common patterns. Full reference: uploadkit-pdf README.