2017-07-04 3 views
0

Ich erstelle eine HTML-Tabelle, die mehrere Seiten lang sein kann.TCPDF-Tabellenheader schwebt nach Seitenumbruch

Auf der ersten Seite ist alles in einer Linie und sieht gut aus, aber nach dem ersten Seitenwechsel schwebt nur der Tabellenheader auf der linken Seite.

Ich habe versucht, der Tabelle eine feste Breite zu geben, um das Problem zu lösen, aber das hatte keine Auswirkungen.

Hier ein Screenshot, den Fehler zu präsentieren: the second page is a bit left and not in line with the other parts as displayed by the free hand circles!

ich keine Lösung für dieses Problem finden konnte, ich frage, wie so jetzt, es zu lösen, so dass der Kopf der Tabelle im Einklang mit der sich ausruhen.

Hier einige verkürzte Code, der die Tabelle erzeugt:

<!DOCTYPE html> 
<html> 
    <head> 
     <style> 
      h1 { 
       color: navy; 
       font-family: times; 
       font-size: 20pt; 
       text-decoration: underline; 
      } 
      .table { 
       font-family: courier; 
       font-size: 8pt; 
       background-color: #efefef; 
       width: 770px; 
      } 
      .table th {font-family: helvetica, arial; font-weight: bold; border: 1px solid #cccccc; } 
      .table td.normal {font-weight: normal} 
      .table td { 
       font-size: 8pt; 
       background-color: #ffffff; 
       vertical-align: top; 
      } 
      .table td.h4 { font-family: helvetica, arial; font-size: 12pt; font-weight: bold; } 
      .border-left-solid {border-left: 1px solid #cccccc;} 
      .border-right-solid {border-right: 1px solid #cccccc;} 
      .border-left-dashed {border-left: 1px dashed #cccccc;} 
      .border-bottom-solid {border-bottom: 1px solid #cccccc;} 
      .border-top-dotted {border-top: 1px dotted #cccccc;} 
      .text-center {text-align: center;} 
      .text-right {text-align: right;} 

     </style> 
     <title>Waypoints</title> 
    </head> 
    <body> 
     <table cellspacing="0" cellpadding="2" border="0" class="table" width="770px;"> 
      <thead></thead> 
      <tbody> 
       <tr> 
        <td width="50%" class="h4">Date from - Date to </td> 
        <td width="50%" class="h4">Last position:</td> 
       </tr> 
      </tbody> 
     </table> 
     <table cellspacing="0" cellpadding="2" border="0" class="table"> 
      <thead> 
      <tr> 
       <th width="40px;">Sometime</th> 
       <th width="260px;">Somewhere</th> 
       <th colspan="4" width="190px;">Some course</th> 
       <th width="60px;">extra information</th> 
       <th colspan="2" width="60px;">wind</th> 
       <th colspan="3" width="160px;">weather</th> 
      </tr> 
      <tr> 
       <th width="40px;"></th> 
       <th width="260px;"></th> 
       <th width="30px;">CoG</th> 
       <th width="50px;">SoG</th> 
       <th width="50px;">Log</th> 
       <th width="60px;">Status</th> 
       <th width="60px;"></th> 
       <th width="30px;">dir</th> 
       <th width="30px;">bft</th> 
       <th width="30px;">°C</th> 
       <th width="30px;">hPa</th> 
       <th width="100px;">sign.</th> 
      </tr> 
      </thead> 
      <tbody> 
       {% for waypoint in arrWaypoints %} 
       {# generation of the rows #} 
      </tbody> 
     </table> 
    </body> 
</html> 

Dies ist der Code, der die HTMLCell in TCPDF macht

durch Zugabe eines Seitenumbruch <br /> zwischen der
$html = $this->twig->render('@App/cruiselog/waypointTable.html.twig', array(
    'arrWaypoints' => $arrWaypoints, 
    'cruise' => $cruise, 
    'arrOverviewDayData' => $arrOverviewDayData 
)); 
$pdf->SetX(0); 
$pdf->writeHTMLCell(0,0,10,$pdf->GetY(),$html,0,1); 

Antwort

0

Ich reparierte habe das Problem zwei Tabellen

<table cellspacing="0" cellpadding="2" border="0" class="table" width="770px;"> 
    <thead></thead> 
    <tbody> 
     <tr> 
      <td width="50%" class="h4">Date from - Date to </td> 
      <td width="50%" class="h4">Last position:</td> 
     </tr> 
    </tbody> 
</table> 
<br /> 
<table cellspacing="0" cellpadding="2" border="0" class="table"> 
    <thead> 
     <tr> 
      <th width="40px;">Sometime</th> 
      <th width="260px;">Somewhere</th> 
      <th colspan="4" width="190px;">Some course</th> 
      <th width="60px;">extra information</th> 
      <th colspan="2" width="60px;">wind</th> 
      <th colspan="3" width="160px;">weather</th> 
     </tr> 
     <tr> 
      <th width="40px;"></th> 
      <th width="260px;"></th> 
      <th width="30px;">CoG</th> 
      <th width="50px;">SoG</th> 
      <th width="50px;">Log</th> 
      <th width="60px;">Status</th> 
      <th width="60px;"></th> 
      <th width="30px;">dir</th> 
      <th width="30px;">bft</th> 
      <th width="30px;">°C</th> 
      <th width="30px;">hPa</th> 
      <th width="100px;">sign.</th> 
     </tr> 
    </thead> 
    <tbody> 
     {% for waypoint in arrWaypoints %} 
     {# generation of the rows #} 
    </tbody> 
</table> 
Verwandte Themen