2016-04-11 13 views
2

Ich entwickle ein Reiseportal und es ist wichtig, ein PDF-Ticket für die Buchung zu machen. Ich habe Dompdf und tcPdf benutzt. Aber es gibt Entwurfsfehler in exportiertem pdf von beiden Bibliotheken.Designfehler im PDF-Export - Dompdf/tcpdf

Dies ist mein eigentliches HTML-Design
enter image description here

Dies ist das erzeugte PDF

enter image description here

Mein HTML Design Code

<table class="col-xs-12 other-table" style="text-align:left"> 
    <tr> 
    <td>TICKET ID</td> 
    <td>&nbsp;</td> 
    <td><span>LD324865</span></td> 
    <td></td> 
    <td></td> 
    <td></td> 
    </tr> 
    <tr> 
    <td>PACKAGE NAME</td> 
    <td>&nbsp;</td> 
    <td><span>LAKSHADWEEP SUMMER PACKAGE</span></td> 
    <td></td> 
    <td></td> 
    <td></td> 
    </tr> 
    <tr> 
    <td>DATE OF BOOKING</td> 
    <td>&nbsp;</td> 
    <td><span>28 May 2016</span></td> 
    <td>DATE OF JOURNEY</td> 
    <td>&nbsp;</td> 
    <td><span>31 May 2016</span></td> 
    </tr> 
</table> 
<style> 
.grey-color{ 
color:#666; 
} 
.total-cost{font-size:18px} 
.address{ 
font-size:11px; 
} 
.heading{ 
border-bottom:1px #CCCCCC solid; 
} 
.package-name{ 
font-size:15px; 
margin:15px 0px; 
} 
.package-name span{ 
    padding:10px !important;background:#EAEAEA; 
} 
.table{font-size:14px} 
.other-table td{padding: 12px 0px !important;font-size:12px} 
.other-table span{background:#EAEAEA;padding:16px !important;} 
.uppercase{text-transform:uppercase !important;} 

</style> 

PHP-Code für die PDF-Erzeugung

<?php 
require_once 'dompdf/autoload.inc.php'; 


// reference the Dompdf namespace 
use Dompdf\Dompdf; 

// instantiate and use the dompdf class 
$dompdf = new Dompdf(); 
$html = file_get_contents('holiday.html'); 
$dompdf->loadHtml($html); 


// (Optional) Setup the paper size and orientation 
$dompdf->setPaper('A4', 'portrait'); 

// Render the HTML as PDF 
$dompdf->render(); 

// Output the generated PDF to Browser 
$dompdf->stream(); 
?> 

Wie man ein korrektes pdf-Design bekommen? Ich möchte keine bezahlte Bibliothek. Gibt es eine andere PHP PDF-Bibliothek, um dies zu tun?

Antwort

1

dompdf hat derzeit (bis einschließlich 0.7.0) keine gute Unterstützung für das Auffüllen von Inline-Elementen. Sie können zu einem Blockelement (einem P oder DIV) wechseln und bessere Ergebnisse sehen.

Mit 0.7.0 können Sie auch den Stil korrigieren, indem Sie den Anzeigestil span auf Inline-Block einstellen.

+0

Ich habe versucht, mein Layout mit div, span und p. Jetzt ist es nicht schlecht! – Dino

Verwandte Themen