PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
PDF.co is an API and automation platform for PDF, Barcodes, Data Extraction, and Data Transformations. It also presents online tools for conducting fundamental PDF-related functionalities such as splitting/merging PDF, document parsing, filling PDF forms, searching/replacing text, PDF data extraction to various formats, barcode reader, etc.
This article will demonstrate how to merge large files and compress files after merging with PHP. The PDF.co Web API will be used to perform the task.
Merge PDF Files in PHP – Step-by-Step
Step 1: Start Apache Server
- To begin. First, let’s start the Apache server so we can run the program in a local browser.
Step 2: Save Files in the Folder
Next, save the HTML and PHP sample code in your program folder. We highly recommend saving the files in a folder inside the \www or the \htdocs directory.
Step 3: Run Program
Now, let’s run the program
- On your browser type
- Next, add your PDF.co API Key. You can get the API key by signing up at this link.
- Then, input the PDF documents you want to merge and click the Proceed button to send a request.
Step 4: Test Result
- The program runs successfully, click the temporary URL to view the output.
Step 5: Merge PDF Output
- Here’s the Merge PDF Output
Since we’re done merging the PDF files, we will now compress the merge PDF to reduce the file size.
Compress PDF Files in PHP
Step 1: Save Files
First, save the HTML and PHP sample code in the program folder.
Step 2: Run Program
Let’s run the program
- On your browser, type
localhost/Your_Folder_Name/Name of HTML file.
- Next, Add your PDF.co API Key.
- Then, input the Merge PDF file and click the Proceed button to send a request.
Step 3: Conversion Result
- We successfully compress the PDF file and reduce its file size. Kindly click on the temporary URL to view the output.
Step 4: Compress PDF Output
- Here’s the Compress PDF output that we successfully reduced the file size.