Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Tc Lib Pdf Encrypt

Tc Lib Pdf Encrypt Laravel Package

tecnickcom/tc-lib-pdf-encrypt

PHP library that handles PDF encryption and decryption: password and certificate handling, key derivation, permission flags, and the encryption dictionary. Supports AES-128, AES-256 R5, and AES-256 R6; RC4 modes are deprecated and slow, so use AES for new documents.

View on GitHub
Deep Wiki
Context7

tc-lib-pdf-encrypt is a PHP library implementing the PDF format's encryption and decryption routines: password and certificate handling, key derivation, permission flags, and the encryption dictionary. It powers the TCPDF / tc-lib-pdf ecosystem (100M+ installs).

Supports AES-128, AES-256 R5, and AES-256 R6 / PDF 2.0. Legacy RC4 modes are deprecated and emit E_USER_DEPRECATED at runtime.

  • Multiple encryption modes selected explicitly via mode
  • Password and certificate-based access control
  • Permission flag and key derivation handling
  • AES throughput (~1000 MiB/s) versus PHP-based RC4 fallback
  • Part of the actively maintained TCPDF ecosystem
Frequently asked questions about Tc Lib Pdf Encrypt
How do I encrypt PDF files in Laravel with tc-lib-pdf-encrypt?
Use tc-lib-pdf-encrypt as a PHP service layer when your Laravel app must encrypt generated or stored PDFs before download, such as invoices, reports, or compliance documents. It handles PDF passwords, certificates, key derivation, permission flags, and encryption dictionaries. It is not a replacement for Laravel's built-in application encryption or database encryption.
How do I install tc-lib-pdf-encrypt via Composer?
Run composer require tecnickcom/tc-lib-pdf-encrypt to add it to your Laravel project. The package is framework-agnostic and uses the \Com\Tecnick\Pdf\Encrypt namespace, so you instantiate it manually or bind it in a Laravel service provider. There is no official Laravel facade or auto-discovered service provider to configure.
Does tc-lib-pdf-encrypt work with Laravel, dompdf, or spatie/pdf?
It can post-process PDFs produced by dompdf, spatie/pdf, Snappy, or other generators, because it operates on PDF data rather than rendering HTML. In Laravel, wrap it in a service class and call it after PDF generation, ideally in a queued job for larger files. It does not integrate with those libraries through Laravel facades, so you control the workflow.
Which encryption modes should I use, and why are RC4 modes deprecated?
Use AES-128 mode 2, AES-256 R5 mode 3, or AES-256 R6 mode 4 for new documents; mode 4 targets PDF 2.0. RC4-40 mode 0 and RC4-128 mode 1 are cryptographically broken and emit E_USER_DEPRECATED notices at runtime. Because mode 0 is the constructor default, always pass the mode explicitly in your configuration.
Can tc-lib-pdf-encrypt create PDF 2.0 compliant AES-256 encrypted documents?
Yes, mode 4 implements AES-256 R6 for PDF 2.0, while mode 3 provides AES-256 R5 and mode 2 provides AES-128 for compatible PDF versions. Choose the mode based on the PDF specification level your viewers and downstream systems support. For modern documents, avoid RC4 entirely.
How should I manage PDF passwords and encryption keys in a Laravel app?
Do not hard-code PDF passwords or keys in source control; load them from environment variables or a secrets manager and pass them into your encryption service. Use Laravel's encrypted configuration or a vault/KMS for production key storage, and rotate credentials with a documented process. The package handles PDF encryption mechanics, but your application remains responsible for key lifecycle and access control.
How do I test PDF encryption in Laravel?
Unit test your wrapper for correct passwords, wrong passwords, permission flags, unsupported or deprecated modes, and corrupt PDF inputs. Use Laravel's testing tools around your service class or queued job, and assert that encrypted output cannot be opened without the expected credentials. The package does not provide Laravel-specific factories or mocks for PDF encryption scenarios.
What are the production performance concerns for PDF encryption?
PDF encryption adds CPU and I/O latency, so run it asynchronously with Laravel Queues for large or high-volume PDF generation. Watch memory usage for very large files and set limits or streaming strategies in your job. Also monitor for E_USER_DEPRECATED notices so you do not ship RC4-encrypted PDFs accidentally.
What are alternatives to tc-lib-pdf-encrypt for Laravel PDF encryption?
Alternatives include Ghostscript with OpenSSL for low-level PDF encryption control, commercial libraries such as iText or PDFtk, and generating encrypted PDFs directly with TCPDF or tc-lib-pdf. Laravel's encrypt() helper is not a PDF encryption alternative because it protects application payloads, not PDF encryption dictionaries. Choose based on compliance requirements, PDF 2.0 needs, and support expectations.
Is tc-lib-pdf-encrypt actively maintained and safe for long-term use?
The provided README shows active GitHub Actions build and coverage badges, LGPL v3 licensing, and membership in the TCPDF ecosystem with 100M+ installs. Check Packagist and the repository release history for the latest activity before adopting it. For long-term production use, pin a version, review security advisories, and keep a fallback plan for PDF delivery.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log