Skip to main content

I want to read data from json and write it in pdf. Is there a way I can do it? Also, i want to make pdf downloadable.

1 resposta
  1. 15 de nov. de 2021, 16:20

    Yes... reading data from json is very easy... firstly you can parse the json to a map and then use the results accordingly. Refer this once- 

    https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Json.htm

     

    Then you can write things in a vf and render it as pdf. 

    https://developer.salesforce.com/docs/atlas.en-us.234.0.pages.meta/pages/pages_output_pdf_renderas.htm

     

    You can generate a PDF in Lightning Component in two ways.

    • You can create a Visualforce page with render as pdf and embed it in the Lightning component.

    https://medium.com/@ToAnshulVerma/salesforce-lightning-generate-pdf-from-lightning-components-with-in-memory-data-cd5dffe0fe25  http://www.vermanshul.com/2017/07/lightning-generate-pdf-from-lightning.html  

    • Use PDF.JS library or other javascript libraries to render pdf.

    https://github.com/kumarrk21/PDFViewer

0/9000