0

I have developed a bar chart using Chart.js library in lighting as standard dashboard doesn't help me to meet my requirements. I want to export to PDF with out using any other library.
I tried converting canvas to image(canvas.toDataURL method) and store it in attachment object and retrieve later in PDF. But got an exception(too long url to convert)

Is there a way to export customized chart in to PDF.

  • Am not exactly sure, but I read somewhere that Html2canvas can be used to screenshot screen and save as image. html2canvas.hertzen.com – Pranay Jaiswal Nov 18 '18 at 21:41
  • 2
    Salesforce's only PDF generation functionality is renderAs="pdf" on a Visualforce page. If that doesn't work for your use case - and I would be rather surprised if it did - you'll need to use some other type of functionality, whether that's another library, a document generation app, or an off-platform service. – David Reed Nov 18 '18 at 21:43
0

Salesforce's only PDF generation functionality is built around Visualforce pages. A Visualforce page can be set to renderAs="pdf" to always generate PDFs, or you can render a specific Visualforce page references as a PDF using the getContentAsPDF() method (which, incidentally but importantly, counts as a callout).

It's important to know as well that the PDF rendering library used by Salesforce is old and quirky, and lacks support for some modern web standards. I don't believe it supports JavaScript at all, although I cannot say I've tried it myself.

Put shortly, I don't think you have much in the way of options besides using another library, a document generation application, or an off-platform PDF service.

  • Thank you David. Visual force doesn't work with javascript chart rendering. Looking options for libraries now. – Alex Nov 20 '18 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.