Skip to content

How to Use Aspose.Pdf Merge Sample

Assad Mahmood Qazi edited this page Feb 27, 2014 · 1 revision

Functionality

Aspose.Pdf Document Merge Sample allows merge multiple PDF files using Aspose.Pdf for Cloud API in your Salesforce Portal. You need to provide an output file and a list of pdf files to be merged. Aspose.Pdf Document Merge will append the pdf files and provides output as one single merged file.

Process

Before using Aspose.Pdf Document Merge Sample you need to install Aspose Cloud Samples Package for Salesforce. Please read the installation process here.

  • After successful installation please open "Aspose Samples" App.
  • Open "Aspose Pdf Merge" tab.
  • Fill the on screen from and execute the Sample.

APEX Code Snippet

public String ExecuteMerge(String Filename, String PdfOne, String PdfTwo) {
    
        try{
            //build URI
            String strURI = Product.BaseProductUri + '/pdf/' + Filename + '/merge';
            String signedURI = Utils.Sign(strURI);
            
            String jsonData = '{\'List\':[\'' + PdfOne + '\',\'' + PdfTwo + '\']}';
            
            String strJSON = Utils.ProcessCommand(signedURI, 'PUT', jsonData , 'json');
            this.apiResponse = strJSON;
            
            //prepare signed download link
            String downloadURL = null;
            Map<String, Object> params = (Map<String, Object>) JSON.deserializeUntyped(strJSON);
            if(params.containsKey('Document')){
                strURI = Product.BaseProductUri + '/pdf/' + Filename;
                downloadURL = Utils.Sign(strURI);
            }
            
            return downloadURL;
            
            
        } catch (Exception ex) {
            system.debug(ex);
            return null;
        }
    
    }

ProcessCommand method is available in Utils Class. Please check the source.