|
|
LXXVII. PDF FunktionenEinleitung
Mit Hilfe der PDF-Bibliothek von Thomas Merz k�nnen mit PHP PDF
Dateien erzeugt werden. Die Bibliothek ist unter ; verf�gbar. Zudem sind noch zwei
weitere Bibliotheken notwendig, und , um PHP zu �bersetzen. Diese beiden Bibliothek
bereiten h�ufig Probleme bei der Konfiguration von PHP. Sie
sollten unbedingt die Meldungen des Konfigurations-Skripts
befolgen, um aufkommende Probleme zu l�sen.
Beachten sie zudem die excellente Dokumentation die mit pdflib
ausgeliefert wird. Sie gibt einen guten �berblick �ber die
M�glichkeiten von pdflib.
Die meisten Funktionen in pdflib sind in �hnlicher Form auch in
PHP vorhanden. Die Parameter sind in der Regel auch identisch.
Sie sollten zudem die Grundkonzepte von PDF und Postscript
verstanden haben, um das PDF Module effizient nutzen zu k�nnen.
Alle L�ngen und Koordinatenangaben sind in Postscript-Punkten
gemessen. F�r gew�hnlich entsprechen 72 PostScript-Punkte 1 Inch,
was jedoch von der Aufl�sung des Ausgabeger�ts abh�ngt.
Neben diesem Modul gibt es noch ein weiteres zur Erzeugung von
PDF-Dateien basierend auf der Bibliothek ClibPDF von
.
Es hat eine geringf�gig andere Programmierschnittstelle.
Schauen Sie in die
Funktions�bersicht f�r
weitere Details.
Das PDF Module von PHP verwendet einen neuen Type von Variable
Er wird
pdfdoc genannt.
pdfdoc ist ein Zeiger auf das PDF Dokument und
wird bei fast allen Funktion als erster Parameter erwartet.
Altlasten
Since the very begining of PDF support in PHP — starting with
pdflib 0.6 —
there has been tons of changes especially to the pdflib API. Most of
these changes has been somehow covered by PHP, some has even required
changes to the PHP API. Since pdflib
3.x the API seems to be stabilzed and PHP4 has adopted the version as a
minimum requirement for PDF support. The consequence will be that many
functions will disappear or be replaced by alternatives sooner or later.
Support for pdflib 0.6 is already completely given up.
The following table list all the functions which are deprecated
in PHP 4.02 and should be replaced by their new versions.
Tabelle 1. Deprecated functions and its replacements
Tips zur Installation von pdflib 3.x
Seit Version 3.0 von pdflib sollten sie pdflib mit der configure-Option
--enable-shared-pdflib konfigurieren.
Verwenden alter pdflib Versionen
Mit Version 2.20 von pdflib wurden einige Ver�nderungen an der API
vorgenommen. Zudem ist Unterst�tzung f�r asiatische Zeichens�tze
hinzugekommen. Dies hat leider auch zu �nderungen am php4-Modul
gef�hrt (nicht php3). Wenn Sie pdflib 2.20 benutzen, dann sollten
Sie die Erzeugung von Dokumenten im Speicher mit Vorsicht benutzen.
Bis zur entg�ltigen Version 3.0 von pdflib k�nnte dies instabil sein.
Der encoding Parameter der Funktion pdf_set_font()
hat sich in eine Zeichenkette ge�ndert. Dies bedeutet, dass anstatt
von beispielsweise 4 jetzt 'winansi' verwendet werden muss.
Wenn Sie die Version 2.30 von pdflib verwenden, dann steht Ihnen
die Funktion pdf_set_text_matrix() nicht mehr
zur Verf�gung. Diese Funktion wurde komplett entfernt. Grunds�tzlich
ist es ratsam die release notes der verwendeten Version von pdflib
zu lesen.
Versionen von PHP4 die nach dem 9. M�rz 2000 erscheinen unterst�tzen
nur noch die Versionen >3.0 von pdflib. PHP3 sollte hingegen nicht
mit Versionen >2.01 verwendet werden.
Bei Gebrauch von pdflib 2.01 sollte �berpr�ft werden, ob die
Bibliothek richtig installiert wurde. Es sollte die Datei oder
ein Verweis libpdf.so im Installationsverzeichnis von pdflib
existieren. Version 2.01 erzeugt nur die Bibliothek mit dem Namen
libpdf2.01.so, die so nicht vom Linker des Systems gefunden werden
kann. In diesem Fall m�ssen Sie den Verweis von libpdf.so nach
libpdf2.01.so selbst anlegen.
Beispiele
Die meisten Funktionen sind sehr einfach zu benutzen. Das Schwierigste
wird wohl sein, �berhaupt ein einfaches PDF-Dokument zu erstellen.
Das folgende Beispiel soll die ersten Schritte erleichtern.
Dieses Skript erstellt die PDF-Datei test.pdf,
welche nur aus einer Seite besteht.
Auf der Seite befindet sich der Text "Times Roman outlined" in einem
outlined, 30pt Zeichensatz. Der Text ist zudem unterstrichen.
Beispiel 1. Erstellung eines PDF Dokuments mit pdflib <?php
$fp = fopen("test.pdf", "w");
$pdf = pdf_open($fp);
pdf_set_info_author($pdf, "Uwe Steinmann");
pdf_set_info_title($pdf, "Test for PHP wrapper of PDFlib 2.0");
pdf_set_info_author($pdf, "Name of Author");
pdf_set_info_creator($pdf, "See Author");
pdf_set_info_subject($pdf, "Testing");
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, "Page 1");
pdf_set_font($pdf, "Times-Roman", 30, 4);
pdf_set_text_rendering($pdf, 1);
pdf_show_xy($pdf, "Times Roman outlined", 50, 750);
pdf_moveto($pdf, 50, 740);
pdf_lineto($pdf, 330, 740);
pdf_stroke($pdf);
pdf_end_page($pdf);
pdf_close($pdf);
fclose($fp);
echo "<A HREF=getpdf.php>finished</A>";
?> |
Das PHP-Skript getpdf.php liefert nur das PDF-Dokument.
|
Die pdflib-Distribution enth�lt ein komplizierteres Beispiel,
welches ein Reihe Seiten erstellt die jeweils eine analoge Uhr
mit der aktuellen Uhrzeit enthalten. Dieses Beispiel in ein
PHP-Skript umgesetzt sieht wie folgt aus (das gleiche Beispiel wird
auch in der Dokumentation zum
cpdf Modul verwendet):
Beispiel 2. pdfclock Beispiel aus der pdflib Distribution <?php
$pdffilename = "clock.pdf";
$radius = 200;
$margin = 20;
$pagecount = 40;
$fp = fopen($pdffilename, "w");
$pdf = pdf_open($fp);
pdf_set_info_creator($pdf, "pdf_clock.php3");
pdf_set_info_author($pdf, "Uwe Steinmann");
pdf_set_info_title($pdf, "Analog Clock");
while($pagecount-- > 0) {
pdf_begin_page($pdf, 2 * ($radius + $margin), 2 * ($radius + $margin));
pdf_set_transition($pdf, 4); /* wipe */
pdf_set_duration($pdf, 0.5);
pdf_translate($pdf, $radius + $margin, $radius + $margin);
pdf_save($pdf);
pdf_setrgbcolor($pdf, 0.0, 0.0, 1.0);
/* minute strokes */
pdf_setlinewidth($pdf, 2.0);
for ($alpha = 0; $alpha < 360; $alpha += 6) {
pdf_rotate($pdf, 6.0);
pdf_moveto($pdf, $radius, 0.0);
pdf_lineto($pdf, $radius-$margin/3, 0.0);
pdf_stroke($pdf);
}
pdf_restore($pdf);
pdf_save($pdf);
/* 5 minute strokes */
pdf_setlinewidth($pdf, 3.0);
for ($alpha = 0; $alpha < 360; $alpha += 30) {
pdf_rotate($pdf, 30.0);
pdf_moveto($pdf, $radius, 0.0);
pdf_lineto($pdf, $radius-$margin, 0.0);
pdf_stroke($pdf);
}
$ltime = getdate();
/* draw hour hand */
pdf_save($pdf);
pdf_rotate($pdf,-(($ltime['minutes']/60.0)+$ltime['hours']-3.0)*30.0);
pdf_moveto($pdf, -$radius/10, -$radius/20);
pdf_lineto($pdf, $radius/2, 0.0);
pdf_lineto($pdf, -$radius/10, $radius/20);
pdf_closepath($pdf);
pdf_fill($pdf);
pdf_restore($pdf);
/* draw minute hand */
pdf_save($pdf);
pdf_rotate($pdf,-(($ltime['seconds']/60.0)+$ltime['minutes']-15.0)*6.0);
pdf_moveto($pdf, -$radius/10, -$radius/20);
pdf_lineto($pdf, $radius * 0.8, 0.0);
pdf_lineto($pdf, -$radius/10, $radius/20);
pdf_closepath($pdf);
pdf_fill($pdf);
pdf_restore($pdf);
/* draw second hand */
pdf_setrgbcolor($pdf, 1.0, 0.0, 0.0);
pdf_setlinewidth($pdf, 2);
pdf_save($pdf);
pdf_rotate($pdf, -(($ltime['seconds'] - 15.0) * 6.0));
pdf_moveto($pdf, -$radius/5, 0.0);
pdf_lineto($pdf, $radius, 0.0);
pdf_stroke($pdf);
pdf_restore($pdf);
/* draw little circle at center */
pdf_circle($pdf, 0, 0, $radius/30);
pdf_fill($pdf);
pdf_restore($pdf);
pdf_end_page($pdf);
}
$pdf = pdf_close($pdf);
fclose($fp);
echo "<A HREF=getpdf.php?filename=".$pdffilename.">finished</A>";
?> |
Das PHP-Skript getpdf.php liefert wiederum nur
das Dokument.
<?php
$fp = fopen($filename, "r");
header("Content-type: application/pdf");
fpassthru($fp);
fclose($fp);
?> |
|
User Contributed Notes PDF Funktionen |
|
perluca at fabaris dot it
07-Oct-1999 01:10 |
|
My recipie:
1) untar pdflib-2.01.tar.gz
$./configure
$
make
$ make install
2) set a symlink
$ ln -s
/usr/local/lib/libpdf2.01.so /usr/local/lib/libpdf.so
You need to do
this 'cause the PHP configure checks for pdflib with a little C-program,
compiling it and linking with library named libpdf
(!)
2)
$ldconfig
this updates the info about dynamic
library on your system (think about the magic phrase "Reboot
Windows " ) ;-)
3) go to cvs.php.net and checkout the
source tree.
You can find How-To on
4) configure
your php:
$make
Stop your Apache server with apachectl stop
(don't forget it!!!!!)
$make install
$apachectl
start
and
.......... have happy time hacking with pdflib/php !
;->
Luk.
|
|
Uwe dot Steinmann at fernun-hagen dot de
10-Dec-1999 09:18 |
|
The php mailinglist reported a problem with the
installation of pdflib
2.01. The file pdf.h which is to be copied e.g. into /usr/local/include
will end up as /usr/local/include if the directory /usr/local/include does
not exist already. This is because configure of php to fail, since it
can't find pdf.h
|
|
loke at ic dot chalmers dot se
17-Jan-2000 05:21 |
|
When pdflib2.01 is installed on a HPUX-10.20 system (perhaps others as
well?), the libs end with .sl not .so which means that you should
use
"ln -s /usr/local/lib/libpdf2.01.sl
/usr/local/lib/libpdf.sl" instead!
|
|
yhan at elientech dot com
24-Jul-2000 04:03 |
|
You need the to get the latest pdf.c file from the CVS tree:
php4/ext/pdf/pdf.c
And
make sure that you have patched pdflib 3.01, or you will have problem
writing pdf to file(httpd core dumps).
|
|
nathan at cournia dot com
27-Jul-2000 05:28 |
|
After a couple of hours of trial and error, I've finally gotten PHP
4.0.1pl2, Apache 1.3.12, and PDF 3.01 to all work together.� Here are the
steps I followed.
Downloaded the above from the following
sites:
PDFlib: www.pdflib.com
Apache: www.apache.org
PHP:
www.php.net
I also downloaded the following:
PDFlib patch:
Latest
PHP pdf.c:
After
untarring the archives I did the following:
In PDF
directory:
Applied PDF patch.
./configure --enable-cxx
--with-tiffauxlib=-ljpeg --with-tifflib=/usr/lib --with-zlib=/usr/lib
--with-pnglib=/usr/lib --enable-shared --enable-static
--enable-shared-pdflib
make
make install
In Apache source
directory:
./configure --prefix=/www/apache --with-perl=/usr/bin/perl
--enable-module=so --enable-module=rewrite
make
make
install
In PHP direcotry
Copied over new pdf.c
file.
./configure --with-mysql --with-apxs=/www/apache/bin/apxs
--enable-track-vars --with-zlib-dir --with-jpeg-dir=/usr/lib
--with-png-dir=/usr/lib --with-tiff-dir=/usr/lib
--with-pdflib
make
make install
From there I configured
httpd.conf as outlined in the PHP docs.� Hope this helps.
|
|
nathan at cournia dot com
05-Aug-2000 04:28 |
|
Here are a couple of other notes I made when compiling in PDF 3.x
support.
The PDF patch does not work, or at least I was unable to
get it to work using 'patch'. You have to manually make changes to the
pdf file. Simply look at the patch file to see what line to delete and
add. Lines with a plus in front of them should be added while lines with
a minus should be deleted.
After compiling the PDF library, make
sure '/usr/local/lib' appears in /etc/ld.so.conf. Also, it's probably a
good idea to run 'ldconfig' once the PDF library has been
compiled.
Hope this helps.
|
|
yale_yu at yahoo dot com
30-Aug-2000 11:38 |
|
Just FYI, I just find pdflib-3.0.1 and pdflib-3.0.2 does't work with
php-4.0.2 in my certain condition. Fortunately pdflib-3.0 does
fine.
I'm runing Solaris 7 on a Sun Sparc, apache-1.3.12. DSO
php-4.0.1pl2 or php-4.0.2 works well without pdflib support. But when I
install pdflib-3.0.2, there's no DSO library made, which will cause php
configuration failed, in /usr/local/lib, nor does pdflib-3.0.1, no matter
how do I adjust the configure line parameters.
I have to back to
pdflib-3.0, it works like a magic.
|
|
c dot hue at sofrel dot com
14-Sep-2000 09:52 |
|
For PdfLib.dll v2.01 look
|
|
@boas.anthro.mnsu.edu
02-Oct-2000 01:53 |
|
My process to get this all working:
I use debian, so I used
dselect to make sure that I had libtiff and libjpeg.
Compile
pdflib 3.02 "./configure --enabled-shared-pdflib --enable-cxx
--enable-static --enable-shared --with-tifflib=/usr/lib
--with-tiffauxlib=-ljpeg"
"make" then "make
test" and "make install"
Edit /etc/ld.so.conf and
include the line "/usr/local/lib"
"ln -s
/usr/lib/libtiff.so.3.5.4 /usr/lib/libtiff.so"
"ln -s
/usr/lib/libjpeg.so.62.0.0
/usr/lib/libjpeg.so"
"ldconfig"
Recompile
PHP with "--with-pdflib"
If that doesn't work, make
sure to check the last few lines of config.log ("tail -n 25
config.log") and look for errors. Worked finally for me with PHP
4.0.2.
|
|
mrobinso at php dot net
17-Oct-2000 12:06 |
|
There seems to be a [known] bug in
pdflib-3.0.1 where file
descriptors
are overwritten, resulting in an
apache segfault when
accessing pdf
functions. The bug is documented in
the changelog of
pdflib-3.0.2,
which cures this problem. (Thanks to
Jani for
catching this.)
|
|
mike_nospam at envisionsoftware dot co dot nz
29-Oct-2000 01:36 |
|
[Editor's note: See the section "Security" in the manual for more
information on this and other security matters]
The script
getpdf.php should only be used to learn the concept of passing a file
through a script and not actually used to perform this task. In its
current state, there is a large security flaw which enables many files
(including all your php source) to be viewed by anyone.
For
example
shows the servers machines password file.
|
|
php at interfaces dot fr
03-Nov-2000 01:24 |
|
PHPLIB (3.0.2)
after compiling and installing pdflib3.0.2, it
defaults to /usr/local/lib and creates symlinks that the ./configure of
PHP doesnot want to recognize...
Simply run :
rm
/usr/local/lib/libpdf.so.1
rm /usr/local/lib/libpdf.so
mv
/usr/local/lib/libpdf.so.1.0.0 /usr/local/lib/libpdf.so.1
and
everything will go right : -)
|
|
mschroebel at hsus dot org
04-Dec-2000 06:37 |
|
Having trouble getting MS IE to display your PDFs?
As
[email protected] kindly wrote in the ClidPDF man page:
"I
found out MSIE _REQUIRES_ a correctly set Content-Length header to be sent
beside Content-Type to correctly display PDFs"
|
|
kill-9 at kill-9 dot dk
10-Jan-2001 11:55 |
|
After digging around in pdf.c I found two very useful undocumented PDF
functions.
pdf_add_pdflink(int pdfdoc, double llx, double lly,
double urx, double ury, string filename, int page, string dest)
Adds
link to pdf document
void pdf_add_weblink(int pdfdoc, double llx,
double lly, double urx, double ury, string url)
Adds link to web
resource
enjoy them.
kill-9
www.kill-9.dk
|
|
boism at NOSPAMmultimania dot com
10-Jan-2001 12:40 |
|
Here is a short example to display PDF files without needing a
'redirection'.
Works also with IE thanks to the previous
note.
Avoid spaces/newlines/whatever before and after the php script
if you want the file to be correctly handled as PDF.
Mathieu
BOIS
pdftest.php
:
<?php
$filename="/tmp/test.pdf";
$fp=fopen($filename,"w");
//CREATE
YOUR PDF FILE
HERE
fclose($fp);
$fp2=fopen($filename,"r");
header("Content-Length:
".filesize($filename)); // for IE to
work
header("Content-type:
application/pdf");
fpassthru($fp2);
fclose($fp2);
?>
|
|
dominic at execpc dot com
26-Jan-2001 10:43 |
|
To get around the IE problem with content-length, you can use the output
buffering feature with PHP 4:
<?php
header(
"Content-type: application/pdf" );
// turn output
buffering on
ob_start();
$pdf = PDF_open();
// create
your pdf here.
PDF_close($pdf);
// get the length of the
document
$length = ob_get_length();
// output content-length
header
header("Content-Length: $length");
// send
pdf to the browser, flushing and turning off output
buffering
ob_end_flush();
?>
This works for me in NS
4.7 and IE 5
|
|
gateschris at yahoo dot com
31-Jan-2001 03:27 |
|
just something from :
Quite
Important!!!
Just to have it in the archive I am responding to
myself.
I managed to get it to compile. The problem lies with the
PDFlib and the
options you compile it with. I was seeing some errors
in reference to
the png functions inside the PDFlib being undefined. I
decided to
recompile without PNG support. (--with-pnglib=no). Even
though my system
has PNGlib in /usr/local/lib. I tried it both ways
and disabling the PNG
support seemed to be the way to
go.
After recompiling, PHP is no longer stopped on
pdf_show_boxed.
HTH somebody...
Tom Walsh
>
System: BSDi 4.1
>
> Trying to compile PHP4.0 with PDFlib
support. I have downloaded the
> latest PDFlib (version 3.0) and
compiled it. When I run the
> ./configure
> script I am
getting an error message on PDF_show_boxed. It is
> telling
me
> something to the effect that you must have libjpeg and
libtiff
> installed.
>
> I have compiled libtiff
(v3.5.5) and libjpeg (v6). I have also
> recompiled PDFlib with the
libtiff switch
> (--with-libtiff=/usr/local/lib).
>
> I keep getting the same error message.
>
> I have
tried forcing PDFlib to look at /usr/local/lib
>
(--with-pdflib=/dir) and still the same error message.
>
>
Any help is appreciated.
>
> As an aside: I find that
PDFlib function and actually all things PDF
> like to be very
poorly documented.
>
> Tom Walsh
>
> --
|
|
ernesto at calabozo dot com
09-Feb-2001 03:59 |
|
Ok, with the 3.03 version of pdflib, there's a bug in the library that
throw an error when you try to create the Pdf direct in memory
using:
pdf_open();
You can fix this with the patch
published in the pdflib page at:
After
aplying the patch and recompiled the pdflib, you don't need to recompile
the php, just restart the webserver and you are ready to go, at least it
work for me =)
I use Linux, Apache and PHP as DSO.
Greettings
and excuse my english, but it's not my mother language and is a little
late now ;-)
Ernesto Domato.
|
|
grant at -conprojan dot com dot au
19-Feb-2001 07:52 |
|
You're trying to configure php with support for pdflib. You get the
following error:
checking whether to include Pdflib 3.x
support... yes
checking for PDF_show_boxed in -lpdf... no
configure: error: pdflib extension requires at least pdflib
3.x.
You may also need libtiff and libjpeg. If so, what you need
is to install
libjpeg-devel-6b-10.rpm
I don't know what
source tarball has those development libraries or if it's some make option
I'm not aware of in the latest jpegsrc.v6b.tar.gz
When I
installed that rpm both php and apache configured and compiled
perfectly...
|
|
pete at SoulCoffee dot org
23-Feb-2001 11:18 |
|
I added the manually patched the file, configured with ./configure
--enable-shared-pdflib and nothing else, and used this modification of the
php page shown above:
<?
header( "Content-type:
application/x-pdf" );
$f = fopen("/tmp/test",
"w");
$pdf = PDF_open($f);
//$pdf =
PDF_new();
PDF_set_info_author($pdf, "Luca
Perugini");
PDF_set_info_title($pdf, "Brochure for
FlyStore");
PDF_set_info_creator($pdf, "See
Author");
PDF_set_info_subject($pdf,
"FlyStore");
PDF_begin_page($pdf, 595,
842);
PDF_add_outline($pdf,
"Item".$data[1]);
PDF_set_font($pdf,
"Helvetica-Bold" , 20,
winansi);
PDF_set_text_rendering($pdf, 0);
PDF_show_xy($pdf,
"OMG its a pdf on the fly!",50,780);
if (!isset($name))
{
$name = "Test Name";
}
if (!isset($age))
{
$age = "Test Age";
}
PDF_show_xy($pdf, "Your
Name : $name" .$data[1], 100, 700);
PDF_show_xy($pdf,
"Age : $age" .$data[2], 100,
620);
PDF_stroke($pdf);
PDF_end_page($pdf);
PDF_close($pdf);
fclose($f);
header("Content-length:
" . filesize("test"));
$f =
fopen("/tmp/test",
"r");
fpassthru($f);
fclose($f);
?>
Only
then did it work for me.
|
|
jbinic at hotmail dot com
13-Mar-2001 10:49 |
|
My php compiled ok, but phpinfo() forgot about phplib. I figured out the
libtiff on my box was not the right version. Very offset, I edited
manually configure file and erase all -ltiff or replace them with bogus
-lpng. Don-t care if -lpng wa duplicate. Php works fine now, with pdflib
and without tiff support.
|
|
dmarsh dot nospam at spscc dot ctc dot edu
30-Mar-2001 01:41 |
|
Same as [email protected] only more info!!!!
(comments below are
true as of 4.0.4pl1).
I kept banging my head on the
"samples" that use PDF_new(). If you check
out the source
tree comments on PDF_new(), PDF_delete(), and PDF_open_file() and
you
will see they are only available in the CVS tree.
The
solution:
$fd = fopen("somefile","w"); $pdf =
PDF_open($fd);
[...]
PDF_close($pdf); fclose($f);
You
can't use PDF_new(), PDF_delete(), or PDF_open_file() until the current
CVS
source code tree is branched into a version release at least newer
than 4.0.4pl1!
|
|
matt_nospam at no_spam dot com
17-Apr-2001 10:10 |
|
If you still can't get your pdf files to show up in IE 5.5, here is
something I found on phpBuilder:
1. Be sure to install the SR 1
for IE 5.5
2. Be sure your running Adobe Acrobat 4.0 (not 3.0).
3. Open Adobe Acrobat 4.0 by itself.
4. Click on File
5.
Click on Preferences
6. Click on General
7. Deselect the option
to: Web Browser Integration
That should do it. This does not
correct the problem of opening the files directly in IE, but it's a great
work around....and it works.
|
|
a dot marchand dot nospam at home dot com
01-May-2001 07:42 |
|
To continue on the internet explorer (Iexplorer, IE) requirements, instead
of content-length, a simple:
header("Accept-Ranges:
bytes");
is enough for the getpdf.php file working right.
Even Netscape will without error with this modification.
Aurelien
|
|
webmaster at toolshed51 dot com
01-May-2001 10:10 |
|
An FYI for anybody else looking for pdflib help. I got php-4.0.5 and built
pdflib-4.0.0 with
'./configure' \
'--enable-cxx'
\
'--enable-shared' \
'--enable-shared-pdflib'
I did
make, make install and both make and make install complained that there is
no makefile in pdflib-4.0.0/bind/php. It works anyway, so dont worry
bout it.
Then in php I used --with-pdflib=/usr/local and it works,
this was performed on a FreeBSD 4.2 Release machine
|
|
mued at muetdhiver dot org
06-May-2001 09:11 |
|
If you just have a look into the rep given, you'll see a nice readme.txt
saying you how to make this link working
|
|
tsvitbaum at gmx dot de
27-May-2001 03:27 |
|
When I use
$text='<align="center"><strong>Text
text!</strong></div> ';
....
and
then
$num=pdf_show_boxed($pdfdoc, $text ....)
I get a problem with
PHP: after 30 sek. says PHP... Timiout reached.
With other text
(without HTML Tags) it works fine. Were is a problem here?
Thanx for
Answer.
|
|
jeff at iomojo dot com
27-May-2001 05:08 |
|
With php-4.0.5 and pdflib-4.0.1 there is an error in the php source code
ext/pdf/pdf.c with function pdf_close_pdi_page wanting 3 args instead of
2.
To fix, copy the section for this function from the pdflib
source bind/php/ext/pdf/pdf.c and then it will
compile.
Section from the pdflib source reproduced
below:
/* {{{ proto void pdf_close_pdi(int pdf, int doc);
*
Close all open page handles, and close the input PDF document.
*/
PHP_FUNCTION(pdf_close_pdi) {
zval **arg1, **arg2;
PDF *pdf;
if (ZEND_NUM_ARGS() != 2 ||
zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object",
le_pdf);
convert_to_long_ex(arg2);
PDF_close_pdi(pdf,
Z_LVAL_PP(arg2)-PDFLIB_PDI_OFFSET);
RETURN_TRUE;
}
|
|
casebell at dreamwiz dot com
12-Jun-2001 04:36 |
|
With PHP-4.0.5 and PDFLib 4.0.1 the Error that do not compile in the php
compiling..
The error function in pdf.c is no
PHP_FUNCTION(pdf_close_pdi) but
PHP_FUNCTION(pdf_close_pdi_page)
patch pdf.c in php-4.0.5. Like
as below
PHP_FUNCTION(pdf_close_pdi_page) {
zval **arg1,
**arg2;
PDF *pdf;
if (ZEND_NUM_ARGS() != 2 ||
zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(pdf, PDF
*, arg1, -1, "pdf object",
le_pdf);
convert_to_long_ex(arg2);
PDF_close_pdi_page(pdf,
Z_LVAL_PP(arg2)-PDFLIB_IMAGE_OFFSET);
RETURN_TRUE;
}
|
|
shicks at theaffinitygrp dot com
02-Jul-2001 07:23 |
|
I'm running Apache 1.3.20+PHP 4.0.6+PDFLib 4.0.1 and the 1st example given
above doesn't seem to work. When I try it, I get:
Fatal error:
PDFlib error: function 'PDF_set_info' must not be called in 'object' scope
in /usr/local/apache/htdocs/restricted/accounting/pdftest.php on line
4
Removing the filename and replacing it with "" seems
to make the page work fine again.
|
|
werner at webapps dot co dot za
04-Jul-2001 03:37 |
|
In reply to [email protected] comment about the
"Fatal
error: PDFlib error: function 'PDF_set_info' must not be called in
'object' scope"
The reason why you get this error is because
the directory you are saving to does not have write permission. Make sure
that Apache (or whatever webserver you are using) can actully write to
your directory.
|
|
sdelille at auxicad dot fr
12-Jul-2001 11:33 |
|
PDFLIB 3.0 won't work with PHP 4.0.6 because this version makes use of the
"imagewarning" parameter, available only from PDFLIB version
3.01. PDFLIB 3.03 works fine for me with PHP 4.0.6.
|
|
13-Jul-2001 08:09 |
|
The demo version for windows (.dll) is purely for testing as their
enourmous watermark spanning the entire page diagnolly makes it completely
useless for anything else (that is what their liscensing suggests, I just
wanted to let everyone know in case you got comfortable with the
open-source concept.)
|
|
morten at e-rasmuREMOVETHISTEXTssen dot com
29-Jul-2001 03:06 |
|
To make PDFlib PDFlib 4.0.1 work under PHP 4.0.6, you need to add the file
libpdf_php.so manually to the PHP extension library (as defined in
php.ini).
The file can be downloaded from www.pdflib.com. Just
add it manually after all the compiling stuff is done.
|
|
bob at nijman dot de
02-Aug-2001 11:20 |
|
Try these tutorials:
************************************
************************************
|
|
justin at blowouts dot co dot uk
02-Sep-2001 11:13 |
|
I thought the whole beauty of PHP was the fact that it is free. So to find
out how much the PDFlib licence will cost me was quite a shock. Is there
not a free API for building PDF documents
?
Cheers
Justing
|
|
schirmer at taytron dot net
14-Sep-2001 10:40 |
|
Hi,
yes there is a free one:
Hope
that helps a bit
|
|
hugues at guindaille dot com
10-Jan-2002 12:44 |
|
You can also try for a
completely free PDF-generating class. Not complete yet, but very
promising!
|
|
pasnak at warpedsystems dot sk dot ca
10-Feb-2002 07:21 |
|
Right from their site: The �Aladdin Free Public License�
In
short and non-legal terms:
* you may develop free software with
PDFlib, provided you make all of your own source code publicly
available * you may develop software for your own use with PDFlib as
long as you don't sell it * you may redistribute PDFlib
non-commercially * you may redistribute PDFlib on digital media for a
fee if the complete contents of the media are freely redistributable.
|
|
the_banski at hotmail dot com
05-Mar-2002 10:22 |
|
Is there a way to open a exiting pdf file and add some text to it?
|
|
pbierans at lynet dot de
27-Mar-2002 04:56 |
|
Load extension, open a PDF, add a font, modify PDF in memory and send it
to browser:
<?php // no cache headers:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y
H:i:s")." GMT"); header("Cache-Control: no-store,
no-cache, must-revalidate"); header("Cache-Control:
post-check=0, pre-check=0", false); header("Pragma:
no-cache");
$ext_name="libpdf_php.so"; //
libpdf_php.so is the PDFLIB for SunOS by "PDFlib GmbH" //
visit
// if the extension is not automatically loaded by Apache // dl()
will try to load it on demand: if (!extension_loaded($ext_name)
&& !@dl($ext_name)) { ?> <table
width="100%" border="0"><tr><td
align="center"> <table style="border: solid
#f0f0f0 2px;"><tr> <td
valign="middle" style="padding: 20px; margin:
0px;"> <p style="font-family: arial;
font-size: 12px; "> <b>Sorry,</b>
A PDF can not be generated right
now.
The administrator has been informed and will fix
this as soon as possible.
Please try again
later. </td></tr></table>
</td></tr></table> <?php
mail('[email protected]','Error: PDFLib not found', 'Called by
script:\n '.$SCRIPT_FILENAME.'?'.$QUERY_STRING, "From:
[email protected]\n"); exit; } // verify that extension
is usable
// unique serial number:
srand(microtime()*10000); $usnr=
gmdate("Ymd-His-").rand(1000,9999).'-';
$pdf_file=$usnr.'result.pdf'; $src_file='source.pdf';
//
create pdf object $pdf = pdf_new(); pdf_open_file($pdf);
pdf_set_parameter($pdf, 'serial', 'if-you-have-one');
//
fonts to embed, they are in the folder of this file:
pdf_set_parameter($pdf, 'FontAFM', 'TradeGothic=Tg______.afm');
pdf_set_parameter($pdf, 'FontOutline', 'TradeGothic=Tg______.pfb');
pdf_set_parameter($pdf, 'FontPFM',
'TradeGothic=Tg______.pfm');
// load the source file:
$src_doc =pdf_open_pdi($pdf,$src_file,'', 0); $src_page
=pdf_open_pdi_page($pdf,$src_doc,1,''); $src_width
=pdf_get_pdi_value($pdf,'width' ,$src_doc,$src_page,0);
$src_height=pdf_get_pdi_value($pdf,'height',$src_doc,$src_page,0);
pdf_begin_page($pdf, $src_width, $src_height); { // place the
sourcefile to the background of the actual page:
pdf_place_pdi_page($pdf,$src_page,0,0,1,1);
pdf_close_pdi_page($pdf,$src_page);
// modify the page:
pdf_set_font($pdf, 'TradeGothic', 8, 'host'); pdf_show_xy($pdf,
'Now: '.gmdate("Y-m-d H:i:s"),50,50); }
pdf_end_page($pdf); pdf_close($pdf);
// prepare output:
$pdfdata = pdf_get_buffer($pdf); // to echo the pdf-data $pdfsize =
strlen($pdfdata); // IE requires the datasize
// real
datatype headers: header('Content-type: application/pdf');
header('Content-disposition: attachment;
filename="'.$pdf_file.'"'); header('Content-length:
'.$pdfsize); echo $pdfdata; exit; // keep this one so no #13#10
or #32 will be written ?>
|
|
chernyshevsky at hotmail dot com
06-May-2002 10:22 |
|
If you're wondering how to highlight words inside a PDF file, take a look
at this script I've written (doesn't need PDFLib)
It's
a whole lot harder than you think. (Rarely has no much code been written
that does so little, that's what I say :-) Worth looking at if you want to
do searches inside a PDF.
|
|
bs dot net at gmx dot de
07-Jun-2002 08:11 |
|
Well it's nice to have a PDF function under PHP, but for several problems
PDFlib is useless. Here my problem I need a solution that create a PDF
file after I've had transformed a XML file with XSLT to XSL-FO. Executing
Apache-FOP with the "system" Command is not quite well.
Therefore I need to create a seperate channel to create PDFs. The
usability for transforming XML with XSLT in this case is poor. For
standealone project this lib could be quite usefull, but for XSLT
transforming I think a C++-dll-wrapper for XSL-FO->PDF after
XML->XSLT->XSL-FO is more usefull. Or what do you think about it?
|
|
gilbertng at hongkong dot com
11-Jun-2002 10:23 |
|
Hope it can help someone:
$pdf =
pdf_new(); //pdf_open_file($pdf,""); if
(!pdf_open_file($pdf, "")) { print
error; exit; }
PDF_set_parameter($pdf,
"resourcefile",
"/usr/local/pdflib/fonts/pdflib.upr"); PDF_set_parameter($pdf,"prefix","/usr/local/pdflib/fonts");
pdf_begin_page($pdf,
595, 842); pdf_add_outline($pdf, "Page
1");
//pdf_set_font($pdf, "Times-Roman", 30,
"host"); // set chinese characters, $font =
pdf_findfont($pdf, "MHei-Medium", "B5pc-H",0); if
($font) { pdf_setfont($pdf, $font,
30); }
pdf_set_value($pdf,
"textrendering",0); pdf_show_xy($pdf, "���� 100 Roman
outlined", 50, 750);
pdf_set_font($pdf,
"Times-Roman", 30, "host"); pdf_show_xy($pdf,
"���� Times Roman outlined", 50, 600); pdf_moveto($pdf, 50,
740); pdf_lineto($pdf, 330,
740); pdf_stroke($pdf); 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"); print $buf;
pdf_delete($pdf);
|
|
wern at igroup dot ws
02-Jul-2002 02:02 |
|
Hi Guys
How can you encrypt a pdf document so that it is write
protected. You can read it, but can't make modifications to the file,
except if you have the password.
Apparently this is a new feature
that was added in Adobe Acrobat 5.0.
Thx
|
|
sean dot truman at truson dot biz
07-Aug-2002 12:29 |
|
A Friend of mine has written a PHP class that is free for generating
dynamic PFD.
|
|
matt at nospam dot org
24-Aug-2002 08:51 |
|
It's worth noting that once IE opens a url as pdf, it will always try to
show it as a pdf within that window. So, if you're working on your php
script and produce an error, IE will show a broken image icon instead of
showing the pdf in Adobe Acrobat. It's not that PDFLIB produced a bad
pdf. Instead the php parser has output some standard text first. Close
the browser window you're in, open a new window, and browse again to the
url to see the error.
The same is true if you're working on your
first pdf, and keep getting errors. Once you resolve the parse, PDFLIB,
and whatever other errors there are, you have to close the window, and
launch a new window for IE to show the pdf.
|
|
matt at nospam dot org
29-Aug-2002 06:11 |
|
Adding to my prior note, IE 6 has a strange feature of using GET when
refreshing a pdf document, even though the page was originally POSTed to.
This may be the root cause of all the trouble listed above regarding
posting and pdf.
So, I recommend: 1) using a two page
form/action handler when doing pdf rendering instead of the standard
$PHP_SELF form/self handler to resolve the problem discussed above 2)
Using either GET, or a self posting form that sets cookies and then
redirects to the pdf creation page instead of POST, so that the parms get
to the page. HTH
|
|
frederic dot surleau at atosorigin dot com
18-Sep-2002 09:12 |
|
If you use session, all headers you can send about "cache" are
too late !
See
The
solution is something like this :
<?php // Default is
"no-cache" session_cache_limiter('private');
session_start();
$pdf
= pdf_new();
/* your code here
/*
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"); print $buf; pdf_delete($pdf); ?>
|
|
chees0NOSPAM at sci dot NO_SPAM dot fi
14-Oct-2002 10:03 |
|
--- Begin quote --- If you're wondering how to highlight words inside a
PDF file, take a look at this script I've written (doesn't need
PDFLib)
It's
a whole lot harder than you think. (Rarely has no much code been written
that does so little, that's what I say :-) Worth looking at if you want to
do searches inside a PDF. --- End quote ---
The link was dead.
You can find the script at
|
|
fbordage at ifrance dot fr
01-Nov-2002 05:33 |
|
There's a nice totaly free PDF class at
basic features
are Choice of measure unit, page format and margins Page header
and footer management Automatic page break Automatic line break
and text justification Image support (JPEG and PNG) Colors
Links TrueType, Type1 and encoding support Page compression
Hope this help.
|
|
keithw at nxdomain dot us
20-Nov-2002 03:30 |
|
One of the big problems I faced as I converted legacy applications to web
base apps in PHP was how to handle reports. HTML can only take you so far
and doesn't handle formatted reporting at all, plus printing is
inconsistent among browsers. So, generating PDFs becomes very important
to replace reports that must be highly formatted.
I spent about
half a day setting up and testing PDFlib and while it worked great, I had
reservations about maintenance. Since my apps are not commercial, I
wanted to use the free aladdin license, which requires compiling and
linking PDFlib to PHP. From what I read, the DSO version only comes with
the paid commercial license. So, when my distro vendor releases a patch
for PHP, I would have to recompile it and link in PDFlib every time. A
major pain. Plus, I use several distros and the procedure is slightly
different with each one.
After much searching here and on google, I
found several other solutions, some free, some not. But the one I am
using at the moment is done completely with PHP code (no modules, no
compiling, no linking). It is free and easy to set up and use. It is
called EZPDF and can be found here:
and
here:
Since
it is all done in PHP, it is slower than PDFlib, so if you have strict
performance requirements, it might not be the best, but it has many
features and everything I need.
|
|
japlo at time dot net dot my
25-Nov-2002 09:26 |
|
Another simple and fast php to pdf. Its free under GPL. current version is
1.14. No complilation required.
|
|
20-Dec-2002 12:20 |
|
If you got this message you have already installed de pdflib. I had the
same problem you have and did following changes, and it
works
<?php $pdf = pdf_new(); PDF_open_file($pdf,
"");
PDF_set_info($pdf, "Creator",
"hello.php"); PDF_set_info($pdf, "Author",
"Rainer Schaaf"); PDF_set_info($pdf, "Title",
"Hello world (PHP)");
pdf_begin_page($pdf, 595,
842); pdf_add_outline($pdf, "Page 1"); pdf_set_font($pdf,
"Times-Roman", 30, "host"); pdf_set_value($pdf,
"textrendering", 1); pdf_show_xy($pdf, "Times Roman
outlined", 50, 750); pdf_moveto($pdf, 50,
740); pdf_lineto($pdf, 330,
740); pdf_stroke($pdf); 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=hello.pdf"); print $buf;
pdf_delete($pdf); echo
"<A HREF=getpdf.php>finished</A>"; ?>
|
|
wmoran at potentialtech dot com
29-Jan-2003 11:02 |
|
I appreciate someone listing our phppdflib on this page. I'm glad that
folks feel it's good enough to pass on to others. It's not good that
the link goes directly to version 1.14. This version is known to be buggy
and is superceeded by a very stable version (currently 1.16).
If
the editors could update the link to point to:
It
will point to the phppdflib 'home' page, which always has the most recent
version listed.
We're seeing a LOT of downloads of 1.14. I left it
on the server for archive purposes, but considering the traffic that it's
getting, I'm considering removing it.
|
|
Alexandre Strube
03-Feb-2003 06:00 |
|
For a free alternative to it, try the pdf class found at
|
|
tiago at contempory dot com
06-Feb-2003 08:11 |
|
Hi, my output is that: ------------------------------- %PDF-1.3 %����
5 0 obj <> stream x�=�1�@ ����:
���+�����FI4G00\���"�����K�W98\�D7� � �eF7B�����'
���]�^���r�,��M��{�lG��&c���R �ٺ����Zkْ)L�+w�F ����
*OzD�-�H!z��ީ����_�.�endstream endobj 6 0 obj 157 endobj 4 0 obj
<> endobj 8 0 obj <> >> endobj 3 0 obj <> endobj 7
0 obj <> endobj 1 0 obj <> endobj 2 0 obj <> endobj xref
0 9 0000000000 65535 f 0000000688 00000 n 0000000742 00000 n 0000000425
00000 n 0000000262 00000 n 0000000015 00000 n 0000000243 00000 n
0000000591 00000 n 0000000365 00000 n trailer <] >> startxref 789
%%EOF ------------------------ And my code is
that: ------------------------ <?php
dl("php_pdf.dll");
$p
= PDF_new(); PDF_open_file($p, "");
PDF_set_info($p,
"Creator", "hello.php"); PDF_set_info($p,
"Author", "Rainer Schaaf"); PDF_set_info($p,
"Title", "Hello world
(PHP)");
PDF_begin_page($p, 595, 842);
# Change
"host" encoding to "winansi" or whatever you
need! $font = PDF_findfont($p, "Helvetica-Bold",
"host", 0); PDF_setfont($p, $font,
18.0);
PDF_set_text_pos($p, 50, 700); PDF_show($p, "Hello
world!"); PDF_continue_text($p, "(says
PHP)");
PDF_end_page($p); PDF_close($p);
$buf =
PDF_get_buffer($p); $len =
strlen($buf);
header("Content-type:
application/pdf"); header("Content-Length:
$len"); header("Content-Disposition: inline;
filename=hello.pdf"); print
$buf;
PDF_delete($p);
?> --------------------------------- Anybody
can help-me?
|
|
jkit
07-Feb-2003 01:27 |
|
I think you are using IE. Append a dummy-parameter ending with .pdf when
you call your script. e.g.
|
|
tonia dot yee at utsouthwestern dot edu
18-Apr-2003 11:51 |
|
After discovering how expensive PDFLib was (but needing it's capabilities
anyway), I found out that pgHoster, one particular web hosting company
provides PDFLib with hosting accounts. Their website is
www.pghoster.com.
Just passing on some information so no hunting is
necessary! :)
Tonia
|
|
manish_shilpajp at yahoo dot co dot jp
12-May-2003 05:02 |
|
See
for
generating Japanese PDF documents using FPDF license free code
|
|
manish_shilpajp at yahoo dot co dot jp
12-May-2003 05:04 |
|
For users looking for a license free solution and also Japanese support use
FPDF
and
for japanese support on it see,
Manish
Prabhune imodeindia.com
|
|
|
| |