Rank: Member Groups: Member
Joined: 2/17/2013 Posts: 14
|
LS, I'm trying to get the RenderAsPDF result in a variable or other way so I can attach this PDF to an email pseudo code example:
Code: C#
public ActionResult Confirmed()
{
var model = getModelData();
var pdfFile = RenderAsPdfResult(DetailsOfConfirmationView);
mailToClient(pdfFile);
return View(model);
}
[RenderAsPDF]
public ActionResult DetailsOfConfirmationView()
{
var model = getDetailsData();
return View(model);
}
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
In that case you don't need to use RenderAsPDF attribute. What you will need to do is to render the View into a string, then call HtmlToPdf.ConvertHtml to convert that HTML string into PDF. You will also need to set HtmlToPdf.Options.BaseUrl correctly in order for the converter to correctly resolve relative path (of images, style files, script, etc).
Thanks!
|
Rank: Member Groups: Member
Joined: 2/17/2013 Posts: 14
|
That works like a charm!!!
Thanks once again for the quick reply!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are welcome! Please feel free to let us know if there is anything else.
|