Welcome Guest Search | Active Topics | Sign In | Register

PDF from MVC5 controller Options
Hazze
Posted: Wednesday, June 3, 2015 11:29:32 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2015
Posts: 2
I cant find an example where I can learn how to, in a mvc controller method:

1. create new pdf file, add som data
2. return it to browser as downloadable file

I can create the pdf from your example, but what next in the mvc controller method?

Code: C#
public ActionResult GetPdf() {
    //Create a new document
    PdfDocument doc = new PdfDocument();

    //Create a new render
    AcmRender render = new AcmRender(doc);

    //Create some contents
    AcmContent content = new AcmContent(new AcmText("Hello!"));

    //Render the content
    render.Render(content);

    //Instead of saving the document to a local file, here it 
    //saves the document to output stream of the current
    //HttpResponse object. It also set the content type as
    //"application/pdf"
    HttpResponse response = HttpContext.Current.Response;
    response.Clear();
    response.ClearHeaders();
    response.ContentType = "application/pdf";
    doc.Save(response.OutputStream);

    return File.....() // what???
}


Pls, give us better examples how to use this, on MVC

// Hazze
eo_support
Posted: Wednesday, June 3, 2015 2:02:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
You may want to search online on how to send dynamically generated contents to the client side as a downloadable file. What EO.Pdf does is the step before that: dynamically generating the content you wish to send, but as the actual sending step it is a rather generic programming question that does not have anything to do with EO.Pdf. As such it is both beyond the scope of our support and the scope of our expertise, sorry about it!
Hazze
Posted: Thursday, June 4, 2015 2:49:48 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2015
Posts: 2
ok... I can see you have examples on how to use your tool, for MVC:

http://www.essentialobjects.com/doc/4/web/mvc.aspx#conditional

The tool is called mvctopdf:

http://www.essentialobjects.com/Products/EOPdf/MVCToPDF.aspx

And I am missing the part where I can get the file to download to the client... But I solved it...

Why cant you have that as an example, so it is easy for newbies to use your tools?

More examples for MVC would be nice...
eo_support
Posted: Thursday, June 4, 2015 10:17:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

The example you found is very different than what you asked originally. We will always try to have as much sample as possible, but you must understand there are millions different real life scenarios and it is not possible for us to cover them all. As such please always expect that you may need to adapt our samples to fit your need. And one way to do this effectively is to clearly see the boundary of our product so that we can focus on our side and you can focus on your side.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.