Страница 1 из 1

выгрузка данных

Добавлено: 2009-08-14 14:31:55
gurt
нужно осуществить процесс выгрузки с хитрым форматирование. взгляд пал на выгрузку в pdf средствами pdflib. модуль встал, но никак не получается сгенерить хоть что-то.
вебсервер на freebsd 7, apache2, php5
ругается, что нет шрифтов, а где и как их взять ума не приложу. пытался поинсталить /usr/ports/x11-fonts но как-то глухо

собсна код php

Код: Выделить всё

<?php
// create handle for new PDF document
$pdf = pdf_new();

// open a file
$filename="test.pdf";
pdf_open_file($pdf, $filename);

// start a new page (A4)
pdf_begin_page($pdf, 595, 842);

// get and use a font object

//$fontdir = "/usr/local/lib/X11/fonts/TTF/";

//pdf_set_parameter($pdf, "FontOutline", "Unifont=$fontdir/luximri.ttf");

$arial = pdf_findfont($pdf, " Arial", "host",0);
pdf_setfont($pdf,$arial, 10);

// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);

// end page
pdf_end_page($pdf);

// close and save file
pdf_close($pdf);
?>
ругается

Fatal error: Uncaught exception 'PDFlibException' with message 'Font ' Arial' with encoding 'host': Font file (AFM, PFM, TTF, OTF etc.) or host font not found' in /usr/home/........./index.php:19 Stack trace: #0 /usr/home/.........../index.php(19): pdf_findfont(Resource id #2, ' Arial', 'host', 0) #1 {main} thrown in /usr/home/................./index.php on line 19

Re: выгрузка данных

Добавлено: 2009-08-14 15:23:12
gurt
problem resolved. перепроверил старый вариант, была ошибка в пути.

Код: Выделить всё

<?php
// create handle for new PDF document
$pdf = pdf_new();

// open a file
$filename="test.pdf";
pdf_open_file($pdf, $filename);

// start a new page (A4)
pdf_begin_page($pdf, 595, 842);

pdf_set_info($pdf, "Author", "Gurt Noglance");

// get and use a font object
//pdf_set_parameter($pdf, "textformat", "utf8");
$fontdir = "/usr/local/lib/X11/fonts/webfonts";

//pdf_set_parameter($pdf, "resourcefile", "unifont.ttf");
pdf_set_parameter($pdf, "FontOutline", "Arial=$fontdir/arial.ttf");
$arial = pdf_findfont($pdf, "Arial", "host",0);
pdf_setfont($pdf,$arial, 10);

// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);

// end page
pdf_end_page($pdf);

// close and save file
pdf_close($pdf);

echo "<a href=\"test.pdf\">open pdf</a>";
?>