This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Merge PDF

msajid wrote on 2012-07-19:
Hi, I used Pdfcrowd free API for PHP & it is really awesome but I did not find any option to Merge different PDF files.
Can some body guide how could I merge PDF files by Pdfcrowd?
support wrote on 2012-07-19:
There is no such option in the API.

However, it should be easy to merge PDFs locally as there are several free tools (e.g. pdftk) that allow joining existing PDFs.
aptagen wrote on 2012-07-21:
I had a similiar problem but I fixed it using iTextSharp because our server runs Asp.Net. For PHP, I would recommend pdftk as stated above. Here's some example code in php that may be what you're looking for.


$uploaddir = "files/";  //set this to where your files should be uploaded.  Make sure to chmod to 777. 

if ($_FILES['file']) { 

    $command = ""; 
    foreach($_FILES['file']['type'] as $key => $value) { 
    $ispdf = end(explode(".",$_FILES['file']['name'][$key]));  //make sure it's a PDF file     
    $ispdf = strtolower($ispdf); 

        if ($value && $ispdf=='pdf') { 
            //upload each file to the server 
            $filename = $_FILES['file']['name'][$key]; 
            $filename = str_replace(" ","",$filename); //remove spaces from file name 
            $uploadfile = $uploaddir . $filename; 
            move_uploaded_file($_FILES['file']['tmp_name'][$key], $uploadfile); 
            //build an array for the command being sent to output the merged PDF using pdftk 
            $command = $command." files/".$filename; 

    $command = base64_encode($command); //encode and then decode the command string 
    $command = base64_decode($command); 

    $output = "files/merged-pdf".time().".pdf"; //set name of output file 
    $command = "pdftk $command output $output"; 

    passthru($command); //run the command 

    header(sprintf('Location: %s', $output)); //open the merged pdf file in the browser 



This link follows this a little more in detail:
noodle758 wrote on 2013-07-01:
my .net sulotion for PDF merge
using RasterEdge.Imaging.Basic;
using RasterEdge.Imaging.Basic.Core;
using RasterEdge.Imaging.Basic.Codec;
using RasterEdge.Imaging.PDF;

namespace RE__Test
    public partial class Form1 : Form
        public Form1()

        public static string FolderName = "c:/";

        private void button1_Click(object sender, EventArgs e)
            string fileName1 = FolderName + "Sample1.pdf";
            string fileName2 = FolderName + "Sample2.pdf";
            string fileNameMerged = FolderName + "Merged.pdf";

            REDocument doc1 = REFile.OpenDocumentFile(fileName1, new PDFDecoder());//use PDFDecoder open one pdf file

            REDocument doc2 = REFile.OpenDocumentFile(fileName2, new PDFDecoder());//use PDFDecoder open another pdf file

            BaseDocument docMerged = doc1.MergeDocument(doc2);//merge two pdf

            REFile.SaveDocumentFile((REDocument)docMerged, fileNameMerged, new PDFEncoder());//save new pdf



hawk007 wrote on 2013-09-09:
did this code work ?
hawk007 wrote on 2013-09-09:
can any body help me how this code be replce to slove this proble so that i could use pdf merge