Note: I wrote UFPDF as an experiment, not as a finished product. If you have problems using it, don't bug me for support. Patches are welcome though, but I don't have much time to maintain this.
FPDF is a PHP class for generating PDF files on-the-fly. Unfortunately it does not support Unicode. So I've coded UFPDF, an extension of FPDF which accepts input in UTF-8.
Only TrueType fonts are supported for now. To embed .TTF files, you need to extract the font metrics and build the required tables using the provided utilities (see README.txt). Included is a modified version of TTF2PT1 which extracts the Unicode glyph info.
UFPDF works the same as FPDF, except that all text is in UTF-8, so consult the FPDF documentation for usage.

RE: Default fonts
This is correct. I have been trying to work out a way to do it for quite some time. I plan to have something in not too long. So far I have gotten along just fine because all the languages I have been required to support are covered by the Latin 1 encoding. So I just convert everything to Latin 1 before I stick it in the pdf.
For an upcoming project however I am going to have to support Chinese. If I can come up with some logic to look at a string and tell what encoding to use then I know how to do the rest. I have figured out how to do the character mapping etc. I just need to know what mappings to use.
Worst case you will simply need to always specifiy what language you are using each time you add text.
I will post my results here when I am done.
also...
you may want to check out these links from the front page of the fpdf site:
Chinese:
http://www.fpdf.org/phorum/read.php?f=1&i=5142&t=5142
Japanese:
http://www.fpdf.org/phorum/read.php?f=1&i=7977&t=7977
Korean:
http://www.fpdf.org/phorum/read.php?f=1&i=10058&t=10058
Hi Cristo,did you get it
Hi Cristo,
did you get it running?
Best wishes
Daniel
left to right
you can use strev function to reverse the letters
Russian Font
FontForge is a very smart program to test, which glyphes are in the font. With the some wonderfull program you can add/merge fonts.
Hi Ben,
Hi Ben,
to display a glyph it must be in your ttf. You can switch the font for this special glyphes or add this glyphes with FontForge in it.
In TCPDF or UFPDF you have to use UTF-8, not Unicode entities.
I hope I can help you.
Rainer
http://webmasterei.com
ufpdf and arabic
Moin,
'strrev' dont work because multibyte encoding of arabic text.
I have written a special utf8_strrev() - but the result is a grazy arabic text:
It contains only single, arabic symbols without ligatures.
Any ideas?
ufpdf and arabic
Moin,
you can revert the text with strrev(): it dont work because arabic text is multibyte.
With a special, own function utf8_strrev() I have reverted a teststring. The result is a crazy arabic text. All glyphs are single, without ligatures.
Rainer
problem when using tamil unicode latha
hello everyone , i am using ufdpf and unicode tamil font latha , i have converted into ufm and then to php and the output is also coming , but some characters are not displayed properly , can any solve my problem it will be great help for me
thnks in advance
santhana krishnan.v
MultiCell - sollved, but ..
Hey guys, there seems to be a workaround for this - in original FPDF class file, just replace the line:
$l+=$cw[$c];
with:
$l+=isset($cw[ord($c)])?$cw[ord($c)]:0;
I found it on some forum .. dont remember where exacly.
Now it seems to work, but not really properly - if you use MultiCell in justified align mode, it doeasnt work. The lines seem to have random length. I was trying to track it down, there seems to be a problem with values of $cw in font definition file.
Was anyone succesfull in solving this?
problem when using tamil unicode
hi santhana,
did you manage to make your thamil work out?
i am approching UFPDF to work with chinese, so i guess i'll have same problems as you...
bytheway, how did you convert your font to UFM?
is there any application to do that under windows?
i use windows and cant manage to use TTF 2 PT1!
thanks
Something Wrong With Chinese Unicode
hi jason,
did you manage to make your chinese work out?
i am approching UFPDF to work with chinese, so i guess i'll have same problems as you...
bytheway, how did you convert your font to UFM?
is there any application to do that under windows?
i use windows and cant manage to use TTF 2 PT1!
thanks
chinese
hi jason/
did you manage to have your chinese working?
actually i have even a worst problem: i cant use ttf2ufm on windows, it closes immediately upon launch.
how's that?
Trouble with Page Count
I use the latest files(cvs) ufpdf.php and fpdf.php from the phpmyadmin project. They fixed the problem.
Klaus
"č" problem
Hi,
the idea of the fix is (hopefully) ok, but..you mention U 266, where is should be U 269 (see http://www.pemberley.com/janeinfo/latin1.html).
The fix in your case would then be;
-------
for example in verdana.ufm originaly was:
U 269 ; WX 698 ; N Cdot ; G 328 ;
i've changed into:
U 269 ; WX 521 ; N Cdot ; G 254 ;
--------
right?
Also, the list with several lines changed some posts above is plain wrong, a check with;
<?php$font = 258;
while($font <270) {
$test = decode_entities('&#' . $font . ';');
$pdf->Write(9,$font .' = ' . $test."\n");
$font++;
}
?>
showed just the ccaron being wrong. I do hope there aren't more fonts broken, cause I can hardly check the whole unicode table :-|
UFPDF and pdfview.module in Drupal
Hi all,
Finally, is there any way to have UFPDF working with Drupal?
I seem to be quite lost going through all those comments. Is anyone able to summarize the situation about [Drupal - view as PDF - Accents]?
Thanks
ps: for instance, how to modify Drupal's 'pdfview' module to use UFPDF (instead of html2fpdf) or something like that ...
html2ufpdf
Good morning,
I saw that you tried to find a tool to convert unicoded HTML to PDF.
I am also searching for such a tool. Did you managed to include HTML2PDF with UFDF?
Thanks,
Cheers.
Warzazel
code
Can I put a unicode code in hexa , like '010D', in a string and the output to be the char that corresponde to the '0100D' code?. Like we put html entities in html
Thanks
problem with ttf2ufm converted font
as in TCPDF's bug:
http://sourceforge.net/tracker/index.php?func=detail&aid=1421290&group_i...
Wrong characters displayed in some fonts
Some characters are always displayed wrong. instead of
the requested character there is always the character
with the unicode value of the requested character minus
3 displayed.
e.g. instead of č (U-269) the character with the
unicode value 266 will be displayed
here is a list of all characters i have identified so far:
Requested: č U-269 Displayed: don't know (U-266)
Requested: 名 U-21517 Displayed: 吊 U-21514
Requested: 」 U-12301 Displayed: 《 U-12298
Requested: 對 U-23565 Displayed: 尊 U-23562
Requested: 服 U-26381 Displayed: 朊 U-26378
Requested: 复 U-22797 Displayed: 夊 U-22794
Requested: ญ U-3597 Displayed: ช U-3594
Requested: 긍 U-44557 Displayed: don't know (U-44554)
This seems to be independent of the used font. In the
.ufm file the correct CID/GID values are written and
the CIDtoGID-Map seems to include the correct values, too.
I also checked for bugs in the utf8-to-utf16 converter
method but didn't find any.
ttf2ufm switching characters, "č" and more...
this is a retification of my previous posting...
It came out a bug in ttf2ufm:
The resulting UFM will switch some characters with others:
instead of the requested character there is always the character with the unicode value of the requested character minus 3 displayed.
E.g. instead of č (U-269) the character with the unicode value 266 will be displayed
Here is a list of all characters we have identified so far:
Requested: č U-269 Displayed: don't know (U-266)
Requested: 名 U-21517 Displayed: 吊 U-21514
Requested: 」 U-12301 Displayed: 《 U-12298
Requested: 對 U-23565 Displayed: 尊 U-23562
Requested: 服 U-26381 Displayed: 朊 U-26378
Requested: 复 U-22797 Displayed: 夊 U-22794
Requested: ญ U-3597 Displayed: ช U-3594
Requested: 긍 U-44557 Displayed: don't know (U-44554)
a fix on TTF2UFM would be very very appreciated!
in the mean while, we can only modify the UFM manually before we create the fonts.
ex, for "č"
-------
in verdana.ufm /arial.ufm originaly would be:
U 269 ; WX 698 ; N Cdot ; G 328 ;
it should be changed into:
U 269 ; WX 521 ; N Cdot ; G 254 ;
(in FreeSerif = G 205).
this value is relative to the position of the character in the specific font.
Does anyone know how to retrive the position of the character in a font's table?
for example, in arialuni.ufm the definition for 复 is wrong , as in: U 22797 ; WX 1000 ; N _d_11164 ; G 11164 ;
11164 is probabilly wrong, but how can i know what is the right position for 复 inside arialuni??
you can post your answer here or on TCPDF's forum, which seems to have more active mantainance.
thanks!
how about vietnamese?
there are some characters in Vietnamese don't appear, idon't know why?
how about vietnamese? - missing chars
hi trung,
according to my experience, problem could be 2:
(difficault but possible: try to use arial unicode to make sure you have a complete font)
TTF2UFM will switch some character with others, according to a logic we didnt figure out yet.
you could either:
also you can refer to
TCPDF's forum which seems to have more mantainence then here.