I am wondering if anyone has a suggestion on the best practice for rendering a pdf from an LWC.  I have a visualforce page that does the rendering now, I pass some values from another visualforce page to render the PDF.  The first Visualforce page is getting replaced with an LWC but now I'm unsure of how to handle producing a PDF from that lightning web component.  Thanks!!!
50170
I need to view/generate PDF in Lightning component. How can I achieve that?  Do I have to user VF page with "renderAs" attribute inside Lightning Component? Or is there any other way to achieve this?
94858
I am new to lightning experience and components. I have been through some blogs and code that guide through the basics, but other than that I haven't had much hands-on experience.  My question is:  When to use component events vs application events? If I have nested components (parent &amp; child) and if the events are of type Component, will the parent be able to handle events fired from child, and vice versa?  Also, I've noticed there are two ways to get an instance of an event (say TestEvent) -      component.getEvent("TestEvent");   and      $A.get("e.c:TestEvent");   Is there any difference between the both? What do "$A" &amp; "e" in the second form, represent?  Thanks in advance for your reply!
26816
I have a couple custom lightning pages and apps, both overriding default record views and standalone pages (just straight nav to from the sidebar). It seems that every time we go from 'tab' to 'tab' it just hides the content rather than destroying it. When you navigate back to the tab, it does recreate the components, so you end up with 2 of everything sitting out there.  I noticed this b/c we have a component that registers to an app event. And every time you navigate away from and back to the page, the handler is registered +1. So going back and forth a few times you pretty quickly have 10s of the same handlers firing for each app event.  Anyone seen this? Thoughts?  If you create a Lightning App, add this component, and assign it to lightning menu you can see what I mean. Just go the app click home and then click back:  Comp:  &lt;aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"&gt;     &lt;aura:handler event="c:BoringAppEvent" action="{!c.test}"/&gt;     hi     &lt;ui:button press="{!c.onClick}" &gt;App Event&lt;/ui:button&gt; &lt;/aura:component&gt;   controller:  ({     test : function(component, event, helper) {         console.log('Clicked');     },     onClick : function(cmp, evt){          var notEvt = $A.get('e.c:BoringAppEvent');          notEvt.fire();     } })   Renderer  ({     unrender: function(){         this.superUnrender();         console.log('unrender');         debugger;     } })   BoringAppEvent.evt  &lt;aura:event type="APPLICATION" description="Event template" /&gt;
6979
I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7.  It uses fairly basic CSS to style it and renders fine in HTML.  I'm now after a way of converting it to PDF.  I have tried:   : it had huge problems with tables.  I factored out my large nested tables and it helped (before it was just consuming up to 128M of memory then dying--thats my limit on memory in php.ini) but it makes a complete mess of tables and doesn't seem to get images.  The tables were just basic stuff with some border styles to add some lines at various points; : I actually had better luck with this.  It rendered some of the images (all the images are Google Chart URLs) and the table formatting was much better but it seemed to have some complexity problem I haven't figured out yet and kept dying with unknown node_type() errors.  Not sure where to go from here; and : this seems to work fine on basic HTML but has almost no support for CSS whatsoever so you have to do everything in HTML (I didn't realize it was still 2001 in Htmldoc-land...) so it's useless to me.   I tried a Windows app called Html2Pdf Pilot that actually did a pretty decent job but I need something that at a minimum runs on Linux and ideally runs on-demand via PHP on the Webserver.  What am I missing, or how can I resolve this issue?
97536
My vf page     &lt;apex:page renderAs="pdf" Controller="testpdf1"&gt;     &lt;head&gt;         &lt;style type="text/css" media="print"&gt;             @page              {                 size: 8.5in 11in;/* width height */             }              @page              {                 @top-center                  {                     content: element(header);                 }                  @bottom-left                  {                     content: element(footer);                 }             }              div.header              {                 padding: 10px;                 position: running(header);             }              div.footer              {                 display: block;                 padding: 5px;                 position: running(footer);             }              .pagenumber:before              {                 content: counter(page);             }              .pagecount:before              {                 content: counter(pages);             }         &lt;/style&gt;     &lt;/head&gt;      &lt;div class="header"&gt;             &lt;div align="right"&gt;Header&lt;/div&gt;     &lt;/div&gt;      &lt;div class="footer"&gt;         &lt;div&gt;Page &lt;span class="pagenumber"/&gt; of &lt;span class="pagecount"/&gt;&lt;/div&gt;     &lt;/div&gt;      &lt;div class="content"&gt;         &lt;p&gt;             &lt;apex:repeat value="{!opp}" var="item"&gt;                 &lt;tr&gt;                     &lt;td class="tableContent"&gt;{!item.Name}&lt;/td&gt;                 &lt;/tr&gt;             &lt;/apex:repeat&gt;         &lt;/p&gt;     &lt;/div&gt; &lt;/apex:page&gt;   Controller  public class testpdf1 {     public list&lt;Account&gt; opp{get;set;}      public testpdf1()     {         opp=[SELECT Name  from Account limit 50];     } }   I am getting all records in pdf format but able to get header in first page only and i am not getting header from second pages how can i display header to all pages.
123755
I use LWC components in Customer Community. There is datatable component with records and I implemented the function to export selected records in .csv and .pdf.  csv works fine, but I experience the next issue when downloading the file as pdf:   Here is the code I use to create and download the file:  main.js  handleExportAction(evt) {     const selectedFormat = evt.detail.value;     try {         let _file;         let _type;         switch (selectedFormat) {             case 'csv':                 _file = parseToCSV(this.columns, this.selectedRows);                 _type = 'text/html';                 break;             case 'pdf':                 _file = parseToPDF(this.columns, this.selectedRows);                 _type = 'application/pdf';                 break;             default:                 _file = undefined;                 _type = undefined;         }         downloadDataAsFile('Subscription Overview.' + selectedFormat, _type, _file);     } catch(e) {         console.error(e);     } }   service.js - parse&amp;donwloadFile functions  const parseToPDF = (tableCols, rows) =&gt; {     let cols = [];     tableCols.filter(el =&gt; cols.push('&lt;th&gt;' + el.label));      let fileData = '&lt;html&gt;&lt;head&gt;';     fileData += '&lt;title&gt;Subscription Overview&lt;/title&gt;';     fileData += '&lt;body&gt;&lt;table&gt;';     fileData += '&lt;tr&gt;';     fileData += cols.map(col =&gt; col).join('&lt;/th&gt;') + '&lt;/th&gt;';     fileData += '&lt;/tr&gt;';     fileData += '&lt;tr&gt;';     fileData += '&lt;td&gt;Test Data&lt;/td&gt;';     fileData += '&lt;/tr&gt;';     fileData += '&lt;/body&gt;&lt;/html&gt;';     console.log('file: ' + fileData);      return fileData; };  const downloadDataAsFile = (name, type, data) =&gt; { var file = new Blob([data], { type: type }); if (window.navigator.msSaveOrOpenBlob) { // IE10+     window.navigator.msSaveOrOpenBlob(file, filename); } else { // Others     var a = document.createElement("a"),         url = URL.createObjectURL(file);     a.href = url;     a.download = name;     document.body.appendChild(a);     a.click();     setTimeout(function () {         document.body.removeChild(a);         window.URL.revokeObjectURL(url);     }, 0); } };   The body (fileData) variable is for testing purposes, I tried other options but the result was the same.   Probably the issue is in contentType which I set as application/pdf?  I did not find any limitations related to creating pdf files with js. Did someone experienced this issue before?   Thanks in advance.
55635
I am working on a visualforce page and have used javascript to add a row dynamically. All are coming in the pdf except that javascript column.  Below is the javascript sippet that is not loading:  &lt;apex:page controller="Controller" renderAs="pdf"&gt;    &lt;html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;          &lt;script src="https://code.jquery.com/jquery-1.11.1.min.js"&gt;&lt;/script&gt;         &lt;!--SLDS STYLESHEET STATIC RESOURCE--&gt;             &lt;apex:slds /&gt;                 &lt;body&gt;
89078
Is it at all possible to have &lt;link href="http://jacobraccuia.com/styles.css"&gt;inside your Visualforce page and have it work when clicking the http://cs14.salesforce.com/apex/visualforce_page?    That way i can make tons of CSS changes without having to reupload or repackage files.    It works perfectly when I make the site a public domain but inside Salesforce it doesn't.  It seems like I'm going to have to re-zip and reference as a static resource whenever I want to demo or repackage or something.  The other problem is that one of the components requires log-in, which is not something I have set up...  I haven't fooled around with the Eclipse IDE, but maybe that is the way to go.  edit: here is the top of my code!  &lt;apex:page sidebar="false" showHeader="false"  standardStyleSheets="false" controller="Boardroom_Home_Jacob"&gt; &lt;head&gt;     &lt;apex:stylesheet value="http://jacobraccuia.com/bootstrap/css/bootstrap.min.css" /&gt;     &lt;apex:stylesheet value="http://jacobraccuia.com/sf_styles.css" /&gt; &lt;/head&gt;   edit 2:  adding https:// seemed to work perfectly in Firefox, but in Chrome.... (failed) net::ERR_INSECURE_RESPONSE
28809
I :   Aura Components, leveraging its own component model, templates, and modular development programming model. Lightning Web Components, built on top of the web standards breakthroughs of the last five years: web components, custom elements, Shadow DOM, etc.   Apart from both using , and perhaps common component names, at first sight, these look as different as  are.  Can anyone who has worked hands-on with both Aura Components and Lightning Web Components - pilot participants? - comment about how much commonality there is in the framework and tools, and what the learning curve is like for Lightning Web Components?  (I'm hoping this doesn't get closed for being a matter of opinion; my aim is to get some insight into how easy or hard it will be to switch over.)
116439
I have a VF code below where I am trying to display the related list of an object using  and  command. I am rendering this page as PDF , doing that in my PDF I am unable to see the content in a tabular format. How can I make the content appear in a table?      &lt;apex:pageBlockSection columns="1" title="TECHNICAL ASSESSMENT"&gt;          &lt;apex:repeat value="{!interviewSkillReviews}" var="interview"&gt;              &lt;table border="1" cellpadding="6"&gt;                 &lt;apex:pageblockTable value="{!interview.Skill_review__r}" var="skillreview"&gt;                      &lt;apex:column headerValue="Skill Name"&gt;                                                         &lt;apex:outputText value="{!skillreview.Skill__r.Name}"/&gt;                     &lt;/apex:column&gt;                 &lt;apex:column headerValue="Recommended Level"&gt;                     &lt;apex:outputText value="{!skillreview.Level__r.Name}"/&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating"&gt;                     &lt;apex:outputField value="{!skillreview.RatingCopy__c}" rendered="{!NOT(interviewerMode)}" /&gt;                     &lt;apex:selectList value="{!rating}" multiselect="false" size="1" rendered="{!interviewerMode}"&gt;                         &lt;apex:selectOption itemValue="1" itemLabel="1"/&gt;                         &lt;apex:selectOption itemValue="2" itemLabel="2"/&gt;                         &lt;apex:selectOption itemValue="3" itemLabel="3"/&gt;                         &lt;apex:selectOption itemValue="4" itemLabel="4"/&gt;                         &lt;apex:selectOption itemValue="5" itemLabel="5"/&gt;                     &lt;/apex:selectList&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating Level Description"&gt;                     &lt;apex:outputText value="{!skillreview.Skill_Level_Description__c}"/&gt;                 &lt;/apex:column&gt;               &lt;/apex:pageblockTable&gt;         &lt;/table&gt;      &lt;/apex:repeat&gt; &lt;/apex:pageBlockSection&gt;   I tried using &lt;table&gt; command of HTML but I just get a border around the pageblocktable.    Example of table look and feel:
108002
Open local xhtml files in chrome, however, chrome treats it as XML files, and won't render it as HTML.  I don't want to change all my *.xhtml file extension to .html, so is there any workaround?  EXAMPLE  a.xhtml:  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html&gt;     &lt;head&gt;         &lt;title&gt;Example&lt;/title&gt;     &lt;/head&gt;     &lt;body&gt;         &lt;b&gt;Hello&lt;/b&gt;,          &lt;i&gt;World&lt;/i&gt;!     &lt;/body&gt; &lt;/html&gt;
113059
LWC rookie here, How can we call a JavaScript function from LWC? For example I have the following static resource helloWorld.js and I'll like to use and call the function in the file. How can I accomplish this?   JavaScript file:      function helloWorld(name) {         let hello = 'Hi ' + name;         return hello     }   LWC controller:   import { LightningElement, track, api } from "lwc";  import helloWorld from "@salesforce/resourceUrl/helloWorld";  import { loadScript } from "lightning/platformResourceLoader";   export default class testLwc extends LightningElement {    @track message;    renderedCallback() {     Promise.all([loadScript(this, helloWorld)])       .then(() =&gt; {         this.error = undefined;         // Call back function if scripts loaded successfully         console.log('load correctly')       })       .catch(error =&gt; {        });   }    handleOnChange() {        //how can I do something like this below ?      this.message = window.helloWorld('test');     }   Thank you
123521
I have a VF page with lightningstylesheets = &quot;true&quot;. (This needs to stay this way-- when I take that away the whole page doesn't look right.) I need to save this VF page as a PDF to my Lead record, from an after update trigger. I am seeing that I cannot use renderas=&quot;pdf&quot; together with lightningstylesheets=&quot;true&quot;. I am also seeing that when I try to save the page as is as a pdf, it does not work-- the logs say  Internal Salesforce.com Error.  Does anyone have experience with a similar issue? How can I make this work? Here is the code I'm trying to get the body of the page as pdf:  PageReference pref = Page.SEEK_MVP_PDF_Display;         pref.getParameters().put('id',leadId);         Blob b; if(Test.isRunningTest()) {   b = blob.valueOf('Unit.Test'); } else {    b = pref.getContentaspdf();    system.debug('B: ' + b); } ContentVersion cv = new ContentVersion();         cv.versionData = b;         cv.title = 'SEEK Medicare Eligibility Check';         cv.PathOnClient = 'SEEK_Eligibility_Check.pdf';         insert cv;  ContentVersion Content = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];         ContentDocumentLink contentlink=new ContentDocumentLink();         contentlink.LinkedEntityId= leadId;         contentlink.ShareType= 'V';         contentlink.ContentDocumentId= Content.ContentDocumentId;         insert contentlink;
59918
I know lightning doesn't support javascript buttons. I know there are alternative routes to do this with actions, lightning components, and visualforce. I'm asking how to do something that according to my research is supported but doesn't seem to work.  From the      Custom buttons and links that define their content source as URL are   now supported in Lightning Experience and the Salesforce1 mobile app.   This feature was previously available in Salesforce Classic only.   Seems straight forward. Create the button, add it to the classic page layout, see it in lightning. But for the life of me, I can't figure out how to get this thing to show up.  Here's the custom button, pretty basic   I've got it setup as the only button on the page layout, it's the assigned layout when I edit the page in lightning.   But in lightning I'm getting nothing   What am I doing wrong? Seems like I'm following the instructions outlined in this . Even though it's in the release notes, it's not mentioned in the . Other peopler have had  and have gotten it working eventually. What am I missing? Are there other factors to consider? Are those documented anywhere?
35807
I have created a VF page and used "render as pdf"  &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  /&gt;   Its working fine when i am using above line without rerender and oncomplete but when i am adding rerender or oncomplete it is not working.I am able to save the PDF in attachment folder but when i am trying to open its showing  "Unable to load document"  Even if i remove oncomplete and use Rerender then also its saving the attachment in Attachment object and when i view ,it is not loading and says "Unable to load document"      &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  oncomplete="myClose();"/&gt;   Javascript Code  function myClose(){      self.close();     window.opener.location.href="/{!$CurrentPage.parameters.Id}";  }   Class Code  public void savePdf() {      PageReference pdf = Page.GenerateQuotePDF;     pdf.getParameters().put('id',parentId);      Attachment attach = new Attachment();      Blob body;     body = pdf.getContent();     attach.Body = body;     attach.Name = 'Opportunity'+ '.pdf';       attach.IsPrivate = false;     attach.ParentId = parentId;     attach.ContentType = 'application/pdf';     insert attach;     }     Please help..
56430
I'm not able to get refreshApex() working in an lwc. . Here are the key elements of the js file:  import { LightningElement, track, api, wire } from 'lwc'; import getBlasts from '@salesforce/apex/Blast.getBlasts'; import { refreshApex } from '@salesforce/apex';  export default class BlastWaveTree extends LightningElement {     @api recordId;     @track blastData;     @track error;     @wire(getBlasts, { CampaignId: '$recordId' })         wireBlastData({             error,             data         }) {             if (data) {                 let tempjson = JSON.parse(JSON.stringify(data).split('waves').join('_children'));                 this.blastData = tempjson;          } else {                 this.error = error;         }     }      @api     refresh() {         return refreshApex(this.blastData);      }   My code varies from the doc examples for 2 reasons:    The example code doesn't separate out the Apex response into error and data, the pattern I've been following as shown elsewhere. This data is going into a lightning-tree-grid so I have to process it a bit before assigning it to blastData.   I've tried return refreshApex(this.wireBlastData) as well, and that doesn't work.  Ultimately, I want to call the refresh function from the parent component (hence, the @api), but I've simplified it (till I get it working) by calling the refresh function from a button on this same component. I added a console.log line in the refresh() function so I know the button is calling the function. It just doesn't refresh. I'm also watching the apex logs as I push the refresh button, and there's no apex activity.  Here's the template:  &lt;template&gt; &lt;lightning-card title="Blasts" icon-name="custom:custom3"&gt;     &lt;div slot="actions"&gt;         &lt;lightning-button-group &gt;             &lt;lightning-button-icon icon-name="utility:refresh"  alternative-text="Refresh" onclick={refresh}&gt;&lt;/lightning-button-icon&gt;             &lt;lightning-button label={buttonLabel} onclick={toggleWaves}&gt;&lt;/lightning-button&gt;              &lt;lightning-button label="New Blast" onclick={onNewBlast} variant="Brand"&gt; &lt;/lightning-button&gt;         &lt;/lightning-button-group&gt;     &lt;/div&gt;     &lt;div class="slds-m-around_medium"&gt;         &lt;lightning-tree-grid              data={blastData}              columns={columns}              key-field="id"              hide-checkbox-column="true"              onrowaction={handleRowAction} &gt;         &lt;/lightning-tree-grid&gt;     &lt;/div&gt; &lt;/lightning-card&gt;     What am I missing?  Here's the error detail from the browser dev tools:      lds.js:2 Uncaught (in promise) Error: Refresh failed because resolved configuration is not available.     at Object.e.refresh [as refreshApex] (lds.js:2)     at l.refresh (blastWaveTree.js:4)     at callHook (aura_prod.js:24)     at sa (aura_prod.js:2)     at aura_prod.js:2     at _ (aura_prod.js:2)     at HTMLElement.e (aura_prod.js:2)     at l (aura_prod.js:2)     at Un.call.a (aura_prod.js:2)     at Array.forEach (&lt;anonymous&gt;) e.refresh   @   lds.js:2 refresh @   blastWaveTree.js:4 callHook    @   aura_prod.js:24 sa  @   aura_prod.js:2 (anonymous) @   aura_prod.js:2 _   @   aura_prod.js:2 e   @   aura_prod.js:2 l   @   aura_prod.js:2 Un.call.a   @   aura_prod.js:2 t   @   aura_prod.js:2 Lt  @   aura_prod.js:2 t.$$lwcEventWrapper$$   @   aura_prod.js:2
14837
I want to generate a PDF by passing HTML contents to a function. I have made use of iTextSharp for this but it does not perform well when it encounters tables and the layout just gets messy.  Is there a better way?