Download the PHP package tomedio/pdf-watermark without Composer

On this page you can find all versions of the php package tomedio/pdf-watermark. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdf-watermark

PDF Watermark

A PHP library for adding text and image watermarks to PDF files using FPDI.

Features

Requirements

Installation

1. Install pdftk (optional but recommended)

pdftk is used as a workaround for handling compressed PDFs with versions higher than 1.4.

On Ubuntu/Debian:

On macOS (using Homebrew):

On Windows:

Download and install pdftk from the official website.

2. Install the library via Composer

Basic Usage

Adding a Text Watermark

Adding an Image Watermark

Note: If the image watermark exceeds the page size, it will be automatically scaled down proportionally to fit within the page boundaries while maintaining its aspect ratio.

Adding Multiple Watermarks

Page Selection

You can specify which pages to apply the watermark to:

Custom Temporary Directory

You can specify a custom temporary directory for processing files:

If no temporary directory is specified, the system's default temporary directory (sys_get_temp_dir()) will be used.

API Documentation

PdfWatermarkerFactory

The factory class provides methods to create watermarkers, watermark configurations, and watermarks.

Methods

PdfWatermarker

The main class for applying watermarks to PDF files.

Methods

AbstractWatermark

The base class for all watermarks.

Constants

TextWatermarkConfig

Configuration class for text watermarks.

Constants

Methods

ImageWatermarkConfig

Configuration class for image watermarks.

Methods

PDF Version Compatibility

This library uses FPDI to process PDF files, which has a limitation with compressed PDFs that have versions higher than 1.4. To overcome this limitation, the library implements a workaround using pdftk:

  1. When a PDF cannot be processed directly with FPDI (typically due to being a compressed PDF with version > 1.4), the library automatically falls back to using pdftk.
  2. pdftk is used to uncompress the PDF, making it compatible with FPDI.
  3. The watermarks are applied to the uncompressed PDF using FPDI.
  4. The resulting PDF is recompressed using pdftk.

This approach allows the library to work with a wide range of PDF files, including those with higher versions, without requiring the paid version of FPDI.

Advanced Usage

Using Page Number Placeholder

You can include the page number in your text watermark using the %d placeholder:

Setting Font Name and Style

Font Name

You can set the font name for text watermarks using predefined constants or custom font names:

Font Style

You can set the font style for text watermarks using constants:

You can also combine multiple font styles using the bitwise OR operator:

Setting Explicit Dimensions for Image Watermarks

Instead of scaling, you can set explicit dimensions for image watermarks:

Note: If the resulting image dimensions exceed the page size, the image will be automatically scaled down proportionally to fit within the page boundaries while maintaining its aspect ratio.

Development

Available Makefile Commands

The library includes a Makefile with several useful commands:

License

This library is licensed under the MIT License.


All versions of pdf-watermark with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
symfony/process Version ^6.0
setasign/fpdi-tcpdf Version ^2.3
tecnickcom/tcpdf Version ^6.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tomedio/pdf-watermark contains the following files

Loading the files please wait ...