I am trying to print a pdf from an aura component in Salesforce Communities and I'm having some difficulties. Does anyone know a good way to do this? Currently the pdf is saved as a static resource. I've tried to do some things with iframes. The iframe will show if I put it in a lightning app, but the iframe isnt rendering in communities. I have made the visualforce page available for communities. Also, it is not currently printing in either location. Here is my code at the moment:

The Aura Component:

<iframe id="iframe" src="{!'https://okbeaneighbor--govdev--c.visualforce.com/apex/AdultHopeScale'}" width="100%" height="600px;" frameBorder="0"/>
<lightning:button onclick="{!c.print}" label="Download Adult Hope Scale" />

The Controller funtion:

print: function(cmp, event, helper) {
    pwin = window.open(document.getElementById("iframe").src,"_blank");
    pwin.onload = function () {window.print();}

The visualforce page containing the static resource:

<apex:page sidebar="false" showHeader="false" standardStylesheets="true">
<apex:iframe width="1000" height="1000" src="{!URLFOR($Resource.OK_HopeScaleAdult)}"/>

Thanks in advance!

  • For communities the URL of the frame will change. https://domain.force.com/communityNameHere/apex/Vfpagename and make sure the VF is enabled for communities.
    – manjit5190
    May 1, 2020 at 22:02
  • For domain, is that the domain name in my domain? Also, our community name has spaces. How should that be handled in communityNameHere? May 1, 2020 at 22:50
  • It's the url that you see when you are in the community.
    – manjit5190
    May 2, 2020 at 10:24
  • looks like I still have the wrong url. I'm getting the frowny face. For the community name, will it just remove the spaces? May 2, 2020 at 13:51
  • Can you paste your community URL here?
    – manjit5190
    May 2, 2020 at 14:51

1 Answer 1

  1. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
  2. Click Edit for the page you want to make available for your community.
  3. Select Available for Salesforce mobile apps and Lightning Pages and click Save.


This will help you to show Vf page in community

  • I have done this and it did not fix the issue. Any other ideas? I'm trying to get it to render from an aura component in communities and not communities directly if that makes any difference. Thank you for your input. May 3, 2020 at 19:25

You must log in to answer this question.

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