Hi,
I noticed you are planning to add the utf-8 characters to the next
release,
I think it's important for you to know this feature will almost be
unique (since no other product to best of my knowledge works with
these languages) to hundreds of millions of people who write in
Arabic, Hebrew, Persian, Urdu and etc, and it will certainly help them
a lot, so I decided to help you help us.
I thought since you probably don't use these languages I could help
you a bit by testing your product, and making sure it works. This also
will be a good thing to follow for developers that will be using your
product for such purpose.
I'm gonna try my best to make it work and after I'm done others will
have a sample to use.
Let's start with Persian (my mother tongue).
So I installed dompdf_0-6-0_beta1.
Here is what I have changed
and here is my code:
[code]
define("DOMPDF_UNICODE_ENABLED", true);
[/code]
I have downloaded farsifonts-0.4.zip from here:
http://www.farsiweb.ir/wiki/Persian_fonts
And decided to use roya.ttf, because of the beauty of it.
I used this tool:
http://eclecticgeek.com/dompdf/load_font.php
To generate the font format that your product uses, I used royab.ttf
to generate the bold font.
I copied all the following generated files in the lib/fonts folder:
dompdf_font_family_cache.sample
roya.afm
roya.ttf
roya.ufm
royab.afm
royab.ttf
royab.ttf
[code]
$html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//
EN\">
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html;
charset=UTF-8\">
<META HTTP-EQUIV=\"CONTENT-LANGUAGE\" CONTENT=\"fa\">
<title>Tutorial: HelloWorld</title>
<style>
body {dir:rtl;}
h1{ font-size:70px; font-family: Courier}
h2{ font-size:70px; font-family: Roya;}
h3{ font-size:70px; font-family: Arial;}
}
</style>
</head>
<body>
<h1>hello world</h1>
<h2>hello world</h2>
<h3>hello world</h3>
<h1>سلام دنیا</h1>
<h2>سلام دنیا</h2>
<h3>سلام دنیا</h3>
</body>
</html>";
set_include_path(APPLICATION_PATH . "../../library/
dompdf-0.5.1" . PATH_SEPARATOR . get_include_path());
require_once 'dompdf_config.inc.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader('DOMPDF_autoload');
$dompdf = new DOMPDF();
$dompdf->set_paper("a4", "portrait");
$dompdf->load_html($html);
$dompdf->set_base_path($_SERVER['DOCUMENT_ROOT']);
$dompdf->render();
$dompdf->stream("document.pdf");
die();
[/code]
And when I run my code, the following file is generated:
PersianRTLDocument.pdf which I uploaded to the files section:
http://groups.google.com/group/dompdf/web/PersianRTLDocument.pdf
As you can see in the file, Persian characters are replaced with
question marks (?).
When you open the file with an editor, you don't see a "roya" (the
name of the font used) anywhere, instead there are F1, F2, and F3
which happen to be Times-Roman, Courier-Bold, and Times-Bold.
Also the encoding seems to be WinAnsiEncoding, which is obviously ANSI
and not Unicode, I think it should rather be AFMEncoding.
So what am I doing wrong here?
Thanks