Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

How can I set the document name #9

Closed
eskye opened this issue Aug 29, 2020 · 2 comments
Closed

How can I set the document name #9

eskye opened this issue Aug 29, 2020 · 2 comments

Comments

@eskye
Copy link

eskye commented Aug 29, 2020

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
Copy link
Owner

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
Copy link
Author

eskye commented Aug 31, 2020

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

@eskye eskye closed this as completed Sep 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants