How to Encrypt & Watermark a PHP PDF

The PHP language lets you dynamically create PDF files that you can display and distribute on your website. Watermarking and encrypting a PHP PDF protects the file from copyright infringement, and allows only authorized viewers to see the PDF's contents. Use the PHP encryption and watermark plugin for a PDF to enhance your PDF creation process and protect the files from unauthorized users.

Instructions

    • 1

      Right-click the PHP file you want to use to create the PDF file. Click "Open With" and select your preferred PHP editor. Add the plugin files to the top of the page by copying and pasting the following code to the source code:

      require_once("Stamper/SetaPDF_Stamper.php");

    • 2

      Set up a watermark on the file. The following code creates a "My File" watermark on the file:

      $watermark = new SetaPDF_TextStamp();
      $stamper =& SetaPDF_Stamper::factory('I');
      $watermark ->setText("My File");
      $stamper->setStamp($watermark);
      $stamper->stampit();

    • 3

      Use the following code to encrypt the file:

      exec(“C:\EncryptPDF.exe -i c:\original.pdf -o C:\output.pdf -w owner -u user -e pass”);

      Replace "user" and "pass" with your own information. Your recipients need this information to access the file. Replace "output.pdf" with the name you want to give the file, and replace "original.pdf" with the name of the watermarked file.

    • 4

      Save the changes and open the file in your browser to test the new settings.

Related Searches:

References

Comments

Related Ads

Featured