You need to sign in to do that
Don't have an account?
harry.kim
pageReference pdf download problem
Hi I have some problem.
I want to download PageReference to PDF file. But korean or chinese are not visible.
For this, my apex code and lightning callback code is below.
1. apex code
PageReference pdfPage = Page.VOCFinalReportPage;
pdfPage.getParameters().put('id',recordId);
Blob pdfBlob;
try{
pdfBlob = pdfPage.getContents();
}catch(VisualforceException ex){
pdfBlob = Blob.valueOf('some pdf');
System.debug(ex);
}
return JSON.serialize(pdfBlob);
2. lightning controller (callback)
var pdfbase64 = JSON.parse(res.getReturnValue());
var byteCharacters = atob(pdfbase64);
var byteNumbers = new Array(pdfbase64.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray], {type: "application/pdf"});
FileSaver.saveAs(blob, 'finalreport.pdf');
What is the problem?
Please help me. Thank you...
I want to download PageReference to PDF file. But korean or chinese are not visible.
For this, my apex code and lightning callback code is below.
1. apex code
PageReference pdfPage = Page.VOCFinalReportPage;
pdfPage.getParameters().put('id',recordId);
Blob pdfBlob;
try{
pdfBlob = pdfPage.getContents();
}catch(VisualforceException ex){
pdfBlob = Blob.valueOf('some pdf');
System.debug(ex);
}
return JSON.serialize(pdfBlob);
2. lightning controller (callback)
var pdfbase64 = JSON.parse(res.getReturnValue());
var byteCharacters = atob(pdfbase64);
var byteNumbers = new Array(pdfbase64.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray], {type: "application/pdf"});
FileSaver.saveAs(blob, 'finalreport.pdf');
What is the problem?
Please help me. Thank you...