characters messed up?

137 views
Skip to first unread message

CodilX

unread,
Feb 19, 2010, 8:40:11 AM2/19/10
to dompdf
hi there,

i can't get characters like ų ė to show up, instead they become
question marks.

can somebody help me out with this?

BrianS

unread,
Feb 19, 2010, 11:23:40 AM2/19/10
to dompdf

Which version of DOMPDF? The default character set available is fairly
limited (i.e. a subset of Windows-1252). There are two methods of
increasing character set support:
1) use a differences array
2) use DOMPDF 0.6.0 alpha 2, enable unicode, add a new font using
load_font.php

The first option is somewhat complex because you are essentially using
character replacement. Unfortunately, it's your only option with
DOMPDF 0.5.1. Luca Priorelli has a pretty good post about how to do
this: http://luca.priorelli.com/

The second option can also be somewhat complex, because you have to
ensure that ttf2ufm (ttf2pt1 modified with Unicode support) is running
on your system. Beyond that, though, it is a much better option.

CodilX

unread,
Feb 19, 2010, 5:27:20 PM2/19/10
to dompdf
Thank you for your reply,

I've tried adding a new font.. but i'm getting nowhere :/

can someone help me with this? how exactly do I make the font? how do
I include it and us it the right way?

Thanks

BrianS

unread,
Feb 19, 2010, 6:45:13 PM2/19/10
to dompdf

What OS are you using? Currently ttf2ufm (which you need in order to
install new fonts) only works on linux systems. If you're on a linux
system you will also need shell access. You can't install a new font
over the web.

Briefly, here are the steps:
1) ensure your system has ttf2ufm
2) configure dompdf_config.inc so that TTF2AFM points to the ttf2ufm
executable
3) ensure that the font file is in an accessible location
3) execute load_font.php as described in the documentation

The documentation related to font installation can be found here:
http://code.google.com/p/dompdf/wiki/Installation

CodilX

unread,
Feb 20, 2010, 3:37:57 AM2/20/10
to dompdf
Well i'm currently running on windows but i also have linux. If i
convert the font in linux, can i use it in windows?

Also, i'm trying to add the Times font with character support, after i
convert the font, how do i include it properly for use?

And.. If i try to use the conversion array thing, how do i specify new
characters? I need ęėįūšžč, or are they in the array? And .. Do i have
to change that string in 4 places along with the array?

Thanks

leny bernard

unread,
Feb 21, 2010, 1:30:49 PM2/21/10
to dompdf
Hello,
I have the same encoding error... I'm under linux (ubuntu) and there
is no way to get properly what I want...
I tried to download ttf2pt1 because it didn't exist in the download's
archive, there is only an .exe file named tt2ufm.exe. I also changed
the path TT2AFM in the config file.
Nothing's good...
First I do not understand the concept : why can't I use the fonts
which used to work well, even with tcpdf I already used...
I'm lost, if you already get this error, please help me/us.
Thanks

BrianS

unread,
Feb 24, 2010, 2:31:42 PM2/24/10
to dompdf
On Feb 20, 3:37 am, CodilX <cod...@gmail.com> wrote:
> On Feb 20, 1:45 am, BrianS <eclecticg...@gmail.com> wrote:
>
> > On Feb 19, 5:27 pm, CodilX <cod...@gmail.com> wrote:
>
> > > On Feb 19, 6:23 pm, BrianS <eclecticg...@gmail.com> wrote:
>
> > > > On Feb 19, 8:40 am, CodilX <cod...@gmail.com> wrote:
>
> > > > > hi there,
>
> > > > > i can't get characters like ų ė to show up, instead they become
> > > > > question marks.
>
> > > > > can somebody help me out with this?
>
> > > > Which version of DOMPDF? The default character set available is fairly
> > > > limited (i.e. a subset of Windows-1252). There are two methods of
> > > > increasing character set support:
> > > > 1) use a differences array
> > > > 2) use DOMPDF 0.6.0 alpha 2, enable unicode, add a new font using
> > > > load_font.php
>
> > > > The first option is somewhat complex because you are essentially using
> > > > character replacement. Unfortunately, it's your only option with
> > > > DOMPDF 0.5.1. Luca Priorelli has a pretty good post about how to do
> > > > this:http://luca.priorelli.com/
>
> > > > The second option can also be somewhat complex, because you have to
> > > > ensure thatttf2ufm(ttf2pt1 modified with Unicode support) is running

> > > > on your system. Beyond that, though, it is a much better option.
>
> > > Thank you for your reply,
>
> > > I've tried adding a new font.. but i'm getting nowhere :/
>
> > > can someone help me with this? how exactly do I make the font? how do
> > > I include it and us it the right way?
>
> > > Thanks
>
> > What OS are you using? Currentlyttf2ufm(which you need in order to

> > install new fonts) only works on linux systems. If you're on a linux
> > system you will also need shell access. You can't install a new font
> > over the web.
>
> > Briefly, here are the steps:
> > 1) ensure your system hasttf2ufm
> > 2) configure dompdf_config.inc so that TTF2AFM points to thettf2ufm
> > executable
> > 3) ensure that the font file is in an accessible location
> > 3) execute load_font.php as described in the documentation
>
> > The documentation related to font installation can be found here:http://code.google.com/p/dompdf/wiki/Installation
>
> Well i'm currently running on windows but i also have linux. If i
> convert the font in linux, can i use it in windows?
>
> Also, i'm trying to add the Times font with character support, after i
> convert the font, how do i include it properly for use?
>
> And.. If i try to use the conversion array thing, how do i specify new
> characters? I need ęėįūšžč, or are they in the array? And .. Do i have
> to change that string in 4 places along with the array?
>
> Thanks
>

The files produced by load_font.php should be portable. So if you want
to set it up on linux and copy to your Windows system you should be
able to do so. Also note the recent release of a web-based tool to
prepare the fonts for you. See the following post:
http://groups.google.com/group/dompdf/browse_thread/thread/9f7bc0162b04d5cf

I'm not sure what will happen if you use the Times font since it is a
core font, but it doesn't hurt to try. After you install a font, you
only need to reference it in your CSS using the name you supplied
during installation. If specifying "Times" doesn't work you could
always install with an alternate name like "Times Expanded" or
something like that.

Take a look at this post on Luca's site for directions on using the
differences array. If you decide to give it a try, but you're still
having problems, let me know and I'll try to help you out more. I
haven't used this particular feature, so it's something I'll need to
research more.
http://luca.priorelli.com/lang/en-us/2009/05/19/dompdf-justification-extended-ascii-chars/

BrianS

unread,
Feb 24, 2010, 2:33:39 PM2/24/10
to dompdf
> > > > > ensure thatttf2ufm(ttf2pt1 modified with Unicode support) is running

> > > > > on your system. Beyond that, though, it is a much better option.
>
> > > > Thank you for your reply,
>
> > > > I've tried adding a new font.. but i'm getting nowhere :/
>
> > > > can someone help me with this? how exactly do I make the font? how do
> > > > I include it and us it the right way?
>
> > > > Thanks
>
> > > What OS are you using? Currentlyttf2ufm(which you need in order to

> > > install new fonts) only works on linux systems. If you're on a linux
> > > system you will also need shell access. You can't install a new font
> > > over the web.
>
> > > Briefly, here are the steps:
> > > 1) ensure your system hasttf2ufm
> > > 2) configure dompdf_config.inc so that TTF2AFM points to thettf2ufm
> > > executable
> > > 3) ensure that the font file is in an accessible location
> > > 3) execute load_font.php as described in the documentation
>
> > > The documentation related to font installation can be found here:http://code.google.com/p/dompdf/wiki/Installation
>
> Hello,
> I have the same encoding error... I'm under linux (ubuntu) and there
> is no way to get properly what I want...
> I tried to download ttf2pt1 because it didn't exist in the download's
> archive, there is only an .exe file named tt2ufm.exe. I also changed
> the path TT2AFM in the config file.
> Nothing's good...
> First I do not understand the concept : why can't I use the fonts
> which used to work well, even with tcpdf I already used...
> I'm lost, if you already get this error, please help me/us.
> Thanks

You probably can use the files produced by tcpdf, but I'm not familiar
enough with the output to say for sure. This is probably something
that is worth us looking into. In the meantime, however, maybe the new
web-based tool can help you out:
http://groups.google.com/group/dompdf/browse_thread/thread/9f7bc0162b04d5cf

CodilX

unread,
Feb 25, 2010, 5:29:05 AM2/25/10
to dompdf
I've followed the instructions on the site, I've uploaded the fonts
and cache file, but it still shows up messed up.

How do I correctly specify the font? my current setup is:

$output='
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<style type="text/css">
body
{
padding: 2cm 1cm 2cm 3cm;
font-family: "Times Custom";
}
</style>
</head>
<body>

ąčęėįšųūž

</body>
</html>';

$dompdf = new DOMPDF();
$dompdf->load_html($output);
$dompdf->render();
$dompdf->stream("test.pdf", array("Attachment" => 0));

> web-based tool can help you out:http://groups.google.com/group/dompdf/browse_thread/thread/9f7bc0162b...

BrianS

