php - Dompdf and set different font-family -


when generating pdf totally ignores font-family attribute applied css. instead of verdana, uses times new roman. css like:

.sub-header {     font-size: 1.4rem;     text-transform: uppercase;     font-family: neutratext-book !important;     padding-bottom: 1.5rem; } 

the pdf generated this:

$pdf = pdf::loadhtml($view); return $pdf->stream(); 

how can set font want?

pdf documents internally support following fonts: helvetica, times-roman, courier, zapf-dingbats, & symbol (all using windows ansi encoding). dompdf embed referenced font in pdf long has been pre-loaded or accessible dompdf , referenced in css @font-face rule. loading process necessary in order produce font metrics used type setting.

dompdf supports same fonts underlying r&os pdf class: type 1 (.pfb) , truetype (.ttf) long font metrics (.afm/.ufm) available. bundled, php-based php-font-lib provides support loading , sub-setting fonts.

the process loading font varies depending on needs , server access. there 3 ways can load font:

  1. use css @font-face rules load font @ run-time.
  2. from command line use dompdf/load_font.php.
  3. browse dompdf/www/fonts.php in included admin site.

use css @font-face rules load font @ run-time

no command line access required. long font want load available online can load via css.

@font-face {   font-family: 'open sans';   font-style: normal;   font-weight: normal;   src: url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cjzkeoubrn4kerxqtauh3acwcynf_cdxxwclxiixg1c.ttf) format('truetype'); } 

from command line use dompdf/load_font.php

if have access command line loading font simple as:

[php] load_font.php "neutratext-book" /path/to/neutratext.ttf 

run command without parameters see text. quickly, though, parameters are: name of font, normal font file, bold font file, italic font file, bold-italic font file

browse dompdf/www/fonts.php in included admin site

self-explanatory (sample). thing need make sure you've modified admin username/password combo


note: load_font.php , admin site not included default starting dompdf 0.7.0

adapted dompdf wiki (unicode how-to, about fonts , character encoding) , other sources.


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -