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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot change page layout

RafPe opened this issue · comments

Hey ,

I'm having issues with generating PDF which would not look like A4 . So whatever I set as value in document it always gets the same layout as PDF

This is how I try to return PDF

        return new PdfActionResult(outputLayout,outInvoiceModel, (writer, document) =>
           {

               //document.SetPageSize(new iTextSharp.text.Rectangle(500f, 500f, 90));
               document.SetPageSize(iTextSharp.text.PageSize.GetRectangle("LETTER_LANDSCAPE"));
               document.NewPage();

           })
           {
               FileDownloadName = "ElanWasHere.pdf"
           };

Is this possible I have something wrong in View ?

Ok - I have found a way to do that. I had to use the following
document.SetPageSize(PageSize.A4.Rotate());
and then it worked!