I have a requirement to perform a callout from an LWC to get invoices data and then display as a PDF the data returned. So i have an LWC with a lightning data table and on row action it calls an apex class to do the callout and get the result. In order to do the rendering to PDF, i created a visualforce page which is called from apex. However, i didn't manage to find solution i was getting several errors like "ERROR: Formula Expression is required on the action attributes." or like "common.apex.runtime.impl.executionexception argument cannot be null". Seems like i am doing something wrong when passing the data from Apex to the Visualforce.
so, the issue is:
- i have got the invoice data of structure:
public class el_invoices{
@AuraEnabled
public Boolean Success {get; set;}
@AuraEnabled
public String ErrorCode {get; set;}
@AuraEnabled
public String ErrorMessage {get; set;}
@AuraEnabled
public String BillNo {get; set;}
@AuraEnabled
public String BillData {get; set;}
}
- Then on specific invoice action i call from my LWC an APEX function showPDF
@AuraEnabled
public static void showPDF(String s){
System.debug('in show pdf: '+s);
navigate(s);
}
public static blob navigate(String s) {
PageReference pg = new PageReference('/apex/el_generatePDF');
pg.getParameters().put('displayText', 'sdfsdf');
pg.setRedirect(true);
//blob doccontent = pg.getContent();
//ystem.debug('doccontent '+doccontent);
system.debug('show pdf finish');
return pg.getContent();
}
- But my visualforce is always blank, like i cannot pass data from my apex class to the "displayText" attribute. Has anyone found solution on such topic? Again, what i want is to make a callout, and show a PDF (not save anything in the database)
<!--<apex:page controller="el_generatePDFController" contentType="application/pdf" renderAs="pdf">-->
<apex:page controller="el_generatePDFController" contentType="application/pdf" renderAs="pdf">
<apex:form >
<!-- Page code -->
<apex:inputhidden id="hidData" value="{!displayText}"/>
{!displayText}
</apex:form>
</apex:page>
public with sharing class el_generatePDFController {
public String displayText {get; set;}
public String getdisplayText (){
/*//System.debug('s: '+ s);
System.debug('pdfdatastring: '+ pdfdatastring);
return EncodingUtil.base64Decode(pdfdatastring).toString();
*/
displayText = 'giorgos';
return displayText;
}
}
UDATE: I edit my question to show at a high level the problem that i am facing: