- Get started
- Overview
- Getting started
- Processing a PDF
- Common functions
- Error handling
- Organize
-
Merge PDF
-
Split PDF
-
Smart Split PDF (AI)
-
Rotate PDF
-
Add page numbers
- Optimize
-
Compress PDF
-
Repair PDF
-
PDF to PDF/A
-
Validate PDF/A
- Convert
-
Office to PDF
-
HTML to PDF
-
Images to PDF
-
PDF to JPG
- Edit and secure
-
Edit PDF
-
Watermark PDF
-
Protect PDF
-
Unlock PDF
- AI and data
-
OCR PDF
-
Extract text
-
PDF to Markdown (AI)
-
AI Summarizer (AI)
-
Detect forms (AI)
- No matches.
Resources
Merge PDF Guide
Develop your own solution to combine multiple PDF files by integrating with iLovePDF’s REST API.
New to the API? Start with Processing a PDF: every tool guide builds on its task flow.
Basic merge
Merge is one of the simplest iLoveAPI tools to use and can be done by simply uploading two or more files, as shown in this example code:
Examples using a library
// Create a new task
$myTaskMerge = $ilovepdf->newTask('merge');
// Add files to task for upload
$file1 = $myTaskMerge->addFile('path/to/file1_name.pdf');
$file2 = $myTaskMerge->addFile('path/to/file2_name.pdf');
// Execute the task
$myTaskMerge->execute();
// Download the package files
$myTaskMerge->download();// Create a new task
var taskMerge = api.CreateTask<MergeTask>();
// Add files to task for upload
var file1 = taskMerge.AddFile("file1.pdf");
var file2 = taskMerge.AddFile("file2.pdf");
// Execute the task
taskMerge.Process();
// Download the package files
taskMerge.DownloadFile();# Create a new task
my_task_merge = ilovepdf.new_task :merge
# Add files to task for upload
file1 = my_task_merge.add_file 'path/to/file1_name.pdf'
file2 = my_task_merge.add_file 'path/to/file2_name.pdf'
# Execute the task
my_task_merge.execute
# Download the package files
my_task_merge.downloadconst task = ilovepdf.newTask('merge') as MergeTask;
task.start()
.then(() => {
return task.addFile(new ILovePDFFile('path/to/file1_name.pdf'));
})
.then(() => {
return task.addFile(new ILovePDFFile('path/to/file2_name.pdf'));
})
.then(() => {
return task.process();
})
.then(() => {
return task.download();
})
.then((data) => {
fs.writeFileSync('path/to/local/file_name.pdf', data);
});PHP library ilovepdf/ilovepdf-php
composer require ilovepdf/ilovepdf-php.NET library ilovepdf/ilovepdf-net
dotnet add package ILove_PDFRuby library ilovepdf/ilovepdf-ruby
gem install ilovepdfNode.js library ilovepdf/ilovepdf-nodejs
npm install @ilovepdf/ilovepdf-nodejsIn this example, file1_name.pdf and file2_name.pdf will be merged into a single PDF with a default filename.
Merge is that simple. Remember that you can explore more functions like setting the output filename in the Common functions guide.