fpanaccia / Wkhtmltopdf.NetCore.Example-deprecated

Implementation of Wkhtmltopdf.NetCore
81 stars 33 forks source link

How can I set the document name #9

Closed eskye closed 4 years ago

eskye commented 4 years ago

Hi

Have been trying to set a name for the document generated using the _generatePdf.GetByteArrayViewInHtml(). Please how can I go about this? Instead of the Document given as the default title when you preview or download, I want to be able to change it.

Screenshot (73)

Thanks.

fpanaccia commented 4 years ago

Hi, you could do something like this

        var pdf = await _generatePdf.GetByteArrayViewInHtml(htmlView, data);
        var pdfStream = new System.IO.MemoryStream();
        pdfStream.Write(pdf, 0, pdf.Length);
        pdfStream.Position = 0;
        return new FileStreamResult(pdfStream, "application/pdf") { FileDownloadName = "New Name.pdf" };
eskye commented 4 years ago

Thank you so much for the quick response, I will try it out and drop feedback here.