Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotativa ViewAsPDF CSS Sizing / Dimensions

I am rendering an HTML View in ASP.Net MVC to PDF using Rotativa ViewAsPdf method. I am setting the ouput to be of A4 Size, Portrait and no margins, by setting:

new ViewAsPdf(MVCCfpFormatter.Members.Views.FlightPlansFullPagePrint, model)
                    {
                       // FileName = flightPlan.ListingItemDetailsModel.FlightDetails + ".pdf",
                        PageSize = Size.A4,
                        PageOrientation = Orientation.Portrait,
                        PageMargins = new Margins(0, 0, 0, 0),
                        PageWidth = 210,
                        PageHeight = 297
                    };

Then within the CSS, I am setting an element to have 210mm width, which should spread the entire width of the page, yet in the output PDF, the 210mm width is not representing the entire width of the PDF but less. By trial and error, the total width of the generated PDF seems to be around 246mm.

Any ideas why this could be happening?

like image 945
Mark Cassar Avatar asked Jul 08 '14 12:07

Mark Cassar


1 Answers

I think I can help you out.

 {
               FileName = Name + ".pdf",
               PageOrientation = Rotativa.Options.Orientation.Landscape,
               PageSize = Rotativa.Options.Size.A4

 }

Is what works for me with 1.6.3. Id imagine you would need to follow that syntax to set the other things you want.

like image 150
user2612373 Avatar answered Oct 17 '22 00:10

user2612373