Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

PDF_findfont

(PHP 4 >= 4.0.5, PECL)

PDF_findfont -- Prepare font for later use [deprecated]

Описание

int PDF_findfont ( resource p, string fontname, string encoding, int embed )

Search for a font and prepare it for later use with PDF_setfont(). The metrics will be loaded, and if embed is nonzero, the font file will be checked, but not yet used. encoding is one of builtin, macroman, winansi, host, a user-defined encoding name or the name of a CMap. Parameter embed is optional before PHP 4.3.5 or with PDFlib less than 5.

This function is deprecated since PDFlib version 5, use PDF_load_font() instead.



PDF_fit_image> <PDF_fill
Last updated: Fri, 26 Jan 2007
 
add a note add a note User Contributed Notes
PDF_findfont
R. Christiaanse
26-Jul-2005 04:57
If you get the following error,

"PDFlib error: [2518] PDF_findfont: No file specified with outline data for font ..."

you might try the following:

1. Take care the environment variable PDFLIBRESOURCE is correctly set.
  
   You can set it like this: putenv("PDFLIBRESOURCE=C:\phpdev\php\pdf-related\pdflib.upr");
  
2. Take care the resource variabele used by PDFLib is correctly set.

   You can set it like this: pdf_set_parameter($pdf, "resourcefile", "C:\phpdev\php\pdf-related\pdflib.upr");
  
3. Take care the resource file and fonts can be found by adjusting your local include path.

   You can set it like this: ini_set('include_path', 'C:/phpdev/php/pdf-related');
  
4. Take care the paths in the PDFLIB resource file are correct

   Open pdflib.upr in a text editor and modify the path entry (read the comments):
  
   Example: /C:/phpdev/php/pdf-related
  
5. Leave the optional parameter 'embed' out:

   Like this:

   if ($font = pdf_findfont($pdf, "Helvetica", "host", 0))
     pdf_setfont($pdf, $font, 12);
    
   Or this:
  
   if ($font = pdf_findfont($pdf, "Helvetica", "host"))
     pdf_setfont($pdf, $font, 12);

I hope this could be of help to you...
sebastien at galliot dot com
25-Jun-2004 01:14
Display UTF-8 string with your PDFlib and true type font
<?php 

/*  UTF-8 : Unicode encoded string with PDFlib & Php
    
*/
$pdf = pdf_new();
if (!
pdf_open_file($pdf, ""))
   exit;

PDF_begin_page($pdf, 600,800);

// set the textformat parameter to utf8
pdf_set_parameter($pdf, "textformat", "utf8");  

// path of your TTF font directory
$fontdir = "/path/to/font/directory/";

// Open few .TTF (true type font) 
// be sure that your font file contains enough character for your language
 
pdf_set_parameter($pdf, "FontOutline", "ArialUnicode=$fontdir/ARIALUNI.TTF");
pdf_set_parameter($pdf, "FontOutline", "ArialItalic=$fontdir/ariali.ttf");

// UTF-8 encoded string (this is bulgarian (cyrillic alphabet))   
$utf_8_string ="Потребление" ;

// Set the font
$font = PDF_findfont($pdf, "ArialUnicode", "unicode",0);
pdf_setfont($pdf, $font, 15);  
// output the encoded string with Arial Unicode font
pdf_show_xy($pdf"Arial Unicode : $utf_8_string"   ,40 ,700);  

// output the encoded string with Arial Italic font
$font = PDF_findfont($pdf, "ArialItalic", "unicode",0);
pdf_setfont($pdf, $font, 15);  
pdf_show_xy($pdf"Arial Italic  : $utf_8_string"   ,40 ,650);  

 
PDF_end_page($pdf);
pdf_close($pdf);

$buf = pdf_get_buffer($pdf);
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=foo.pdf");
echo
$buf;

pdf_delete($pdf);

 
?>
Mairsil
27-Jan-2004 10:31
An easy way to use .ttf fonts under *nix:

pdf_set_parameter($pdf, "FontOutline", "Arial=/var/path/to/font/arial.ttf");
Leander Hanwald
13-Aug-2003 04:46
Hi

--- English ----

Be carefull if you want to use german umlauts.

I tried it with libpdf 5.x and used the builtin paramater.
After i created a pdf I saw that all umlauts are a space ('
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571