I have landing page which uses AmpScript and SSJS to displays result of filter on anather landing page in form of table. Is there any way I can save/download this table as pdf or any other format using AmpScript and SSJS on users machine.
2 Answers
AFAIK, there's nothing in Server-Side SFMC scripting (SSJS or AMPScript) that accommodate this. You might check out these threads:
I haven't thought about this from a PDF extract perspective but I have often asked the same question in terms of serve side solutions. Unfortunately, ET doesn't give much any the way of web service extract tools so we have to turn to a client side solution.
Regarding a format such a CSV extract, until recently I settled for doing an manual extract or (query activity) to another data extension but then I thought about screen scraping tools that could extract directly what the browser rendered.
There are such paid tools such as Outwit Hub (http://www.outwit.com) used for harvesting data collection on the web and such extract processes could be automated if desired. However, in the simpler and free category you can build form based elements such as dropdowns or date calendar pickers to perform a filter on the data that the AMPSCRIPT or SSJS would display on the page.
Then if you were interested in a CSV extract you could use one of these.
a) http://www.jqueryscript.net/table/jQuery-Plugin-To-Convert-HTML-Table-To-CSV-tabletoCSV.html
b) gist.github.com/TechplexEngineer/f2aaa7bf307eec95ad18
(this one requires a bit of tweaking to filter out the carriage returns line feed that might be present)
The downside of generating an extract like this is that it is being exported using the "browser's" memory and javascript engine so there is a cap limitation on how much data could be extracted so you will definitely need to limit the data being displayed (i think I saw this max out at 4000 records and there were about 12 columns of data with varying column size). So if you have 20000+ total records of data you could make this work by creating a table pagination mechanism (either by record number or by date) using SSJS or AMPSCRIPT lookup functions and then export the data for each page of data displayed.
A PDF extract plugin could be done in JQuery but it would have some of the same memory limitation as the csv if it's not driven by the server side action.