Download the PHP package johind/collate without Composer

On this page you can find all versions of the php package johind/collate. 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 collate

Collate — PDF manipulation for Laravel

Tests Packagist License Latest Stable Version Total Downloads

Collate is a Laravel package that provides a fluent API for manipulating PDFs.

Powered by qpdf, it supports common operations including merging, splitting, extracting pages, watermarking, encryption, editing metadata, and web optimisation.

Requirements

Installation

Install the package via Composer:

Then run the install command to publish the configuration and verify that qpdf is available:

You may also publish the config file manually:

Configuration

The published config file (config/collate.php) contains three options:

Quick Examples

Capabilities

Category Features
Getting started raw content
Page operations rotate
Overlays & watermarks overlay & underlay
Security restrict permissions
Metadata & inspection page count
Optimization optimize
Advanced error handling

Getting Started

Use open() to manipulate an existing PDF, or merge() to combine multiple files. Both return a fluent builder you can chain before saving or returning a response.

Opening a PDF

Files are resolved from your configured filesystem disk. You can also pass UploadedFile instances:

Choosing a Disk

Switch disks on the fly using fromDisk():

Save to Disk

Download

Return a download response from a controller. The filename defaults to document.pdf when omitted:

Stream Inline

Display the PDF inline in the browser. The filename defaults to document.pdf when omitted:

Raw Content

Get the raw PDF binary contents as a string. Useful for APIs, email attachments, or custom storage:

Returning from Controllers

PendingCollate implements Laravel's Responsable interface, so you can return it directly from a controller. By default, the PDF is displayed in the browser:

Page Operations

Merging PDFs

Combine multiple files into a single document:

For more control, pass a closure to select specific pages:

Adding Pages

Append entire files or specific pages to an existing document:

[!IMPORTANT] The range parameter cannot be used when passing an array of files. Chain multiple addPages() calls instead.

Removing Pages

Remove specific pages from a document:

Extracting Pages

Keep only the pages you need using onlyPages():

[!WARNING] onlyPages() and removePages() are mutually exclusive and neither can be called more than once — calling both, or calling either twice, on the same instance will throw a BadMethodCallException.

Page Range Syntax

Anywhere a page range string is accepted (onlyPages(), addPages(), removePages(), rotate()), you can use qpdf range syntax:

Expression Meaning
1-5 Pages 1 through 5
1,3,5 Pages 1, 3, and 5
1-3,7-9 Pages 1–3 and 7–9
z Last page
1-z All pages
1-z:odd Odd pages only
1-z:even Even pages only

Splitting a PDF

Split every page into its own file. The path supports a {page} placeholder for the page number:

[!IMPORTANT] Always include {page} in your path. Without it, every page will be written to the same destination, with each one overwriting the last.

All operations (page selection, rotation, overlays, etc.) are applied before splitting, so you can chain them freely:

Rotating Pages

Rotate pages by 0, 90, 180, or 270 degrees:

Overlays & Underlays

Add watermarks, letterheads, or backgrounds. Both methods accept a disk path or an UploadedFile instance:

Encryption & Decryption

Encrypt a document with a password:

For more control, use separate user and owner passwords and restrict specific permissions. Note that restrict() must be called after encrypt():

The following permissions can be passed to restrict():

Permission Effect
print Disallow printing
modify Disallow modifications
extract Disallow text and image extraction
annotate Disallow adding annotations
assemble Disallow page assembly (inserting, rotating, etc.)
print-highres Disallow high-resolution printing
form Disallow filling in form fields
modify-other Disallow all other modifications

Decrypt a password-protected document:

Re-encrypt with a new password in one step:

Metadata & Inspection

Reading Metadata

Use inspect() (a semantic alias for open()) for read-only operations like reading metadata or counting pages:

pageCount() and metadata() are also available on the builder if you need them mid-chain, even after a merge():

Writing Metadata

Set metadata on the output document:

[!NOTE] When you pass a PdfMetadata instance, you can override any named fields in the same call except title. To change the title, call withMetadata() again with title: as shown above.

Stripping Metadata

Remove all metadata from the output document:

[!WARNING] withoutMetadata() and withMetadata() are mutually exclusive. Calling both on the same instance will throw a BadMethodCallException.

Inspecting a PDF

Use inspect() to query properties of an existing document without modifying it:

inspect() is a semantic alias for open(). You can also call these methods mid-chain on any builder.

pageSize() returns the underlying page box dimensions in PDF points, not a rotation-adjusted display size. The returned PageSize object includes conversion helpers:

Optimization

Flattening

Flatten form fields and annotations into the page content:

Linearization

Optimize a PDF for fast web viewing (progressive loading):

File Size Optimization

Reduce file size by removing redundant data and optimizing internal structures:

When optimize() is combined with linearize(), qpdf's linearization requirements take precedence over object stream generation. Other optimization steps still apply.

Advanced

Conditional Operations

PendingCollate uses the Conditionable trait, so you can conditionally apply operations:

Extending with Macros

Register macros on PendingCollate to add chainable operations:

Register macros on Collate to add new entry points:

Debugging the qpdf Command

Use dump() and dd() to inspect the underlying qpdf command that Collate builds, without executing it:

[!WARNING] The output may contain sensitive data such as file paths and passwords.

Error Handling

All exceptions thrown by Collate extend Johind\Collate\Exceptions\CollateException, which itself extends PHP's RuntimeException.

When a qpdf command fails, a Johind\Collate\Exceptions\ProcessFailedException is thrown, exposing the exitCode and errorOutput from the underlying process. Invalid arguments (bad page ranges, unsupported rotation degrees, etc.) throw standard InvalidArgumentException or BadMethodCallException instances.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for your help in keeping Collate stable! I am primarily looking for contributions that focus on fixing bugs, improving error handling or enhancing performance. If you have an idea for a new feature, please open an issue to discuss it with me first, since I want to ensure that the scope of the package remains focused. Please note that I do not provide monetary compensation for contributions.

Security

If you discover a security vulnerability, please send an email rather than opening a GitHub issue.

License

The MIT License (MIT). Please see License File for more information.


All versions of collate with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4 || ^8.5
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
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 johind/collate contains the following files

Loading the files please wait ...