You need to sign in to do that
Don't have an account?
Paul Foley
My lightning component isn't able to render PDF
Hey All,
I have a lightning component that makes a webService call to an Apex class that is designed to generate a quote document (pdf) and save it to a QuoteDocument record against the quote. When I call the class via a javascript button in classic it creates the PDF and attaches it as expected. However when I call the PDF document from a lightning action it doesnt. (The new quoteDocuement record is created, but the PDF document wont load)
I'm wondering if the PDF rendering issues in lightning are the cause of this? Does anyone know the specifics about why we can't render PDFs in lightning?
Below are some bit of code that may help to give some reference
Apex code to generate and save the PDF Doc
Javascript Button code - called from the Classic Quote page when the button is click (this works)
Lightning controller.js - this one doesnt work :(
I have a lightning component that makes a webService call to an Apex class that is designed to generate a quote document (pdf) and save it to a QuoteDocument record against the quote. When I call the class via a javascript button in classic it creates the PDF and attaches it as expected. However when I call the PDF document from a lightning action it doesnt. (The new quoteDocuement record is created, but the PDF document wont load)
I'm wondering if the PDF rendering issues in lightning are the cause of this? Does anyone know the specifics about why we can't render PDFs in lightning?
Below are some bit of code that may help to give some reference
Apex code to generate and save the PDF Doc
String quoteTemplateDataViewerUrl = '/quote/quoteTemplateDataViewer.apexp?id={!QuoteId}&headerHeight={!QuoteHeaderHeight}&footerHeight={!QuoteFooterHeight}&summlid={!QuoteTemplateId}'; PageReference pageRef = new PageReference( quoteTemplateDataViewerUrl.replace('{!QuoteId}', theQuote.Id) .replace('{!QuoteHeaderHeight}', quoteHeaderHeight) .replace('{!QuoteFooterHeight}', quoteFooterHeight) .replace('{!QuoteTemplateId}', quoteTemplateId) ); QuoteDocument qdoc = new QuoteDocument(); qdoc.Document = pageRef.getContent(); qdoc.QuoteId = theQuote.Id; attList.add(qdoc);
Javascript Button code - called from the Classic Quote page when the button is click (this works)
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} var quoteId = '{!Quote.Id}'; var errorMsg = sforce.apex.execute("QuotePdfWs", "generateDraftProposalPdf", {quoteIdList:quoteId}); if (errorMsg != '') alert(errorMsg); else window.location.reload();
Lightning controller.js - this one doesnt work :(
({ generateProposal : function(component, event, helper) { var recordId = component.get("v.recordId") var action = component.get("c.generateDraftProposalPdf"); action.setParams({"quoteIdList": [recordId]}); action.setCallback(this, function(response) { var state = response.getState(); if(component.isValid()){ $A.get("e.force:closeQuickAction").fire(); var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "Success!", "message": "A new draft proposal document has been created" }); toastEvent.fire(); $A.get('e.force:refreshView').fire(); } else { component.set("v.messageError", true); } }); $A.enqueueAction(action); } })