Rotativa.AspNetCore icon indicating copy to clipboard operation
Rotativa.AspNetCore copied to clipboard

Multi-page bleeds over

Open Binary-Man opened this issue 6 years ago • 3 comments

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");

Binary-Man avatar Feb 14 '19 17:02 Binary-Man

Some solution for this ?

DiegoVenancioVieira avatar Dec 02 '19 13:12 DiegoVenancioVieira

Anyone found a solution to this please share?

coommark avatar Jan 22 '20 18:01 coommark

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">

coommark avatar Jan 23 '20 07:01 coommark