SFDC developer here. I have created a VF page which accepts Account id & displays some information on a VF page in tabular form.
I need to make multiple calls to this page with different account ids on a button click & download the tables in them as PDF/Text files in a zip. I was thinking about using JSZip to download all PDF/Text files as one zip.
I have got Blob value of this VF page in a variable using getContentAsPDF.
Basically i need to know how to use this Blob value for each account table and put it in separate files, download those files one Zip. Any ideas how to proceed?
EDIT 1:
So in the code below, we can see that we generating a list of Blob in the controller. On click of a VF page button i send the Blob list as a param to a JavaScript function. In that function i am trying to add each and every blob to the zip and download. But nothing is getting downloaded for me.
Apex Code:
CkIds = returnCommaSeparatedString(setOFCommKitID);
pr = New PageReference('/apex/PDFPage?id=' + iICPRec +'&CKIds='+CkIds);
pdf = pr.getContentAsPDF();
lstOfBlob.add(pdf);
JavaScript Code:
var IdString;
var ArrayOfBlob = [];
function CallMe(TempVar, VarTemp){
alert(TempVar);alert(VarTemp);
IdString = TempVar;
ArrayOfBlob = VarTemp;
var zip = new JSZip();
for (var i=0; i < ArrayOfBlob.length; i++)
{
zip.file('Test',ArrayOfBlob[0]);
}
var blobLink = document.getElementById('CustomLink');
blobLink.download = "CommunicationKit.zip";
blobLink.href = window.URL.createObjectURL(zip.generate());
blobLink.click();