PHP code example of devraeph / laravel-pdf-protect

1. Go to this page and download the library: Download devraeph/laravel-pdf-protect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

devraeph / laravel-pdf-protect example snippets


PDFPasswordProtect::setInputFile('pdf/LetterFormat.pdf','local|s3|...')
    ->setOutputFile('pdf/encrypted-123.pdf','local|s3|...')
    ->setPassword("1234")
    ->secure();

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

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

...

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

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();

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

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