PHPackages                             devraeph/laravel-pdf-protect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. devraeph/laravel-pdf-protect

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

devraeph/laravel-pdf-protect
============================

Password protect PDF in Laravel

3.3.0(1mo ago)675.8k↓43.3%2MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI failing

Since Jan 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/DevRaeph/laravel-pdf-protect)[ Packagist](https://packagist.org/packages/devraeph/laravel-pdf-protect)[ Docs](https://github.com/devraeph/laravel-pdf-protect)[ RSS](/packages/devraeph-laravel-pdf-protect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (12)Used By (0)

Laravel PDF Protect
===================

[](#laravel-pdf-protect)

[![Latest Version on Packagist](https://camo.githubusercontent.com/81c1a683da692e71b576915334c63fe2fabf73ed90e35e121b9a9ad99814c84f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657672616570682f6c61726176656c2d7064662d70726f746563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/devraeph/laravel-pdf-protect)[![Check & fix styling](https://github.com/DevRaeph/laravel-pdf-protect/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/DevRaeph/laravel-pdf-protect/actions/workflows/php-cs-fixer.yml)[![run-tests](https://github.com/DevRaeph/laravel-pdf-protect/actions/workflows/run-tests.yml/badge.svg)](https://github.com/DevRaeph/laravel-pdf-protect/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/8a3c7e710088a15834ee532426fc0bdd68855e74920b436646db4030814276ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657672616570682f6c61726176656c2d7064662d70726f746563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/devraeph/laravel-pdf-protect)[![Issues](https://camo.githubusercontent.com/17813c747392200aa3302442f2c3da106be1b78df210a7d375e107ca6f43e4b3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f44657652616570682f6c61726176656c2d7064662d70726f74656374)](https://github.com/DevRaeph/laravel-pdf-protect/issues)

Simple wrapper package around MPDF's `setProtection` method that allows you to set password on PDF files.

### Version Compatibilities

[](#version-compatibilities)

Laravel PDF ProtectPHP VersionLaravel 7.\*Laravel 8.\*Laravel 9.\*Laravel 10.\*Laravel 11.\*Laravel 12.\*Laravel 13.\*`3.x``>=8.1` - `=7.4` - `=7.4` - `=7.4` - `setOutputFile('pdf/encrypted-123.pdf','local|s3|...')
    ->setPassword("1234")
    ->secure();
```

#### OLD Version 2.x

[](#old-version-2x)

In version 2.x the usage is more common to use and simplified.

```
$inputFile = storage_path('pdf/LetterFormat.pdf');
$outputFile = storage_path('pdf/encrypted-123.pdf');

PDFPasswordProtect::setInputFile($inputFile)
    ->setOutputFile($outputFile)
    ->setPassword("1234")
    ->secure();
```

You can also add the optional method 'setOwnerPassword':

```
...

PDFPasswordProtect::setInputFile($inputFile)
    ...
    ->setOwnerPassword("1234")
    ->secure();
```

Alternative new options are: 'setMode' and 'setFormat'.

> setFormat is default 'auto' and will now detect the document format. Before v2.x it was set to 'A4'.

```
PDFPasswordProtect::setInputFile($inputFile)
...
->setMode("en_GB") //You can set different language values. Default is utf-8
->setFormat("auto|A4|Letter") //You can set a Document format. Default is auto.
->secure();
```

#### Version 1.x

[](#version-1x)

You can also use the old version from v1.x in v2.x, but it is deprecated and will no longer get any updates.

```
PdfPasswordProtect::encrypt(storage_path('pdf/document.pdf'),storage_path('pdf/'.'encrypted-documented.pdf'),'janedoe');
```

Encrypt method in detail

- $inputFile and $outputFile has to be a path like `storage_path("pdf/document.pdf")`

```
PdfPasswordProtect::encrypt($inputFile,$outputFile,$password)
```

The final file will be located in `storage/pdf` as `encrypted-document.pdf`

### Testing

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Owen Jubilant](https://github.com/Owen-oj) (creator of the original package) - [PDF Password Protect](https://github.com/Owen-oj/pdf-password-protect)
- [DevRaeph](https://github.com/devraeph) (refactored classes to comply with PSR-4)

Sponsor
-------

[](#sponsor)

[![ko-fi](https://camo.githubusercontent.com/201ef269611db7eb6b5d08e9f756ab8980df3014b64492770bdf13a6ed924641/68747470733a2f2f6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/A0A3E29FS)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 93.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~169 days

Recently: every ~229 days

Total

10

Last Release

57d ago

Major Versions

1.1.3 → 2.0.02023-09-17

2.0.0 → 3.0.02024-05-21

PHP version history (5 changes)1.0.0PHP ^7.4|^8.0

1.1.2PHP ^7.4|^8.0|^8.1

2.0.0PHP ^7.4|^8.0|^8.1|^8.2

3.0.0PHP ^8.1|^8.2|^8.3

3.2.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58560217?v=4)[Raphael Planer](/maintainers/devraeph)[@DevRaeph](https://github.com/DevRaeph)

---

Top Contributors

[![DevRaeph](https://avatars.githubusercontent.com/u/58560217?v=4)](https://github.com/DevRaeph "DevRaeph (44 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")

---

Tags

pdfpasswordprotectDevRaeph

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/devraeph-laravel-pdf-protect/health.svg)

```
[![Health](https://phpackages.com/badges/devraeph-laravel-pdf-protect/health.svg)](https://phpackages.com/packages/devraeph-laravel-pdf-protect)
```

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[themsaid/ibis

Markdown to PDF book builder

2.0k2.0k](/packages/themsaid-ibis)[setasign/fpdi-protection

A FPDI compatible version of the FPDF\_Protection script.

324.3M2](/packages/setasign-fpdi-protection)[codersfree/laravel-greenter

Laravel package for Greenter

261.4k](/packages/codersfree-laravel-greenter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
