Rotativa.AspNetCore
Rotativa.AspNetCore copied to clipboard
Multi-page bleeds over
Printing/displaying multi-page contents seems to bleed over to the next page, so the contents from the previous page over writes the html headers of the next page.
Please see below the code I use to create the PDF:
var htmlContent = await _helperService.GetHtmlContent(columnNames, fileNotes); var WkhtmlPath = Path.Combine(_hostingEnvironment.ContentRootPath, "WkHtmlToPdf"); var switches = "-s A4 -O Landscape -T 5 -B 5 --minimum-font-size 12 --header-font-size 14 --header-spacing 4"; var result = WkhtmltopdfDriver.ConvertHtml(WkhtmlPath, switches, htmlContent); var cd = new System.Net.Mime.ContentDisposition { FileName = model.Options?.SelectedOptions != null ? $"{nameof(fileNotes)}-{model.Options.SelectedOptions}-{DateTime.Now.ToShortDateString()}.pdf" : $"{nameof(fileNotes)}-{DateTime.Now.ToShortDateString()}.pdf", Inline = false, // false = prompt the user for downloading; true = browser to try to show the file inline CreationDate = DateTime.Now, Size = result.LongLength, ModificationDate = DateTime.Now, }; Response.Headers.Add("Content-Disposition", cd.ToString()); Response.Headers.Add("X-Content-Type-Options", "nosniff"); return File(result, "application/pdf");
Some solution for this ?
Anyone found a solution to this please share?
Hello. I found the answer. Add this to you css file:
tr {
page-break-inside: avoid !important;
}
or do this if you prefer: <tr style="page-break-inside: avoid !important">