The API is an enhancement of the existing mergeDocsToPDF API. The mergeDocsToPDF2 merges multiple documents using the values specified in the docIds parameter into a single PDF document with the name docFileName and adds a flag to specify whether PDF document protection should be carried over to the collated PDF. The supported file types are DOC, DOCX, XLS, XLSX, PPT, PPTX, and PDF.

Before invoking this API, CustomClass.ActionParams must be instantiated by passing the parameters described below. The parameters are then passed to the API when it is invoked.

API

Signature

mergeDocsToPDF2

webService static Id mergeDocsToPDF2(Apttus.CustomClass.ActionParams mergeParams)
Request Parameters
NameTypeDescriptionRequired?

parentId

IdThe Id of the parent object to associate with the result (merged) document.Yes
docIdsListA collection of the Ids of the documents to merge into a PDF document.Yes
docFileNameStringThe file name for the PDF document.Yes
sessionIdStringThe Salesforce session Id.Yes
sessionUrlStringThe Salesforce server Id.Yes

ProtectOutputDoc

BooleanIf true, protect the output document with PDF security as defined in Comply properties.Yes
addAutoHeaderFooterBoolean

If true:

  • The agreement number is added as the header on the generated agreement.
  • The timestamp as defined in comply system property is added as the footer on the generated agreement.

If false, you need to define the following parameters. 

Request Parameters
S.NoNameTypeDescriptionRequired?
1AddHeaderBooleanIf true, you need to define parameters from 2-6.Optional
2HeaderModeString

The existing footer values are customized based on the values provided for parameters 3-6.

Supported value: Overwrite

Yes if AddHeader is true
3HeaderTextStringThe text that should be displayed at the header of the generated document.Yes if AddHeader is true
4HeaderFontString

The system font for the header text.

Sample value: Arial, Tahoma

Yes if AddHeader is true
5HeaderFontSizeIntegerThe font size of the header text.Yes if AddHeader is true
6HeaderAlignmentStringThe alignment of the header text. 
Supported values: Left, Right, Center
Yes if AddHeader is true
7AddFooterBooleanIf true, you need to define parameters from 8-12.Optional
8FooterModeString

The existing footer values are customized based on the values provided for parameters 9-12.

Supported value: Overwrite

Yes if AddFooter is true
9FooterTextStringThe text that should be displayed at the footer of the generated document.Yes if AddFooter is true
10FooterFontString

The system font for the footer text.

Sample value: Arial, Tahoma

Yes if AddFooter is true
11FooterFontSizeIntegerThe font size of the footer text.Yes if AddFooter is true
12FooterAlignmentStringThe alignment of the footer text. 
Supported values: Left, Right, Center
Yes if AddFooter is true
Yes
Response Parameter
NameTypeDescription
docIdIDThe id of the generated PDF document.

Code Sample

public String docFormat { get; set; }
public String outputDocFileBasename { get; set; }
private Boolean protectOutputDocStatus;
public String protectOutputDocFlag { get; set; }
private Boolean preserveRedlinesStatus;
public String preserveRedlinesFlag { get; set; }
public List<SelectOption> listOfDocxAttachmentsRelated2Agreement_Selected { get; set; }
public List<SelectOption> listOfPDFAttachmentsRelated2Agreement_Selected { get; set; }
public String apiServerURL = '';
private String servicesSOAPInfo = '/services/Soap/u/50.0/';
 
...
...
 