unread,
Mar 2, 2010, 12:25:24 AM3/2/10
to dompdf

This should work. I've done something similar here (I just used
verdana, but called it "times new" for load_font.php):
http://eclecticgeek.com/dompdf/index.php?&input_file=bd0ea178b0779227.htm&dompdf_ver=trunk&load_method=1

Have you enabled unicode support in dompdf_config.inc.php?

CodilX

unread,
Mar 2, 2010, 12:43:12 AM3/2/10
to dom...@googlegroups.com
Thank you for the reply :)

How do i set the unicode encoding?

> --
> You received this message because you are subscribed to the Google
> Groups "dompdf" group.
> To post to this group, send email to dom...@googlegroups.com.
> To unsubscribe from this group, send email to dompdf+un...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/dompdf?hl=en
> .
>

BrianS

unread,
Mar 2, 2010, 1:05:39 AM3/2/10
to dompdf
Find the DOMPDF_UNICODE_ENABLED entry in dompdf/dompdf_config.inc.php.

For reference:
http://code.google.com/p/dompdf/source/browse/trunk/dompdf/dompdf_config.inc.php#147


On Mar 2, 12:43 am, CodilX <cod...@gmail.com> wrote:
> Thank you for the reply :)
>
> How do i set the unicode encoding?
>

> >http://eclecticgeek.com/dompdf/index.php?&input_file=bd0ea178b0779227...

CodilX

unread,
Mar 2, 2010, 1:11:18 AM3/2/10
to dompdf
thanks, it's working! yay! :) thank you so much! awesome!

I think you should put this step-by-step "tutorial" somewhere in the
FAQ or something, it was really confusing when I started using dompdf
in the first place, and then stumbling across this character
problem..

but thankfully it works, thanks again. awesome!!

On Mar 2, 8:05 am, BrianS <eclecticg...@gmail.com> wrote:
> Find the DOMPDF_UNICODE_ENABLED entry in dompdf/dompdf_config.inc.php.
>

> For reference:http://code.google.com/p/dompdf/source/browse/trunk/dompdf/dompdf_con...

CodilX

unread,
Mar 2, 2010, 2:44:11 AM3/2/10
to dompdf
actually.. i jumped the gun - it isn't working. some of the letters I
posted are rendered correctly, but the other letters.. take a look:

http://dompdf.googlegroups.com/web/utf8_verdana_custom.pdf
http://dompdf.googlegroups.com/web/utf8_times_custom.pdf

BrianS

unread,
Mar 2, 2010, 8:28:31 AM3/2/10
to dompdf
That's odd. If you copy and paste the text into another program it
displays correctly. I used the same text in my test render and it
appeared correctly. Did you use the web-based font prep tool? Could
your font be corrupted?

On Mar 2, 2:44 am, CodilX <cod...@gmail.com> wrote:
> actually.. i jumped the gun - it isn't working. some of the letters I
> posted are rendered correctly, but the other letters.. take a look:
>

> http://dompdf.googlegroups.com/web/utf8_verdana_custom.pdfhttp://dompdf.googlegroups.com/web/utf8_times_custom.pdf

CodilX

unread,
Mar 2, 2010, 8:48:37 AM3/2/10
to dom...@googlegroups.com
Yeah I also found it weird that the text copies itself correctly.

I've used the online tool you posted.

The fonts can't be corrupted, I'm using the ones in the windows/fonts
folder.

Could you upload the converted fonts you're using? Times would be great

BrianS

unread,
Mar 2, 2010, 1:13:10 PM3/2/10
to dompdf
Can you send me the zip file that the font prep tool provided. Maybe
there's something else going on ... I'd like to take a look at your
files.

On Mar 2, 8:48 am, CodilX <cod...@gmail.com> wrote:
> Yeah I also found it weird that the text copies itself correctly.
>
> I've used the online tool you posted.
>
> The fonts can't be corrupted, I'm using the ones in the windows/fonts  
> folder.
>
> Could you upload the converted fonts you're using? Times would be great
>

CodilX

unread,
Mar 2, 2010, 1:25:37 PM3/2/10
to dompdf

BrianS

unread,
Mar 3, 2010, 12:36:22 AM3/3/10
to dompdf
The web-based font prep tool seems to be the source of the problem.
When I convert your files locally on my install I don't see the same
error. I knew there were some issues that needed to be addressed, but
this one is unexpected. I've made some changes to the tool, it'd be
great if you could try it again. You'll have to replace the files in
your font directory and delete any files that start with php_ (such as
php_times.afm and php_times.ufm).

The tool isn't even close to being fixed, but I'm hoping the change I
made will at least work around this problem.


