file download with custom action

Hi,
I would like to download a dynamically generated PDF like in the example below. Anyway the return type is bool thus this dowsn’t produce any effect. Some suggestion?

// Row Custom Action event
public bool Row_CustomAction(string action, Dictionary<string, object> row) {
    if (action == "star") { // Check action name
    Syncfusion.Pdf.PdfDocument doc = new Syncfusion.Pdf.PdfDocument();
                //Add a page.
                Syncfusion.Pdf.PdfPage page = doc.Pages.Add();
                Syncfusion.Pdf.Graphics.PdfGraphics graphics = page.Graphics;
                Syncfusion.Pdf.Graphics.PdfFont font = new Syncfusion.Pdf.Graphics.PdfStandardFont(Syncfusion.Pdf.Graphics.PdfFontFamily.Helvetica, 20);

                graphics.DrawString("Hello World!!!", font, Syncfusion.Pdf.Graphics.PdfBrushes.Black, new PointF(0, 0));
    
                MemoryStream stream = new MemoryStream();
                doc.Save(stream);


                stream.Position = 0;
                //Download the PDF document in the browser.
                FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf");
                fileStreamResult.FileDownloadName = "Sample.pdf";


                return true;
    }
    

    return true;
}

You should add your own API action to return the file:
https://aspnetmaker.dev/docs/#/customscripts.html?id=api_action

Thank you for the answer.
What is the best approach to consume the custom API from Row_CustomAction?

If you prefer to use Row_CustomAction rather than custom API action, you can, but you need to use your fileStreamResult, e.g.ActionResult = fileStreamResult;

For me it is perfectly fine to use custom API action. The question is: how to invoke from ListActions?

As explained:

If you prefer to use Row_CustomAction rather than custom API action, you can, but you need to use your fileStreamResult

So the codes in your Row_CustomAction should be like:ActionResult = …; // Return file stream result
return true;

Thank you, this I was trying already. The issue is that PDF output is getting printed (uncomprehensible text) inside popup. I am not manage to get it downloaded (Config.ActionAjax set in ListActions.Add)

If you want to output download file, do not use Ajax for the action, you should use Post Back.