andyhutch77 / MvcRazorToPdf

Create pdf documents within an asp .net mvc project by generating your views as normal but returning a PdfActionResult. This converts regular produced razor/html to pdf documents in the browser using the iTextXmlWorker.
125 stars 105 forks source link

How to create new page in MvcRazorToPdf? #33

Closed NessfertIndia closed 9 years ago

NessfertIndia commented 9 years ago

My code for generating pdf file is this:

public ActionResult Print(int id) { var record = db.Records.Find(id); return new PdfActionResult(record, (writer, document) => { document.SetPageSize(new Rectangle(600f, 400f, 90)); document.NewPage(); }); }

How to return a PdfActionResult with multiple pages for each record if i have a list of records? Either from controller itself or from Razor html page ? I have'nt seen any options in documentation

andyhutch77 commented 9 years ago

Hi, I usually use CSS page breaks to control content on new pages.

page-break-before, page-break-after

I would do a loop and output page-break-after.

I think I got the original idea from here:

http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html