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?
If you are still having issues ive done more research on rotativa. You can use custom switches from wkhtmltopdf. Try and add
CustomSwitches = "--disable-smart-shrinking".
That stops the program from auto resizing your things. From there you can adjust your html page correctly to get the size you want on the pdf.