Rotativa

Install Rotativa menggunakan NuGet

Capture

Pilih yang dibuat oleh Giorgio Bozio.

Contoh:

[code language=”csharp”]
[HttpPost]
public ActionResult Download(ManufacturerDownloadFormStub model)
{
List<int> subcategoryId = model.GetSubcategoryIdArray();
DisplayFormatHelper dfh = new DisplayFormatHelper();

return new Rotativa.ActionAsPdf("ManufacturerPdf", new { subcategoryId = model.SubcategoryIdString })
{
FileName = "AML (" + DateTime.Now.ToString(dfh.FullDateFormat) + ").pdf",
PageOrientation = Rotativa.Options.Orientation.Portrait,
PageSize = Rotativa.Options.Size.A4,
CustomSwitches = string.Format("–footer-right \"[page] / [toPage]\" "
+ "–footer-font-size \"8\" "
+ "–footer-spacing \"3\" ")
};
}

public ViewResult ManufacturerPdf(string subcategoryId)
{
ManufacturerDownloadFormStub downloadForm = new ManufacturerDownloadFormStub { SubcategoryIdString = subcategoryId };
List<vendor_subcategory> dbItem = null;
List<int> subcategoryIdArray = downloadForm.GetSubcategoryIdArray();

if (subcategoryIdArray != null && subcategoryIdArray.Count() > 0)
dbItem = RepoLicensor.FindVendorSubcategory(subcategoryIdArray);

ManufacturerPdfModel model = new ManufacturerPdfModel();
model.Parse(dbItem);

return View(model);
}

[/code]

Parameter yang dikirim ke ManufacturerPdf amannya berupa string. Sempat dicoba mengirimkan List<int> tidak terbaca.

Chandra Oemaryadi has written 244 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>