Razor view in asp.net version 6 prints a blank sheet

Viewed 19

I'm doing a print in razor view with ASP.NET Core 6.

I am having a problem, I have only one table to display data. And at the moment of making the impression, it does it perfectly, but it adds 2 sheets, 1 where the table is and the other blank. What I want to achieve is that it prints only the table, I don't want the blank page. I've been looking for a lot of information, but I'm new to printing. I'd be very glad if someone could give me some advice.

Thank you very much.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to- 
fit=no">
<meta name="description" content="">
<meta name="author" content="">
<style>
  .containerInfo {
    padding-top: 20px;
  }
  .primerSeccion {
    display: flex;
  }
  .segundaSeccion {
    display: flex;
  }
  .terceraSeccion {
    display: flex;
  }
  .cuartoSeccion {
    display: flex;
  }
  .quintaSeccion{
      display:flex;
  }
</style>
 </head>
 <body style="height: 210mm; width: 297mm; margin-left: auto; margin-right: auto">
   <div class="">
    <table style="width: 100%">
      <tr class="trColoridos">
        <th style="font-weight:700;">OR</th>
        <th style="font-weight:700;">Descripcion</th>
        <th style="font-weight:700;">Canti</t>
        <th style="font-weight:700;">Ancho</th>
        <th style="font-weight:700;">Altura</th>
        <th style="font-weight:700;">Metros</th>
        <th style="font-weight:700;">Acumulado</th>
        <th style="font-weight:700;">Unid</th>
        <th style="font-weight:700;">Bisel</th>
        <th style="font-weight:700;">Tipo:Arenado</th>
      </tr>
      <tbody>
       @foreach (var item in Model.PresupuestoDetalle)
        {
         <tr>
          <td style="text-align: center">@Html.DisplayFor(modelItem =>item.Presupuesto.Numero) </td>
          <td style="padding-left: 15px">@Html.DisplayFor(modelItem => item.Descripcion)</td>
          <td style="text-align: center">@Html.DisplayFor(modelItem => item.Cantidad)</td>
          <td style="text-align: center">@Html.DisplayFor(modelItem => item.Ancho)</td>
          <td style="text-align: center">@Html.DisplayFor(modelItem => item.Alto)</td>
          <td style="text-align: center">@Html.DisplayFor(modelItem => item.Metros)</td>
          <td style="text-align: center"></td>
          <td style="text-align: center">  </td>
          <td style="text-align: center"></td>
          <td style="text-align: center"></td>
        </tr>
        }
      </tbody>
    </table>
  </div>
 </body>
 </html>

enter image description here

1 Answers

Try to add the following code to <style></style>:

@@media print {
            html, body {
                border: 1px solid white;
                height: 99%;
                page-break-after: avoid;
                page-break-before: avoid;
            }
        }
Related