My logo is a short string in Palatino Linotype Roman ("bbros") with
just 4 different chars, but Palatino font takes 300kb in my PDF files.
I've created a short map of that font simply cutting /usr/local/share/
ttf2pt1/maps/CP1250.map file into a new file, that I called logo.map
and it contains just the following four rows:
!62 U+0062 b
!6F U+006F o
!72 U+0072 r
!73 U+0073 s
Then I ran ttf2pt1 with the following paramters
ttf2pt1 -b -L logo.map pala.ttf
and I've obtained a compressed pala.pfb and I gained a smaller PDF of
about 300kb less.
I tried to do the same with the other fonts, used often in the
document (like Verdana), but I had more issues than other, so I decide
to do the subset only for the logo.
I feel like suggesting you to use always "ttf2pt1 -b" to earn same
byte.
This is definitely something I would like to do in the future. With so
many other problems to work out, though, this one will have to wait a
few releases until we have the time. We'll keep your post in mind,
though, so that we have a good starting point for working out what we
need to do in order to subset fonts. Thanks for looking into this and
sharing the information.
-b
Also I update my php scripts in this way:
$process = proc_open("/usr/bin/ps2pdf - -", array(0 => array("pipe",
"r"), 1 => array("pipe", "w"), 2 => array("file", "/tmp/error.log",
"a")), $pipes);
if ( is_resource($process) ) {
fwrite($pipes[0], $dompdf->output());
fclose($pipes[0]);
$pdf_output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($process);
$output->stream($pdf_output);
}
else {
$pdf_output = $dompdf->output();
$dompdf->stream($filename, array('Attachment' => 0));
}
$repository->save_as($pdf_output, $filename);
$output and $repository are two my classes, they aren't dompdf object.
I put they there just for example.
:) Really nice small pdf! :)
The best way is to process the output in dompdf.cls.php, so you can
"stream" or "output" without add this patch all the times.
but.. where should I put it?? in each adapters?
Bye!
Federico
> -b- Nascondi testo citato
>
> - Mostra testo citato -
If I wanted to add this functionality inline with DOMPDF I would
consider adding a new method to the adapters. That way you can easily
use the new functionality while still having access to the original
methods.