Re: pdflib greek problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thodoris wrote:

Hi,
   I am trying the following code to generate a pdf:

   try {
       // Create a new pdf handler
       $pdf = new PDFlib();

       //  open new PDF file
       if ($pdf->begin_document("", "") == 0) {
           die("Error: " . $p->get_errmsg());
       }

       // Set some info to the new pdf
       $pdf->set_info("Creator", "Test");
       $pdf->set_info("Author", "Test");
       $pdf->set_info("Title", "Test");
             // Start the page
       $pdf->begin_page_ext(595, 842, "");
             // Load the documents font and set the details
       $font = $pdf->load_font("Times-Roman", "iso8859-7", "");
       $pdf->setfont($font,24.0);
       $pdf->set_parameter('autospace',TRUE);
             // Set the position inside the document
       $pdf->set_text_pos(50, 700);
             // Now start to show the data
       $str = 'Αυτό είναι ένα τεστ.';
       mb_convert_variables('ISO-8859-7','UTF-8',$str);
       $pdf->show($str);
             // End the page and the document
       $pdf->end_page_ext("");
       $pdf->end_document("");
             // Get the document from the buffer find it's length
       $buf = $pdf->get_buffer();
       $len = strlen($buf);
             // And finally print it out to the browser
       header("Content-type: application/pdf");
       header("Content-Length: $len");
       header("Content-Disposition: inline; filename=hello.pdf");
       print $buf;
           }
     catch (PDFlibException $e) {
       die("PDFlib exception occurred in hello sample:\n" .
   "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
       $e->get_errmsg() . "\n");
   }
   catch (Exception $e) {
       die($e);
   }

Although greek are printed normally the characters are overlapping on each other. The script in encoded in UTF-8.

Does anybody have any suggestions on this? Please any help would be appreciated.


LaTeX has some greek stuff that works fairly well - though you have to use one of the fonts encoded for LaTeX.

If you mean to have a web app generate the PDF you'll have to output to .tex and then use a shell command to compile the document, but it is a solution that is fairly well tested for creation of Greek (monotonic and polytonic) PDF documents.

I know that isn't what you asked, but in case there isn't a PDFLib solution to the typesetting issue, I suspect an application designed for typesetting will give better results anyway.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux