There is no preview option in the detail view of the PDF Templates module. How do I generate the PDFs and preview them, I have created a PDF template but I see no option to view the preview or download the template as PDF. Iāve googled with this issue but with no success.
Then create a custom button on your custom module that calls the functions in your custom copy of MyCustomPdf.php.
(this will involve creating a custom controller and adding a custom action that includes MyCustomPdf.php)
edit MyCustomPdf.php to work with the fields in your custom module.
Thanks for lead Andy. Apologies for the late reply. The deadline got extended so got some time to explore.
I did it using the default āGenerate Letterā option in the detail view of Accounts. First had to create the template and then included the āGenerate Letterā option in my custom module and it generated the PDF for me. The only hitch though is I have several user entered line items in a particular subpanel. How do I include that in the PDF Template.
You will have to edit or create a new version of FormLetterPDF.php and alter the code in their to include the line items. Look at how its done in quotes and invoices and as I described above.
SpudR,
Hereās a detailed guide to how to generate a PDF out of a custom module for future reference
Add your Custom Module in the Type dropdown of PDF Template. This will help you select your custom module for creating a sample. You do this by editing the ā'pdf_template_type_domā through the dropdown editor from the admin panel. The āitem nameā must be the name of the module directory.
Add the default āGenerate Letterā link in the actions dropdown in the detail view page of the custom module. To do this, you have to first edit the /custom/modules/Custom_Module/metadata/detailviewdefs.php file of the custom module and include
Next on, add the generate letter functionality. To do this, edit the view.detail.php file in custom/module//Custom_Module/views directory. If there is no such file or directory create it. You can look at http://archive.h2ik.co/2012/03/sugarcrm-upgrade-safe-way-to-extend-views/ to how to create the file. Now add the following piece of code in the display() method,
Will,
I got what Andy was trying to say in #5725 as there is no point in providing a preview option in PDF Templates as ultimately youāll have to select the record against which you need a PDF. So I guess itās one and the same thing to go to the record and generate a PDF rather than have it generated from PDF Template. So didnāt include it in the Suggestion Box .
I made some changes in the formLetterPdf.php file and have attached the zip file. Please check if itās the correct method to proceed. Itās more of a workaround but as of now donāt have much time so have to go with it. Thereās just a minor issue.
Whenever I output the $template->description, it shows me the template text with the html tags, but when I pass the $addTable variable it doesnāt output the tags and displays the table directly. Also if I remove the āStrip out html tagsā in $search will it cause any abnormal behavior in the PDF output.
Iām going forward with the customization Iāve done as attached in the post above.
But there seems to be a bug when the Generate Letter option is selected from the Custom Module. It doesnāt seem to take the Security Suite permissions, because if I do not assign a PDF Template to a particular user who has only owner rights, it still shows up on clicking the Generate Letter option.
I think you will have to write the code yourself that checks for security Suite permissions, its not hard but I cant remember exaclty how its done off hand.
No problem. Iāll give it a try. Also I would really appreciate if you could take some time out and check the zip file I attached a couple of posts earlier to check if itās the correct flow Iāve created or if I need to change it.
it looks ok on first glance but Id really need to try and run it to fully understand whats going on and then advise you but I dont have time for that today.