Watermark
Watermark PDF files - stamp a PDF with the text, image, or another fileExplore the product
The ConvertAPI PHP library provides an all-in-one, developer-friendly toolkit for high-quality document conversion and manipulation. With support for hundreds of file formats, you can quickly transform PDFs, Office documents, images, and more. Whether you need to merge files, compress large documents, extract data, or apply redactions, this flexible library seamlessly integrates with your PHP environment.
It is easy to start converting documents using PHP in a few simple steps:
Sign up for free and receive 250 conversions to try and evaluate our service. You will receive a free trial with no credit card required upon registration!
On your account dashboard you will access an intuitive UI tool that allows you to set up the conversion, adjust the parameters, and try the conversion online with zero code.
Once you have set up the conversion parameters and are happy with the conversion results, you will receive an auto-generated PHP code snippet with your custom parameters!
High-performance and unbeatable accuracy document converter suite with support for over 300+ conversion.
Generate dynamic DOCX and PDF documents like invoices, contracts, reports, on the fly.
Protect, redact, compare, watermark, flatten, compress and modify your documents using ConvertAPI PHP SDK.
Protect and unprotect PDFs, MS Office Powerpoint and MS Office Word documents.
Built to scale with your business, whether you're handling a few conversions or thousands.
Reduce file sizes without losing quality. Archive converters are designed to handle over 100 different file formats.
Configure your file conversion directly online using our intuitive interface. Select the desired parameters and see the results in real-time. Once you're satisfied, we’ll automatically generate the PHP code for you, making integration into your project effortless. No need to start from scratch - just copy the code and implement it seamlessly into your PHP application!
Get started now
Converting documents using our PHP SDK has never been simpler. By reducing complex tasks to just a few lines of code, our library saves valuable time and effort, ensuring secure, reliable, and efficient document processing within your PHP environment. From straightforward conversions to advanced document manipulations, the ConvertAPI PHP library streamlines the entire process for maximum efficiency. To get started, install the ConvertAPI PHP package using Composer:
composer require convertapi/convertapi-php
Or install it manually using ConvertApi autoloader (curl and json extensions are required):
require_once('/path/to/convertapi-php/lib/ConvertApi/autoload.php');
With the ConvertAPI PHP Client, you can configure and perform document conversions with just a few lines of code. Fine-tune your PDF-to-JPG transformation by adjusting properties such as page ranges, cropping parameters, image resolution, width, quality, and color space settings.
Under the hood, the library manages all the complexity, freeing you to integrate powerful, customizable document conversions directly into your PHP application’s workflow. Here’s an example of converting a PDF into a series of JPG images with detailed parameters:
This example demonstrates how to execute a document conversion directly within memory using streams. This bypasses the need to write input or output files to disk.
Use case is efficient for applications that handle files dynamically without intermediate storage.
# set your api token
ConvertApi::setApiCredentials(getenv('CONVERT_API_TOKEN'));
# Example of converting content stream to PDF
# https://www.convertapi.com/txt-to-pdf
$dir = sys_get_temp_dir();
$content = 'Test file body';
$stream = fopen('php://memory', 'rwb');
fwrite($stream, $content);
rewind($stream);
$upload = new \ConvertApi\FileUpload($stream, 'test.txt');
$result = ConvertApi::convert('pdf', ['File' => $upload]);
$savedFiles = $result->saveFiles($dir);
echo "The PDF saved to:\n";
print_r($savedFiles);
The following example illustrates how to convert a web page to a PDF by providing its URL. This is beneficial for archiving web content or generating PDF versions of web pages.
# set your api token
ConvertApi::setApiCredentials(getenv('API_TOKEN'));
# Example of converting Web Page URL to PDF file
# https://www.convertapi.com/web-to-pdf
$fromFormat = 'web';
$conversionTimeout = 180;
$dir = sys_get_temp_dir();
$result = ConvertApi::convert(
'pdf',
[
'Url' => 'https://en.wikipedia.org/wiki/Data_conversion',
'FileName' => 'web-example'
],
$fromFormat,
$conversionTimeout
);
$savedFiles = $result->saveFiles($dir);
echo "The web page PDF saved to\n";
print_r($savedFiles);
In this example we will demonstrate a a chained conversion process, where a file is passed through multiple format transformations in sequence.
Useful for building automated workflows that require more than one conversion operation.
# set your api token
ConvertApi::setApiCredentials(getenv('API_TOKEN'));
# Short example of conversions chaining, the PDF pages extracted and saved as separated JPGs and then ZIP'ed
# https://www.convertapi.com/doc/chaining
$dir = sys_get_temp_dir();
echo "Converting PDF to JPG and compressing result files with ZIP\n";
$jpgResult = ConvertApi::convert('jpg', ['File' => 'files/test.pdf']);
$cost = $jpgResult->getConversionCost();
$count = count($jpgResult->getFiles());
echo "Conversions done. Cost: {$cost}. Total files created: {$count}\n";
$zipResult = ConvertApi::convert('zip', ['Files' => $jpgResult->getFiles()], 'any');
$cost = $zipResult->getConversionCost();
$count = count($zipResult->getFiles());
echo "Conversions done. Cost: {$cost}. Total files created: {$count}\n";
$savedFiles = $zipResult->saveFiles($dir);
echo "File saved to\n";
print_r($savedFiles);
The following example demonstrates how to retrieve user account information, such as usage limits, current balance, and activity statistics.
# set your api token
ConvertApi::setApiCredentials(getenv('API_TOKEN'));
# Retrieve user information
# https://www.convertapi.com/doc/user
$info = ConvertApi::getUser();
print_r($info);
The following example demonstrates how to handle common errors and exceptions that may arise during file conversions.
# set your api token
ConvertApi::setApiCredentials(getenv('API_TOKEN'));
try {
$result = ConvertApi::convert('svg', ['File' => 'files/test.docx']);
} catch (\ConvertApi\Error\Api $error) {
echo "Got API error code: " . $error->getCode() . "\n";
echo $error->getMessage();
}
With our PHP SDK, you’ll have access to over 300+ converters and document management features - all available through one unified platform.
You can pass the documents by specifying URLs, reading file streams, or simply referencing local file paths, ensuring that file handling integrates smoothly into your existing setup. To boost productivity even further, consider leveraging conversion workflows to handle multiple tasks efficiently.
For detailed examples and advanced usage tips, be sure to check out our GitHub repository.
Take control of your documents with our PHP document management SDK. From basic conversions to full workflow automation, we provide the expertise and tools you need to manage your documents efficiently.
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
We ensure that all document processing is handled securely in the cloud, adhering to industry-leading standards like ISO 27001, GDPR, and HIPAA. To enhance security even further, we can ensure that no files or data are stored on our servers and never leave your country.
Learn more about securityHighest rated File Conversion API on major B2B software listing platforms: Capterra, G2, and Trustpilot.
"ConvertAPI has been a game-changer for our document automation workflows. Their conversion accuracy and API reliability are unmatched in the industry for over 7 years."
"ConvertAPI is a reliable, cost-effective solution with a proven track record of stability. It has grown significantly in maturity, adopting enterprise-grade practices over the years."
"We've integrated ConvertAPI across our entire document processing platform. The performance is exceptional and the support team is always responsive. Highly recommended!"
The ConvertAPI PHP SDK enables developers to incorporate robust document conversion and manipulation features directly into PHP projects. Whether you need to transform PDFs, extract data from DOCX, or merge multiple files into one, this SDK covers a wide range of formats and operations.
It supports an extensive list of formats, over 300+ types - including PDFs, Office documents, images, and various other file types. This versatility makes it suitable for a diverse range of document processing tasks.
Not at all. The SDK simplifies complex operations into just a few lines of PHP code, allowing you to handle document transformations, apply custom parameters, and retrieve results quickly without diving into low-level details.
Yes. The SDK is built to handle large documents efficiently. While performance depends on file complexity and server resources, you can implement asynchronous calls or break down tasks into manageable workflows for optimum performance.
Absolutely. The SDK gives you the freedom to adjust parameters such as resolution, image quality, page ranges, metadata handling, and more. This customization lets you produce exactly the output you need.
Yes. You can chain multiple operations together to form automated conversion pipelines. This approach helps streamline repetitive tasks, improving overall productivity in your document processing routines.
Explore our GitHub repository for sample code, tips, and best practices. We regularly update the repository to ensure you have access to the latest information and techniques.
We provide a dedicated support live-chat to assist with integration questions, performance tuning, and troubleshooting. You can also check our docs or engage with our developer community to find solutions tailored to your use case.