2016-05-29 6 views
1

Ich benutze DOMPDF ver. 0.7.0, um eine PDF-Datei aus HTML zu erstellen, aber ich habe Probleme, wenn ich benutzerdefinierte Schriftart (Arial) mit Fettschrift verwenden muss. Die Fettschrift funktioniert nach dem Rendern nicht.Fettschrift für dompdf 0.7.0 beta

hier ist der CSS-Stil ich jetzt benutze:

@font-face { 
    font-family: 'font'; 
    font-style: normal; 
    font-weight: normal; 
    src: url(dompdf/font/arial.ttf); 
} 

@font-face { 
    font-family: 'font'; 
    font-style: normal; 
    font-weight: bold; 
    src: url(dompdf/font/arialbd.ttf); 
} 
body{ 
    font-family: 'font'; 
} 

und hier ist dompdf - PHP-Code:

require_once 'dompdf/autoload.inc.php'; 
use Dompdf\Dompdf; 
$dompdf = new Dompdf(); 
$dompdf->load_html($html); 
$dompdf->setPaper('A4', 'portrait'); 
$dompdf->render(); 
$pdf = $dompdf->output(); 
file_put_contents('pdf/sptjm.pdf', $pdf) 

hier ist das Ergebnis in HTML: enter image description here

und hier ist der Ergebnis in PDF: enter image description here

das pdf zeigte nicht den fetten Typ, bitte helfen Sie. Danke im Voraus.

+0

Wie sieht das HTML selbst aus? – BrianS

+0

@BrianS es ist gelöster Kumpel. Vielen Dank. – maghfirzakir

Antwort

0

ich es einfach mit unterschiedlichen Schrift Namen gemacht haben:

@font-face { 
    font-family: 'font'; 
    font-style: normal; 
    font-weight: normal; 
    src: url(dompdf/font/arial.ttf); 
} 

@font-face { 
    font-family: 'font2'; 
    font-style: normal; 
    font-weight: bold; 
    src: url(dompdf/font/arialbd.ttf); 
} 
body{ 
    font-family: 'font'; 
} 

so, wenn ich die fett Schriftart benötigen, rufen Sie einfach nur den anderen Schriftname ‚Cuz im Grunde ist es unterschiedliche Schriftquelle.

+0

Das * sollte * nicht notwendig sein, aber es wird funktionieren. – BrianS

+0

Ich habe das gleiche Problem. Verschiedene Schriftarten funktionieren. Aber warum funktioniert der gleiche Fontname nicht? Fehler? – Shawn