• ABHILASH A
  • NEWBIE
  • 10 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi All,

How to display base64 encoded PDF data receiving from other system in Lightning web component without storing data in salesforce.

Is using PDF.js the only way to handle this.
#lightningwebcomponent #lwc #pdfview #base64encoded
I am new to integration and would like to know what are the ways with which we could integrate SharePoint online with Salesforce efficiently. From what I have found online we can use REST API to connect to SharePoint online. We approached a Salesforce vendor who estimated the number of hours for each task. Does the below sound reasonable or can you please guide me as to what further questions that I need to ask the vendor on the below integration?
  • Create Data model to store the Folder Structure if required based on the Month/Year - 10 hours.
  • Write the Authentication logic for SharePoint access - 40 hours.
  • Embed the file creation & folder creation (if required) code in existing "Send To Client" lightning component to store the files in SharePoint - 60 hours.
  • Implement the Logging mechanism for any failures occurred - 30 hours.
  • Apex Test Classes - 20 hours.
  • UAT Testing & Bug fixes - 10 hours.
  • Contingency - 10 hours plus or minus.
Dear Community,
I am new to Lightning experience,i have some knowledge about lightning.i tried to generate the pdf for Account or any standard or custom object.i wrote the some logic the pfd is generated with empty sheet,i want all the fields of the perticular object which is i mentioned.i think i missed some logic in my components/controllers.
can any one suggest where i did mistake and also can tell me how to generate the pdf for perticular object either custom or standard
my code is 
Apex class:
public class DataDisplayController {
    public String PDFData{get;set;}
    
    public DataDisplayController(){
        
        PDFData = '';
    }
    public PageReference downloadPDF(){
        System.PageReference pageRef = new System.PageReference('/apex/PDFGenerator');
        //ensure pdf downloads and is assigned with defined name
        pageRef.getHeaders().put('content-disposition', 'attachment; filename=TestPDF.pdf');
        
        return pageRef;
    }
    }
Component:
<aura:component >
    <aura:attribute name = "sendData" type = "Account"/>
    <lightning:button label = "Download Document" onclick = "{!c.downloadDocument}" />
    
</aura:component>

client-side controller.js
({
 downloadDocument : function(component, event, helper){

  var sendDataProc = component.get("v.sendData");
  var dataToSend = {
     "label" : "This is test"
  }; //this is data you want to send for PDF generation

  //invoke vf page js method
  sendDataProc(dataToSend, function(){
              
  });
 }
})
Helper.js
({
    helperMethod : function(component,callbackMethod) {
        var action = component.get("c.download");
        action.setCallback(this,function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var generatePdf = reponse.getReturnValue();
                component.set("v.sendData",generatePdf);
                console.log('pdf generated successfully');
                
            }
            else{
                console.log('unable to generate the pdf');
            }
        });
        $A.enqueueAction(action);
        
    }
})
VF Page:
<apex:page controller="DataDisplayController" showHeader="false">
    <apex:includeLightning />
    
    <apex:form>
        <apex:inputHidden id="hidData" value="{!PDFData}"/>
        <apex:actionFunction name="jsGeneratePDF" action="{!downloadPDF}"/>
        <div id = "lightning" />
        
        <script>
            function saveData(data, callback){
            var hidData = document.getElementById('{!$Component.hidData}');
            hidData.value = JSON.stringify(data);
            
            //invoke PDF Generation
            jsGeneratePDF();
         
            //invoke callback;
            if(typeof callback == 'function') callback();
        }
        
        
        function loadComponents(){
            console.log("Loading lightning component: DataProcessor");
            
            $Lightning.use("c:LightningPDFGeneratorDemoApp", function() {
                $Lightning.createComponent("c:DataProcessor",
                { 
                    sendData : saveData
                },
                "lightning",
                function(cmp) {
                    // do some stuff
                });
            });
        }
        
        loadComponents();
        </script>            
           </apex:form>
</apex:page>

<apex:page controller="DataDisplayController"  renderAs="pdf">
    {!PDFData}
</apex:page>

App:
<aura:application extends = "ltng:outApp" >
    <c:DataProcessor />
    
</aura:application>

thanks in advance
  • October 10, 2018
  • Like
  • 0