Change Filename PDF Export

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
nabilahasna
User
Posts: 220
Contact:

Change Filename PDF Export

Post by nabilahasna »

Hi

I want to change Change Filename PDF Export (in default tabel_namelist.pdf)
i have filename format (tabel_name_currentdate())
How to do that (V.2022)

TIA


mobhar
User
Posts: 11660

Post by mobhar »

You may search in this forum by using ExportFileName keyword.


nabilahasna
User
Posts: 220
Contact:

Post by nabilahasna »

Thank You

in listpage--> page_load

global $ExportFileName;
$ExportFileName = "my_filename";

but still default filename not my_filename
i use custom template

Any Hint?

TIA


mobhar
User
Posts: 11660

Post by mobhar »

From the documentation of Custom Templates, see Important Notes #7:

Custom Template does NOT support the following:
Export to CSV/HTML/XML/PDF and Export to Excel (the data is exported in original tabular format)


mobhar
User
Posts: 11660

Post by mobhar »

In addition, put your code in Page_Exporting server event instead.


nabilahasna
User
Posts: 220
Contact:

Post by nabilahasna »

Now its clear to me.. thank you so much..

in listpage-->Page_Exporting

global $ExportFileName;
$ExportFileName = "my_filename";
return true;

but still not work (i check every related file with export function i.e. ewpdf.css, exportpdf.php etc).. otherwise there is no way to change filename

TIA


mobhar
User
Posts: 11660

Post by mobhar »

It should work properly, as I've just tried it, and it works successfully.

Make sure you have already enabled dompdf extension from Tools -> Extensions -> Type: PDF Export, then click on Advanced tab setting of the extension, and make sure you have already enabled ExportList and ExportView options for that table.

After that, re-generate ALL the script files, and try again.


nabilahasna
User
Posts: 220
Contact:

Post by nabilahasna »

Thank You for your reponse
i have enable all option but still not working
and i have asked to phpmaker support with sample database and project sample

then give sample like

listpage--> clientscript

$(document).trigger("rendertemplate", (e, args) => args.class = "my_filename ");

what is rendertemplate? when i inspect element only tpm_printlist under <template> tag

Any Hint?
TIA


mobhar
User
Posts: 11660

Post by mobhar »

From the documentation of Custom Templates, see Important Notes #6:

Before the Custom Template is applied, the jQuery event "rendertemplate" will be fired, you can use Client Script of the page (see Server Events and Client Scripts) to subscribe this event and pass custom data to the Custom Template, e.g.
$(document).on("rendertemplate", (e, args) => { if (args.template && args.data) args.data.myVar = "myValue"; });


Post Reply