How can we download or view the PDF file using Lightning Component from documents in salesforce1 app, is it possible to do or not, if yes please suggest how can i achieve this.

1 Answer 1


If you use Files or content related object there is a simple event with new lightning namespace which can be used

Here is a sample quick POC

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
   <aura:attribute name="contentId" type="String" default="069B00000015QMwIAM"/>
<lightning:button variant="brand" label="Preview Reciept" onclick="{!c.preview }" />

Note that the default here is the Id of the content document .

The controller code for same is below

   preview : function(component, event, helper) {
        recordIds: [component.get("v.contentId")]

Here is how the component looks in the UI

enter image description here

Once you click this the below should appear

For SF1 there is a repo which covers the same using a third party JS library


enter image description here

  • Thank you, it is working fine in LE but for SF1 am getting "This page has an error. You might just need to refresh it. Action failed: TestLightening8$SalesforceStackExchangeComponents$controller$preview [Cannot read property 'fire' of undefined]"
    – Raj_SFDC
    Commented Oct 30, 2016 at 19:04
  • i am testing it now in SF1.As per docs it should work in SF1 and community builder as well Commented Oct 30, 2016 at 20:09
  • How are you testing it ? Test in on actual device ? Commented Oct 30, 2016 at 20:29
  • i tested on android device, yes as per docs it should work bur not working , i enable and disable locker service also but no luck, for me is major is SF1 app only.
    – Raj_SFDC
    Commented Oct 31, 2016 at 7:05
  • I updated the answer .You may have to tweak the git code to fit your need but that link does a good job Commented Oct 31, 2016 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .