I am making a report, when I am generating the pdf, I tried to implement the margin, but it continues to cut the table in the middle and continues on the other page.
This is happening at the margin, even though I placing it continues to cut in the middle of the table
Thisismycontrollerwherethepdfisgenerated:
varpdf=newViewAsPdf{ViewName="TesteRelatorio",
PageSize = Size.A4,
IsGrayScale = true,
Model = abastecimento.ToPagedList(paginaNumero, abastecimento.Count),
};
return pdf;
My View:
@using PagedList.Mvc;
@model PagedList.IPagedList<BlogWeb.Models.Abastecimento>
@{ ViewBag.Title = "Relatório de Vendas";
Layout = "~/Views/Shared/_Layout2.cshtml"; }
<div style="page-break-after: always;">
<div class="panel panel-default">
<div class="panel-heading"><h4><b>Relatório Venda por Pedido/Período De: @ViewBag.dataInicio á @ViewBag.dataFinal </b></h4></div>
<div class="panel-body">
<div class="row">
<table id="customers">
<tr>
<th>Quant. Total (Litros):</th>
<th>Total (R$):</th>
<th>Total de Km Percorrido:</th>
<th>Media de Litro Consumido:</th>
</tr>
<tr>
<td>@Model.Sum(t => t.Litro)</td>
<td>@ViewBag.TotalGasto</td>
<td>@ViewBag.Total</td>
<td>@ViewBag.KmMedia</td>
</tr>
</table>
<div class="print">
<table id="customers">
<tr>
<th>N° Carro </th>
<th>Quant. </th>
<th>Km </th>
<th>Valor Unitário </th>
<th>Sub Total </th>
<th>Data Abastecimento </th>
</tr>
@{foreach (var item in Model)
{
<tr>
<td> @Html.DisplayFor(modelItem => item.NumCarro.NCarro) </td>
<td> @Html.DisplayFor(modelItem => item.Litro) </td>
<td> @Html.DisplayFor(modelItem => item.Km) </td>
<td> @Html.DisplayFor(modelItem => item.VlrUnit) </td>
<td> @Html.DisplayFor(modelItem => item.TotalGasto) </td>
<td> @Html.DisplayFor(modelItem => item.DtAbastecido) </td>
</tr>
}
}
</table>
</div>
</div>
</div>
</div>
</div>
Layout2:
<!DOCTYPE html>
Ribeira
</nav>
<header>
<h1>
Ribeira Beer Distribuidora de Bebidas Ltda
</h1>
</header>
<div class="print">
<div class="conteudo">
<main>
@RenderBody()
</main>
</div>
</div>
<div class="page-break">
<footer>
Copyright 2017 - RibeiraBeer
</footer>
</div>
@RenderSection("Scripts", false)
My CSS:
@import url(http://fonts.googleapis.com/css?family=Merriweather);
@import url(http://fonts.googleapis.com/css?family=Gloria+Hallelujah);
html{
height: 100%;
}
body {
min-height: 100%;
position: relative;
padding-bottom: 3em;
box-sizing: border-box;
}
header {
/* Altura 480 px largura: 1920 */
font-family: 'Gloria Hallelujah', cursive;
background-image: url(../Imagens/header.jpg);
background-position: center;
color: white;
padding: 1em;
padding-top: 4em;
}
nav {
position: absolute;
top: 0;
width: 100%;
background-color: rgba(0,0,0, 0.2);
}
nav a {
color: #ddd;
padding: 0.5em 0;
margin-right: 1em;
display:inline-block;
}
nav ul {
padding: 0;
margin:0 1em;
}
nav li {
display: inline-block;
}
main{
margin-bottom: 1em;
}
aside {
padding: 1em;
background-color: white;
}
div.static {
position: static;
}
footer{
padding: 1em;
background-color: #31385a;
color: white;
position: absolute;
bottom: 0;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
page-break-after: auto;
}
article {
background-color:white;
padding: 1em;
font-family: Merriweather, 'Times New Roman', serif;
}
.blog-post-meta{
margin-bottom: 1em;
color: #AAA;
}
h1 {
margin: 0;
font-size: 3em;
line-height:1em;
}
h2 {
margin: 0;
}
article + article {
margin-top: 1em;
}
.conteudo{
padding: 1em;
overflow: auto;
color: #333;
}
aside ul {
padding: 0;
}
aside li{
list-style:none;
margin-left: 1em;
margin-bottom: 0.25em;
}
table {
width: 100%;
margin: 1em 0;
}
tbody tr:hover{
background-color: #EEE;
}
tr + tr {
border-top:1px solid #CCC;
}
td {
padding: .5em;
}
td a:before{
font-size: 20px;
}
td a{
font-size: 0;
text-decoration: none;
}
th{
color: #666;
text-align: center;
}
label {
margin-top: 1em;
font-weight: bold;
display:inline-block;
margin-bottom: .25em;
color: #666;
}
input[type=checkbox]{
width: 1.25em;
height: 1.25em;
display: block;
}
[type=text],[type=password],textarea, select{
box-sizing: border-box;
width:20%;
border: 1px solid #CCC;
padding: .5em;
}
input[type=submit]{
padding: 0.5em 1em;
margin-top: 1em;
font-weight: bold;
color: white;
background-color:#31385a;
border: none;
}
.input-validation-error {
border-color: red;
background-color: #ffced2;
}
.field-validation-error, .field-validation-valid{
color: red;
display: block;
margin-top: .5em;
}
@media (min-width: 50em){
.conteudo {
width: 50em;
margin: 0 auto;
}
main{
float: left;
width: 35em;
}
aside {
width: 12em;
float: right;
}
td a {
font-size: 1em;
}
}
.pagination {
display: inline-block;
}
.pagination a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
}
.button {
background-color: #294a73;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
#customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers2 {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers td, #customers th {
border: 1px solid #ddd;
padding: 8px;
}
#customers2 td, #customers2 th {
border: 1px solid #ddd;
padding: 8px;
}
#customers tr:nth-child(even){background-color: #f2f2f2;}
#customers tr:hover {background-color: #ddd;}
#customers2 tr:nth-child(even){background-color: #f2f2f2;}
#customers2 tr:hover {background-color: #ddd;}
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #3e4e84;
color: white;
}
#customers2 th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: black;
color: white;
}
@media print {
* {
background: transparent !important;
color: #000 !important;
text-shadow: none !important;
filter:none !important;
-ms-filter: none !important;
}
body {
margin:0;
padding:0;
line-height: 1.4em;
font: 12pt Georgia, "Times New Roman", Times, serif;
color: #000;
}
@page {
margin: 1.5cm;
}
.wrap {
width: 100%;
margin: 0;
float: none !important;
}
.no-print, nav, footer, video, audio, object, embed {
display:none;
}
.print {
display: block;
}
img {
max-width: 100%;
}
aside {
display:block;
page-break-before: always;
}
h1 {
font-size: 24pt;
}
h2 {
font-size: 18pt;
}
h3 {
font-size: 14pt;
}
p {
font-size: 12pt;
widows: 3;
orphans: 3;
}
a, a:visited {
text-decoration: underline;
}
a:link:after, a:visited:after {
content: " (" attr(href) ") ";
}
p a {
word-wrap: break-word;
}
q:after {
content: " (" attr(cite) ")"
}
a:after, a[href^="javascript:"]:after, a[href^="#"]:after {
content: "";
}
.page-break {
page-break-before: always;
}
/*Estilos da Demo*/
.header.print h1{
width: 100%;
margin-bottom: 0.5cm;
font-size: 18pt;
}
.header.print:after {
content: "Bem vindo";
}
.artigo {
margin-top: 0;
border-top: 1px solid #000;
padding-top: 1cm;
}
h1 a:link:after, h1 a:visited:after {
content: "";
}
}