private void init() {
 
docFormat = 'PDF';
protectOutputDocFlag = 'True';
protectOutputDocStatus = true;
preserveRedlinesFlag = 'True';
preserveRedlinesStatus = true;
outputDocFileBasename = 'Agreement_outputDocFilename_mergeDocsToPDF2';
sessionId = UserInfo.getSessionId();
apiServerURL = System.Url.getSalesforceBaseUrl().toExternalForm() + servicesSOAPInfo + UserInfo.getOrganizationId();
}
 
 
public void mergeDocsToPDF2_ControllerAction() {
 
String outputDocFilename = outputDocFileBasename + '.' + docFormat;
 
List<Apttus.CustomClass.AttachmentInfo> attachmentsInfoList = new List<Apttus.CustomClass.AttachmentInfo>();
List<Id> attachmentsIdList = new List<Id>();
 
// Attachments: Docx
if (listOfDocxAttachmentsRelated2Agreement_Selected != null) {
 
if (!listOfDocxAttachmentsRelated2Agreement_Selected.isEmpty()) {
 
for (selectoption so : listOfDocxAttachmentsRelated2Agreement_Selected) {
 
Apttus.CustomClass.AttachmentInfo attachmentInfo = new Apttus.CustomClass.AttachmentInfo();
 
Attachment attachmentDetails = getAttachmentDetails(so.getValue());
attachmentInfo.Title = attachmentDetails.Name;
attachmentInfo.RecordId = attachmentDetails.Id;
attachmentsInfoList.add(attachmentInfo);
}
}
}
 
// Attachments: PDF
if (listOfPDFAttachmentsRelated2Agreement_Selected != null) {
 
if (!listOfPDFAttachmentsRelated2Agreement_Selected.isEmpty()) {
 
for (selectoption so : listOfPDFAttachmentsRelated2Agreement_Selected) {
 
Apttus.CustomClass.AttachmentInfo attachmentInfo = new Apttus.CustomClass.AttachmentInfo();
 
Attachment attachmentDetails = getAttachmentDetails(so.getValue());
attachmentInfo.Title = attachmentDetails.Name;
attachmentInfo.RecordId = attachmentDetails.Id;
attachmentsInfoList.add(attachmentInfo);
}
}
}
 
//
// Attachments
// DocIds is all that is needed by this API - mergeDocsToPDF2
//
for (Apttus.CustomClass.AttachmentInfo info : attachmentsInfoList) {
 
attachmentsIdList.add(info.RecordId);
}
 
if (getAgreement!= null &&
!string.isBlank(outputDocFilename) &&
(docFormat.equalsIgnoreCase('PDF')) &&
(attachmentsInfoList.size() != 0) &&
apiServerURL != null && apiServerURL != '' &&
sessionId != null && sessionId != '') {
 
//Agreement__c is self lookup field on Agreement
System.debug(apiName + ': getAgreement.Agreement__c: ' + getAgreement.Agreement__c);
Apttus__APTS_Agreement__c myAgreement = [SELECT Id, Name FROM Apttus__APTS_Agreement__c WHERE Id = :getAgreement.Agreement__c];
 
// API Parameters
Apttus.CustomClass.ActionParams apiParameters = new Apttus.CustomClass.ActionParams();
 
apiParameters.ParentId = myAgreement.Id;
apiParameters.DocIds = attachmentsIdList;
apiParameters.DocFileName = outputDocFilename;
apiParameters.PreserveRedlines = getBooleanStatus(preserveRedlinesFlag);
apiParameters.ProtectOutputDoc = getBooleanStatus(protectOutputDocFlag);
apiParameters.SessionId = sessionId;
apiParameters.SessionUrl = apiServerURL;
 
apiParameters.addAutoHeaderFooter = false;
apiParameters.AddHeader = true;
apiParameters.HeaderMode = 'Overwrite';
apiParameters.HeaderText= 'Contract Management';
apiParameters.HeaderFont = 'Arial';
apiParameters.HeaderFontSize = '12';
apiParameters.HeaderAlignment = 'Left';
apiParameters.AddFooter = false;
apiParameters.FooterMode = 'Overwrite';
apiParameters.FooterText= 'Apttus';
apiParameters.FooterFont = 'Arial';
apiParameters.FooterFontSize = '12';
apiParameters.FooterAlignment = 'Left';
 
 
System.debug(apiParameters);
 
try {
 
//submit request
Id myDocId = Apttus.MergeWebService.mergeDocsToPDF2(apiParameters);
 
if (myDocId != null) {
 
// Get details of the corresponding word document.
String pdfFilename = '%' + outputDocFileBasename + '%.pdf';
System.debug(' ' + apiName + ': Querying for: ' + pdfFilename);
List<Attachment> myDocIds = [SELECT Id, Name, CreatedDate FROM Attachment WHERE ParentID = :myAgreement.Id AND Name like :pdfFilename ORDER BY CreatedDate DESC];
Attachment myAttachment = myDocIds.get(0);
getGeneratedDocumentDetails(myAttachment.Id, 'PDF');
 
} else {
 
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'API mergeDocsToPDF2() returned null. Please try again.'));
}
 
} catch (Exception ex) {
 
System.debug('Apttus.MergeWebService.mergeDocsToPDF2: Oops!!! Caught an Exception 1: ' + ex.getMessage());
}
 
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Argument(s) was not set. Please try again'));
}
}
 
 
private Boolean getBooleanStatus(String flagValue) {
 
If ( flagValue.equalsIgnoreCase('True')) {
return true;
} else {
return false;
}
}
CODE

