CSS Sizes and Sizes for Rotativa ViewAsPDF

I am processing the HTML representation in ASP.Net MVC in PDF using the Rotativa ViewAsPdf method. I set the output from A4, Portrait and borderless 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 in CSS, I set an element with a width of 210mm , which should extend the entire width of the page, but in the output PDF format, the width of 210mm does not represent the entire width of the PDF file but less. According to the results of trial and error, the total width of the generated PDF file is about 246mm .

Any ideas why this could be happening?

+10
asp.net-mvc asp.net-mvc-4 rotativa
source share
3 answers

If you still have problems, do more rotative research. You can use custom switches from wkhtmltopdf. Try to add

 CustomSwitches = "--disable-smart-shrinking". 

This allows the program to automatically resize your items. From there, you can correctly configure the html page to get the desired size in pdf format.

+11
source share

I think I can help you.

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

What works for me with 1.6.3. Id imagine you would need to follow this syntax in order to set up other things you want.

+3
source share

if you are using MVC 4, use this format

  public ActionResult yourAction() { var yourModel; var yourpdf= new PartialViewAsPdf(yourModel) { RotativaOptions = new DriverOptions() { PageOrientation=Orientation.Landscape, PageSize = Size.A4, IsLowQuality=true and other your Customiz } }; return yourpdf; } 
0
source share

All Articles