On Mar 2, 1:25 pm, CodilX <cod...@gmail.com> wrote:
> sure, here they arehttp://groups.google.com/group/dompdf/web/dompdf_fonts.zip

CodilX

unread,
Mar 3, 2010, 1:16:44 AM3/3/10
to dompdf
Well I think you cracked it :) every character appears to be correctly
rendered :)

http://dompdf.googlegroups.com/web/utf8_working.pdf

thank you again for your awesome help, and for an awesome product!

CodilX

unread,
Mar 3, 2010, 5:02:00 AM3/3/10
to dompdf
jeez problems just keep popping up..

when i've uploaded the files to my test server, i get this error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 24 bytes) in /var/www/vhosts/test.domain/httpdocs/dompdf/lib/
class.pdf.php(2515) : eval()'d code on line 68615

Paul Waring

unread,
Mar 3, 2010, 5:09:20 AM3/3/10
to dom...@googlegroups.com
This is a common problem with dompdf - you need to either increase the
maximum amount of memory available to PHP or generate your PDF one page
at a time and then stitch them together into one document.

These pages provide all the information on increasing the memory limits:

http://drupal.org/node/207036
http://www.ducea.com/2008/02/14/increase-php-memory-limit/

You might also want to upgrade to the latest versions of dompdf and PHP
if possible, as they may be more memory efficient.

Paul


--
Paul Waring
http://www.pwaring.com

CodilX

unread,
Mar 3, 2010, 5:21:48 AM3/3/10
to dompdf
thank you :)

i've yet to solve this problem, my client has only regular hosting
with no access to php.ini .. hate hosts..

On Mar 3, 12:09 pm, Paul Waring <p...@xk7.net> wrote:
> This is a common problem with dompdf - you need to either increase the
> maximum amount of memory available to PHP or generate your PDF one page
> at a time and then stitch them together into one document.
>
> These pages provide all the information on increasing the memory limits:
>

> http://drupal.org/node/207036http://www.ducea.com/2008/02/14/increase-php-memory-limit/

CodilX

unread,
Mar 3, 2010, 6:20:15 AM3/3/10
to dompdf
the init function inside the class file worked perfectly :)

now another issue.. the file size is incredibly large for the content
in the files. a pdf with only one page with little text, no images is
about 1.5mb in size. two pages are 2.7mb or so. is there anyway to
decrease the size? it isn't really a big issue, but it would be great
if the files were smaller.

again, thanks for helping me :)

On Mar 3, 12:21 pm, CodilX <cod...@gmail.com> wrote:
> thank you :)
>
> i've yet to solve this problem, my client has only regular hosting
> with no access to php.ini .. hate hosts..
>
> On Mar 3, 12:09 pm, Paul Waring <p...@xk7.net> wrote:
>
> > This is a common problem with dompdf - you need to either increase the
> > maximum amount of memory available to PHP or generate your PDF one page
> > at a time and then stitch them together into one document.
>
> > These pages provide all the information on increasing the memory limits:
>

> >http://drupal.org/node/207036http://www.ducea.com/2008/02/14/increase...

Paul Waring

unread,
Mar 3, 2010, 6:27:21 AM3/3/10
to dom...@googlegroups.com
Are you embedding fonts in your files? If so I think that might be the
cause of the problem. I don't embed fonts in my files (I just assume
Arial will be available or a sensible alternative will be used) and a
three page document with several tables comes in at under 100KB.

Paul

CodilX

unread,
Mar 3, 2010, 6:50:11 AM3/3/10
to dompdf
I'm including (I guess) the converted fonts so that international
characters would appear correctly.

BrianS

unread,
Mar 4, 2010, 1:35:01 PM3/4/10
to dompdf
That's probably where the size issue is coming from. Fonts, especially
those that have international characters, can be quite large. For a
future release we'll look into the possibility of creating font
subsets.

ryleyb

unread,
Mar 18, 2010, 4:02:29 PM3/18/10
to dompdf
Sorry to resurrect this, but I've been playing with the 0.6 beta1 and
it's looking great...

I'm currently producing some documents in Japanese, everything looks
fine, but as CodilX was saying, the file sizes are a bit enormous.

http://groups.google.com/group/dompdf/browse_thread/thread/fc9c17f7f261d96d
Following that post, it seems like it ought to be fairly straight
forward to subset the font... except you have to understand how the
map works, and in my case understand a) which map to use for my
Japanese font, and b) how to actually figure out what subset I need.

Any helpful suggestions? :)

I see that you guys have added http://code.google.com/p/dompdf/issues/detail?id=135
to your plans, and in Japanese (and other Asian languages) I'm
imagining this could be quite painful.

Reply all
Reply to author
Forward
0 new messages