function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DilluSalesForceDilluSalesForce 

Merging bodies of two attachments.....??????

Hi,

    Is there any way to add body of two  attachments into a single attachment.

 

i have tried it in the following way

 

PageReference StatementPDF = Page.GeneratePDF;

StatementPDF.getParameters().put('Id','001T000000DppRD'); StatementPDF.setRedirect(true);

Blob p = StatementPDF.getContent();

 

Blob x = p;

x = Blob.valueOf(p + x);

 

Attachment objAttachment = new Attachment(); objAttachment.parentId = '001T000000DppRD';

objAttachment.Body = x;

objAttachment.Name = 'MonthlyStatement.pdf'; objAttachment.ContentType =

'application/pdf';

insert objAttachment;

 

 

but the Problem is it is not displaying any content(though i have content in GeneratePDF) itz juz showing a blank PDF.

Pls do the needful. 

Best Answer chosen by Admin (Salesforce Developers) 
Cool_DevloperCool_Devloper

You cant merge docs liek that!!

Moreover, document merging is not supported in salesforce.

Cool_D

All Answers

Cool_DevloperCool_Devloper

You cant merge docs liek that!!

Moreover, document merging is not supported in salesforce.

Cool_D

This was selected as the best answer
GoForceGoGoForceGo

I tried this...it merged the two documents (created attachment c below). But when I try to open it, it says servlet.filedownload is protected. I suspect the merged document is garbage. 

 


Attachment a; Attachment b; String s = a.Body.toString() + b.Body.toString(); Blob x = Blob.valueof(s); Attachment c = new Attachment (body = x....) insert c;