Join documents together using PHP

PHP SDK to combine several documents and export the result to almost any office format

Use PHP library to merge Word, PDF, Web documents via REST API. Easily combine two or more documents into a single file using PHP.

View code snippet

Combine Word, PDF, Web documents using PHP REST API

Easily merge documents together in various formats in PHP code. This PHP library is designed to combine Word, PDF, Web documents into a single file using the REST API, i.e. by passing HTTPS calls over the Internet.

This is a professional Cloud-native document-merging solution that provides PHP programmers with both great development flexibility and powerful features. Joining files together is often used when it is necessary to create a set of documents of the same structure, each of which contains unique data. By merging documents, you can automate your digital workflows and offload some routine parts of the process to fast and efficient document-processing PHP software.

Merge multiple files into one in PHP

You may need to combine documents together in many cases. For example, you may want to combine multiple files together before printing or archiving.

Merging documents together can be part of a whole integrated technology for creating documents from disparate data sources. Such tasks involve the use of a full-featured file format manipulation PHP library that will process sets of files and merge them together in the shortest possible time, creating a compact and accurate output.

To merge documents in PHP, you need at least two source files. For a quick start, check out the PHP code example below.

Upload files you want to combine
Run code
Upload files you want to combine
Select the target format from the list
use Aspose\Words\WordsApi;

$wordsApi = new WordsApi('####-####-####-####-####', '##################');

$document = "Input1.docx";

// Load a document to append from the Cloud storage.
$mergeDocument = new DocumentEntry(array(
    "file_reference" => FileReference::fromRemoteFilePath("Input2.docx"),
    "import_format_mode" => "KeepSourceFormatting",
));
$documentEntries = [ $mergeDocument, ];
$documentList = new DocumentEntryList(array(
    "document_entries" => $documentEntries,
));
$appendDocumentOnline = new AppendDocumentOnlineRequest(
    $document, $documentList, NULL, NULL, NULL, NULL, NULL, NULL
);
$wordsApi->appendDocumentOnline($appendDocumentOnline);
Run code
  
Copy PHP code to the clipboard

How to use PHP to merge PDF, Word, Web documents and many other file formats

  1. Install PHP SDK and add the reference (import the library) to your PHP project.
  2. Open the source file in PHP using REST API.
  3. Load a document to append from the Cloud storage.
  4. Call the appendDocumentOnline() method, passing the output filename with the required extension.
  5. Get the the combined result as a single file.

PHP library to merge files

Install 'Aspose.Words Cloud SDK for PHP' from Packagist repository. Just run composer require aspose-cloud/aspose-words-cloud to install the SDK, then use require_once('vendor/autoload.php'); to import it into your project.

As an alternative, you can manually clone Aspose.Words Cloud SDK for PHP source code from GitHub. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.

System Requirements

PHP 7.1 or newer

Refer to the Repository Documentation to see more details.

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.