public function appendDocument($basePdf, $newPdf, $startPage = 0, $endPage = 0, $sourceFolder = '')
    {
        //check whether files are set or not
        if ($basePdf == '')
            throw new Exception('Base file not specified');
        if ($newPdf == '')
            throw new Exception('File to merge is not specified');

        //build URI to merge PDFs
        if ($sourceFolder == '')
            $strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
                '/appendDocument?appendFile=' . $newPdf . ($startPage > 0 ? '&startPage=' . $startPage : '') .
                ($endPage > 0 ? '&endPage=' . $endPage : '');
        else
            $strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
                '/appendDocument?appendFile=' . $sourceFolder . '/' . $newPdf .
                ($startPage > 0 ? '&startPage=' . $startPage : '') .
                ($endPage > 0 ? '&endPage=' . $endPage : '') .
                '&folder=' . $sourceFolder;

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'POST', '', '');

        $json = json_decode($responseStream);

        if ($json->Code == 200) {
            $folder = new Folder();
            $path = "";
            if ($sourceFolder == "") {
                $path = $basePdf;
            } else {
                $path = $sourceFolder . '/' . $basePdf;
            }
            $outputStream = $folder->GetFile($path);
            $outputPath = AsposeApp::$outPutLocation . $basePdf;
            Utils::saveFile($outputStream, $outputPath);
        } else {
            return false;
        }
    }
public function appendDocument($basePdf, $newPdf, $startPage = 0, $endPage = 0, $sourceFolder = '')
    {
        //check whether files are set or not
        if ($basePdf == '')
            throw new Exception('Base file not specified');
        if ($newPdf == '')
            throw new Exception('File to merge is not specified');

        //build URI to merge PDFs
        if ($sourceFolder == '')
            $strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
                '/appendDocument?appendFile=' . $newPdf . ($startPage > 0 ? '&startPage=' . $startPage : '') .
                ($endPage > 0 ? '&endPage=' . $endPage : '');
        else
            $strURI = Product::$baseProductUri . '/pdf/' . $basePdf .
                '/appendDocument?appendFile=' . $sourceFolder . '/' . $newPdf .
                ($startPage > 0 ? '&startPage=' . $startPage : '') .
                ($endPage > 0 ? '&endPage=' . $endPage : '') .
                '&folder=' . $sourceFolder;

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'POST', '', '');

        $json = json_decode($responseStream);

        if ($json->Code == 200) {
            $folder = new Folder();
            $path = "";
            if ($sourceFolder == "") {
                $path = $basePdf;
            } else {
                $path = $sourceFolder . '/' . $basePdf;
            }
            $outputStream = $folder->GetFile($path);
            $outputPath = AsposeApp::$outPutLocation . $basePdf;
            Utils::saveFile($outputStream, $outputPath);
        } else {
            return false;
        }
    }
public function appendDocument ( $ basePdf , $ newPdf , $ startPage = 0 , $ endPage = 0 , $ sourceFolder = '' ) { //check whether files are set or not if ( $ basePdf == '' ) throw new Exception ( 'Base file not specified' ) ; if ( $ newPdf == '' ) throw new Exception ( 'File to merge is not specified' ) ; //build URI to merge PDFs if ( $ sourceFolder == '' ) $ strURI = Product :: $ baseProductUri . '/pdf/' . $ basePdf . '/appendDocument?appendFile=' . $ newPdf . ( $ startPage > 0 ? '&startPage=' . $ startPage : '' ) . ( $ endPage > 0 ? '&endPage=' . $ endPage : '' ) ; else $ strURI = Product :: $ baseProductUri . '/pdf/' . $ basePdf . '/appendDocument?appendFile=' . $ sourceFolder . '/' . $ newPdf . ( $ startPage > 0 ? '&startPage=' . $ startPage : '' ) . ( $ endPage > 0 ? '&endPage=' . $ endPage : '' ) . '&folder=' . $ sourceFolder ; //sign URI $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) { $ folder = new Folder ( ) ; $ path = "" ; if ( $ sourceFolder == "" ) { $ path = $ basePdf ; } else { $ path = $ sourceFolder . '/' . $ basePdf ; } $ outputStream = $ folder -> GetFile ( $ path ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ basePdf ; Utils :: saveFile ( $ outputStream , $ outputPath ) ; } else { return false ; } }
Merges two PDF documents.

@param string $basePdf (name of the base/first PDF file)
@param string $newPdf (name of the second PDF file to merge with base PDF file)
@param string $startPage (page number to start merging second PDF: enter 0 to merge complete document)
@param string $endPage (page number to end merging second PDF: enter 0 to merge complete document)
@param string $sourceFolder (name of the folder where base/first and second input PDFs are present)

@return string|boolean
@throws Exception
Merges two PDF documents .