Note

ProtectOutputDoc only enforces document protection in the target PDF when Enable PDF Security was properly configured at the time of PDF generated in the Org corresponding to the input document. For more information, see .Merging Multiple Documents to a PDF with PDF Protection vWinter-20.

All redlines that are present in input documents are accepted prior to collation.

Integration Details

Use the following information in your integrations with Apttus Contract Management Web Services API. For information on how to get started, refer to Integrating Conga CLM with External Systems.

API Prerequisites

None.

Request/Response XML

Example Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mer="http://soap.sforce.com/schemas/class/Apttus/MergeWebService" xmlns:cus="http://soap.sforce.com/schemas/class/Apttus/CustomClass">
   <soapenv:Header>
      <mer:SessionHeader>
         <mer:sessionId>00D0S0000000Pa8!ARUAQGAA1VTGcAG1zxylmAb1RJmiUnspuO5dzL53Xsx3jVhYI3oWTqB2dqzdBeswmwj_I49aI6BgIM4veO1At3rLd9z6BjXv</mer:sessionId>
      </mer:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mer:mergeDocsToPDF2>
         <mer:mergeParams>
            <cus:AddAutoHeaderFooter>False</cus:AddAutoHeaderFooter>
            <cus:AddFooter>True</cus:AddFooter>
            <cus:AddHeader>True</cus:AddHeader>
            <cus:AddWatermark>True</cus:AddWatermark>
            <cus:DocFileName>Merged.PDF</cus:DocFileName>
            <cus:DocIds>0690S000000SvnkQAC</cus:DocIds>
            <cus:DocIds>0690S000000SvwIQAS</cus:DocIds>
            <cus:FooterAlignment>Center</cus:FooterAlignment>
            <cus:FooterFont>Tahoma</cus:FooterFont>
            <cus:FooterFontSize>8</cus:FooterFontSize>
            <cus:FooterMode>Overwrite</cus:FooterMode>
            <cus:FooterText>Copyright 2020</cus:FooterText>
            <cus:HeaderAlignment>Center</cus:HeaderAlignment>
            <cus:HeaderFont>Tahoma</cus:HeaderFont>
            <cus:HeaderFontSize>8</cus:HeaderFontSize>
            <cus:HeaderMode>Overwrite</cus:HeaderMode>
            <cus:HeaderText>Apttus</cus:HeaderText>
            <cus:ParentId>a070S000002bSFzQAM</cus:ParentId>
            <cus:PreserveRedlines>False</cus:PreserveRedlines>
            <cus:ProtectionLevel>Full Access</cus:ProtectionLevel>
            <cus:ProtectOutputDoc>True</cus:ProtectOutputDoc>
            <cus:RemoveWatermark>False</cus:RemoveWatermark>
            <cus:RetainInputHeaderFooter>False</cus:RetainInputHeaderFooter>
            <cus:SessionId>00D0S0000000Pa8!ARUAQGAA1VTGcAG1zxylmAb1RJmiUnspuO5dzL53Xsx3jVhYI3oWTqB2dqzdBeswmwj_I49aI6BgIM4veO1At3rLd9z6BjXv</cus:SessionId>
            <cus:SessionUrl>https://testmanagedclm--tbox.my.salesforce.com/services/Soap/u/50.0/00D0S0000000Pa8</cus:SessionUrl>
            <cus:SObjectId>a070S000002bSFzQAM</cus:SObjectId>
         </mer:mergeParams>
      </mer:mergeDocsToPDF2>
   </soapenv:Body>
</soapenv:Envelope>
XML

Example Response

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/Apttus/MergeWebService">
   <soapenv:Body>
      <mergeDocsToPDF2Response>
         <result>0690S000000SvzCQAS</result>
      </mergeDocsToPDF2Response>
   </soapenv:Body>
</soapenv:Envelope>
XML