PDF Viewer Lightning Component

KK Ramamoorthy
my journey with salesforce1 platform
2 min readOct 29, 2016

Salesforce1 lets you view PDF documents if they are stored either as an attachment to a record or using Files app. However, if you have to generate a PDF document, dynamically (for e.g., Quote PDF), you are out of luck. Rendering a VF page as PDF doesn’t work well, unfortunately. So, I came up with a lightning component that displays any PDF content using the PDF.JS library.

You can download this component from this github repo. Use the ‘Deploy to Salesforce button’ in the repo to deploy to your org. Once deployed, go to <your org>/auradocs/reference.app->components->c->pdfViewer to go through the documentation on the usage of this component. There is also an example component provided as a part of the documentation. This component takes the PDF data in base64 format and displays it in the viewer. Try it out and let me know how it works

Now, the fine print.. At the time of writing this blog, I am employed with Salesforce as an Architect. However, any code samples and declarative approach provided here are purely for experimental purposes and comes with no warranty or support. Matter of fact, all opinions and approach provided in this blog are purely my own and has nothing to do with my employer. It is assumed that you have the right Salesforce configuration and coding skills and will use the ideas presented here as you see fit, in your landscape. The primary purpose of this article is just to share the knowledge and my own experience. Nothing more, nothing less. Use this approach at your own risk

--

--

KK Ramamoorthy
my journey with salesforce1 platform

Digital Tinkerer @awscloud; Love tech; it pays my bills as well, gadgets lover, handyman! Opinions are mine, not necessarily that of my employer