Discussion:
Zend_PDF use cases
Justin Hendrickson
2007-08-24 18:40:32 UTC
Permalink
Per Andi's blog post
(http://andigutmans.blogspot.com/2007/08/use-cases-for-php-and-pdf-needed.html),
I'd like to share my experiences with Pdf usage in PHP.

I have worked on two projects where Pdf output was used. The first was
an e-commerce site where physical invoice printouts were needed. The
second is a legacy printing solution that allows replacement of line
printers and preprinted forms with a laser printers and a template Pdf
which is printed over.

In both cases, the primary required feature was the ability to output
over pre-formatted templates. In the later case, additional features
have been developed to allow for images and barcodes to be added to
the printout.

In both cases, I used FPDF because it was free and (barely) sufficient.

Since the second project is still in active development, I've reviewed
Zend_Pdf from time to time to see if the ability to use pre-formatted
templates had been added. From what I can tell, it has not. There does
appear to be a stub of code for copying existing templates, but it is
only a stub that throws an exception when you try to use it
(Zend/Pdf/Page.php, line 236).

I would give up my first born to use Zend_Pdf instead of FPDF, but
until this feature is added (or if it already is, I figure out how to
use it), I'm stuck with FPDF.
Andi Gutmans
2007-08-25 02:04:52 UTC
Permalink
We do support read-then-write on documents; but are templates the
"forms" version of Pdf? If so, that's a bit different, right?
Barcode is a feature request which I've heard many times. We should
definitely provide that. Are there any sub-requirements you'd have of
barcodes?

Andi
-----Original Message-----
Sent: Friday, August 24, 2007 11:41 AM
Subject: [fw-formats] Zend_PDF use cases
Per Andi's blog post
(http://andigutmans.blogspot.com/2007/08/use-cases-for-php-and-pdf-
needed.html),
I'd like to share my experiences with Pdf usage in PHP.
I have worked on two projects where Pdf output was used. The first was
an e-commerce site where physical invoice printouts were needed. The
second is a legacy printing solution that allows replacement of line
printers and preprinted forms with a laser printers and a template Pdf
which is printed over.
In both cases, the primary required feature was the ability to output
over pre-formatted templates. In the later case, additional features
have been developed to allow for images and barcodes to be added to
the printout.
In both cases, I used FPDF because it was free and (barely)
sufficient.
Since the second project is still in active development, I've reviewed
Zend_Pdf from time to time to see if the ability to use pre-formatted
templates had been added. From what I can tell, it has not. There does
appear to be a stub of code for copying existing templates, but it is
only a stub that throws an exception when you try to use it
(Zend/Pdf/Page.php, line 236).
I would give up my first born to use Zend_Pdf instead of FPDF, but
until this feature is added (or if it already is, I figure out how to
use it), I'm stuck with FPDF.
Andi Gutmans
2007-08-25 22:34:21 UTC
Permalink
Cc'ing fw-formats. Alex is the best person to answer these questions.

Thanks for the detailed follow-up. This is very helpful!

Andi
-----Original Message-----
Sent: Saturday, August 25, 2007 2:28 PM
To: Andi Gutmans
Subject: Re: [fw-formats] Zend_PDF use cases
It'd be nice to have a wide variety of bar codes types to select from.
We use Code 39 (http://en.wikipedia.org/wiki/Code_39), but I know it's
not the only mode our clients have requested.
Actually, more generally, it'd be helpful to see what the 'Zend
Framework' approach to this kind of added functionality would be. In
my current project, I used decorators to add the bar code and image
functionality I needed, but I would love to see how you would go about
it.
On the subject of read-then-write documents and templates, I need to
apply multiple pages of data over one template. Is it possible to read
in a document and copy the template page to accommodate multiple
pages? The last time I played with the library was around 0.7.0 and I
wasn't able to figure out how to accomplish this.
Post by Andi Gutmans
We do support read-then-write on documents; but are templates the
"forms" version of Pdf? If so, that's a bit different, right?
Barcode is a feature request which I've heard many times. We should
definitely provide that. Are there any sub-requirements you'd have of
barcodes?
Andi
-----Original Message-----
Sent: Friday, August 24, 2007 11:41 AM
Subject: [fw-formats] Zend_PDF use cases
Per Andi's blog post
(http://andigutmans.blogspot.com/2007/08/use-cases-for-php-and-pdf-
Post by Andi Gutmans
needed.html),
I'd like to share my experiences with Pdf usage in PHP.
I have worked on two projects where Pdf output was used. The first
was
Post by Andi Gutmans
an e-commerce site where physical invoice printouts were needed.
The
Post by Andi Gutmans
second is a legacy printing solution that allows replacement of
line
Post by Andi Gutmans
printers and preprinted forms with a laser printers and a template
Pdf
Post by Andi Gutmans
which is printed over.
In both cases, the primary required feature was the ability to
output
Post by Andi Gutmans
over pre-formatted templates. In the later case, additional
features
Post by Andi Gutmans
have been developed to allow for images and barcodes to be added to
the printout.
In both cases, I used FPDF because it was free and (barely)
sufficient.
Since the second project is still in active development, I've
reviewed
Post by Andi Gutmans
Zend_Pdf from time to time to see if the ability to use pre-
formatted
Post by Andi Gutmans
templates had been added. From what I can tell, it has not. There
does
Post by Andi Gutmans
appear to be a stub of code for copying existing templates, but it
is
Post by Andi Gutmans
only a stub that throws an exception when you try to use it
(Zend/Pdf/Page.php, line 236).
I would give up my first born to use Zend_Pdf instead of FPDF, but
until this feature is added (or if it already is, I figure out how
to
Post by Andi Gutmans
use it), I'm stuck with FPDF.
Olivier Sirven
2007-08-26 00:01:21 UTC
Permalink
Hi,

Just another mail to try to explain the requirements of Zend_Pdf so I'll be
able to use it.
When I need to work with pdf format I currently use RML format. I create an
xml template that I fill with php then I convert it to a pdf format.
As far as I know it is the best solution I found. FPDF does not fit my needs
as it represents a pdf file like a paper on which you are drawing whereas I
just want to manipulate textual data.
The best pdf library I would imagine would let me create an instance from a
pdf template (or anything else that would be easy to manipulate by hand) and
then add/modify values as I like without considering drawing stuffs.
For example, i'd like to be able to create an area where I'll be able to draw
a string without considering if a given string is too long to fit into it.
Something like:

$box = $pdf->createTextBox(42, 42, 100); // create a text box positionned at
(42,42) with a width of 100px
$box->setText('this is a very long line which will have an automatically added
return to the line');

It would draw something like this:
*----------------------*
| This is a very long |
| line which will have |
| an automatically |
| added return to the |
| line |
*----------------------*

Maybe Zend_Pdf is able to do something like this but it was not the case the
last time I checked.

Regards,
--
Olivier Sirven

Elma Ingénierie Informatique
Groupe Maximiles S.A.
3 rue d'Uzès
F-75002 - Paris - France
Pho. 33-144882744
Fax. 33-144882747
Alexander Veremyev
2007-08-26 18:11:26 UTC
Permalink
Hi Justin,

In principle that's a common use case for Zend_Pdf to load existing PDF,
draw something over existing page (ex. customer info) or add some new
pages, then save resulting PDF as a new document (or send it as an HTTP
response).

The exception you get means you try to construct new page using existing
one. Zend_Pdf is designed for page cloning and detaching page from a
document, but these features are not implemented in current ZF version.


The general question we have: does Zend_Pdf need rich text drawing
features like paragraphs, header/footers, tables and others which should
help to construct document from a scratch or is it enough to have
possibility to draw over existing page?


With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Friday, August 24, 2007 10:41 PM
Subject: [fw-formats] Zend_PDF use cases
Per Andi's blog post
(http://andigutmans.blogspot.com/2007/08/use-cases-for-php-and
-pdf-needed.html),
I'd like to share my experiences with Pdf usage in PHP.
I have worked on two projects where Pdf output was used. The
first was an e-commerce site where physical invoice printouts
were needed. The second is a legacy printing solution that
allows replacement of line printers and preprinted forms with
a laser printers and a template Pdf which is printed over.
In both cases, the primary required feature was the ability
to output over pre-formatted templates. In the later case,
additional features have been developed to allow for images
and barcodes to be added to the printout.
In both cases, I used FPDF because it was free and (barely)
sufficient.
Since the second project is still in active development, I've
reviewed Zend_Pdf from time to time to see if the ability to
use pre-formatted templates had been added. From what I can
tell, it has not. There does appear to be a stub of code for
copying existing templates, but it is only a stub that throws
an exception when you try to use it (Zend/Pdf/Page.php, line 236).
I would give up my first born to use Zend_Pdf instead of
FPDF, but until this feature is added (or if it already is, I
figure out how to use it), I'm stuck with FPDF.
Alexander Veremyev
2007-08-26 18:41:22 UTC
Permalink
PS The important functionality we don't have now is page cloning.
It's already was requested recently (ZF-1309) and it's not so large task
as providing rich text drawing API based on some document model. I think
it would be good improvement for ZF 1.1

Nevertheless, other question is still open. Does Zend_Pdf needs improved
text decoration features (including text flow processing and automatic
pagination based on specified page parameters) or it's enough to draw
over existing pages or some page template.


With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Sunday, August 26, 2007 2:34 AM
To: Justin Hendrickson
Subject: RE: [fw-formats] Zend_PDF use cases
Cc'ing fw-formats. Alex is the best person to answer these questions.
Thanks for the detailed follow-up. This is very helpful!
Andi
-----Original Message-----
Sent: Saturday, August 25, 2007 2:28 PM
To: Andi Gutmans
Subject: Re: [fw-formats] Zend_PDF use cases
It'd be nice to have a wide variety of bar codes types to
select from.
We use Code 39 (http://en.wikipedia.org/wiki/Code_39), but
I know it's
not the only mode our clients have requested.
Actually, more generally, it'd be helpful to see what the 'Zend
Framework' approach to this kind of added functionality
would be. In
my current project, I used decorators to add the bar code and image
functionality I needed, but I would love to see how you
would go about
it.
On the subject of read-then-write documents and templates,
I need to
apply multiple pages of data over one template. Is it
possible to read
in a document and copy the template page to accommodate multiple
pages? The last time I played with the library was around
0.7.0 and I
wasn't able to figure out how to accomplish this.
Post by Andi Gutmans
We do support read-then-write on documents; but are templates the
"forms" version of Pdf? If so, that's a bit different, right?
Barcode is a feature request which I've heard many times.
We should
Post by Andi Gutmans
definitely provide that. Are there any sub-requirements you'd have
of
Post by Andi Gutmans
barcodes?
Andi
-----Original Message-----
Sent: Friday, August 24, 2007 11:41 AM
Subject: [fw-formats] Zend_PDF use cases
Per Andi's blog post
(http://andigutmans.blogspot.com/2007/08/use-cases-for-php-and-pdf-
Post by Andi Gutmans
needed.html),
I'd like to share my experiences with Pdf usage in PHP.
I have worked on two projects where Pdf output was
used. The first
was
Post by Andi Gutmans
an e-commerce site where physical invoice printouts were needed.
The
Post by Andi Gutmans
second is a legacy printing solution that allows replacement of
line
Post by Andi Gutmans
printers and preprinted forms with a laser printers and
a template
Pdf
Post by Andi Gutmans
which is printed over.
In both cases, the primary required feature was the ability to
output
Post by Andi Gutmans
over pre-formatted templates. In the later case, additional
features
Post by Andi Gutmans
have been developed to allow for images and barcodes to be added
to
Post by Andi Gutmans
the printout.
In both cases, I used FPDF because it was free and (barely)
sufficient.
Since the second project is still in active development, I've
reviewed
Post by Andi Gutmans
Zend_Pdf from time to time to see if the ability to use pre-
formatted
Post by Andi Gutmans
templates had been added. From what I can tell, it has
not. There
does
Post by Andi Gutmans
appear to be a stub of code for copying existing
templates, but it
is
Post by Andi Gutmans
only a stub that throws an exception when you try to use it
(Zend/Pdf/Page.php, line 236).
I would give up my first born to use Zend_Pdf instead
of FPDF, but
Post by Andi Gutmans
until this feature is added (or if it already is, I
figure out how
to
Post by Andi Gutmans
use it), I'm stuck with FPDF.
Alexander Veremyev
2007-08-26 18:55:05 UTC
Permalink
Hi Olivier,

Great thanks for the feedback.

What can you say, does it enough to have "text boxes" functionality with line formatting features (automatic line breaks, left/right aligned, centered, justified text, ...) or is it also necessary to have page formatting functionality (generating page or pages depending on text flow and specified page parameters).

We have prepared a document which describes "abstract document model" for such functionality: http://framework.zend.com/wiki/x/nI0
Comments and suggestions are welcomed!


With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Sunday, August 26, 2007 4:01 AM
Subject: Re: [fw-formats] Zend_PDF use cases
Hi,
Just another mail to try to explain the requirements of
Zend_Pdf so I'll be able to use it.
When I need to work with pdf format I currently use RML
format. I create an xml template that I fill with php then I
convert it to a pdf format.
As far as I know it is the best solution I found. FPDF does
not fit my needs as it represents a pdf file like a paper on
which you are drawing whereas I just want to manipulate textual data.
The best pdf library I would imagine would let me create an
instance from a pdf template (or anything else that would be
easy to manipulate by hand) and then add/modify values as I
like without considering drawing stuffs.
For example, i'd like to be able to create an area where I'll
be able to draw a string without considering if a given
string is too long to fit into it.
$box = $pdf->createTextBox(42, 42, 100); // create a text box
positionned at
(42,42) with a width of 100px
$box->setText('this is a very long line which will have an
automatically added return to the line');
*----------------------*
| This is a very long |
| line which will have |
| an automatically |
| added return to the |
| line |
*----------------------*
Maybe Zend_Pdf is able to do something like this but it was
not the case the last time I checked.
Regards,
--
Olivier Sirven
Elma Ingénierie Informatique
Groupe Maximiles S.A.
3 rue d'Uzès
F-75002 - Paris - France
Pho. 33-144882744
Fax. 33-144882747
Olivier Sirven
2007-08-27 08:44:24 UTC
Permalink
Hi Alexander,

As far as I am concerned, line formatting features are sufficient. When
generating pdf documents, I have to create a specific document layout. So I
know when I am supposed to generate a new page or not.
I have read your document "abstract document model" and it seems to be what I
was waiting for ! :)
Post by Alexander Veremyev
Hi Olivier,
Great thanks for the feedback.
What can you say, does it enough to have "text boxes" functionality with
line formatting features (automatic line breaks, left/right aligned,
centered, justified text, ...) or is it also necessary to have page
formatting functionality (generating page or pages depending on text flow
and specified page parameters).
We have prepared a document which describes "abstract document model" for
such functionality: http://framework.zend.com/wiki/x/nI0 Comments and
suggestions are welcomed!
With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Sunday, August 26, 2007 4:01 AM
Subject: Re: [fw-formats] Zend_PDF use cases
Hi,
Just another mail to try to explain the requirements of
Zend_Pdf so I'll be able to use it.
When I need to work with pdf format I currently use RML
format. I create an xml template that I fill with php then I
convert it to a pdf format.
As far as I know it is the best solution I found. FPDF does
not fit my needs as it represents a pdf file like a paper on
which you are drawing whereas I just want to manipulate textual data.
The best pdf library I would imagine would let me create an
instance from a pdf template (or anything else that would be
easy to manipulate by hand) and then add/modify values as I
like without considering drawing stuffs.
For example, i'd like to be able to create an area where I'll
be able to draw a string without considering if a given
string is too long to fit into it.
$box = $pdf->createTextBox(42, 42, 100); // create a text box
positionned at
(42,42) with a width of 100px
$box->setText('this is a very long line which will have an
automatically added return to the line');
*----------------------*
| This is a very long |
| line which will have |
| an automatically |
| added return to the |
| line |
*----------------------*
Maybe Zend_Pdf is able to do something like this but it was
not the case the last time I checked.
Regards,
--
Olivier Sirven
Elma Ingénierie Informatique
Groupe Maximiles S.A.
3 rue d'Uzès
F-75002 - Paris - France
Pho. 33-144882744
Fax. 33-144882747
--
Olivier Sirven

Elma Ingénierie Informatique
Groupe Maximiles S.A.
3 rue d'Uzès
F-75002 - Paris - France
Pho. 33-144882744
Fax. 33-144882747
talawahdotnet
2007-08-27 17:44:33 UTC
Permalink
I feel like other people have touched on this, but I would like to say it
explicitely. I would like to be able to dynamically populate a PDF
(form/template) with PHP variables in a similar manner to how fdf/xfdf
(http://php.net/fdf) works.

However rather then send the user the fdf file with a reference to the PDF
file I want to be able to send them a complete PDF with their customized
data embedded. I have had problems in the past where FDF didn't work
depending on the users browser/plugin settings (default browser, open using
plugin vs open externally, etc).
From what I have seen of the Zend PDF extension so far it seem to involve
drawing objects on a PDF document. I am more interested in inserting
strings into predefined placeholders.
--
View this message in context: http://www.nabble.com/Zend_PDF-use-cases-tf4325141s16154.html#a12354145
Sent from the Zend MFS mailing list archive at Nabble.com.
gimecoffee
2007-09-18 22:01:33 UTC
Permalink
This is exactly what I need. I have a 2 page template from a 3rd party
provider. Currently we combine them from a fdf file for multiple clients
separately but I like to print all 23 clients at 1 time. (eg . . . pick the
23 clients, have php pull 1 template file and data fill output to a 46 page
pdf our custom service person can print out.)

Thoughts / possible?
Post by talawahdotnet
I feel like other people have touched on this, but I would like to say it
explicitely. I would like to be able to dynamically populate a PDF
(form/template) with PHP variables in a similar manner to how fdf/xfdf
(http://php.net/fdf) works.
However rather then send the user the fdf file with a reference to the PDF
file I want to be able to send them a complete PDF with their customized
data embedded. I have had problems in the past where FDF didn't work
depending on the users browser/plugin settings (default browser, open
using plugin vs open externally, etc).
From what I have seen of the Zend PDF extension so far it seem to involve
drawing objects on a PDF document. I am more interested in inserting
strings into predefined placeholders.
--
View this message in context: http://www.nabble.com/Zend_PDF-use-cases-tf4325141s16154.html#a12767025
Sent from the Zend MFS mailing list archive at Nabble.com.
ljbuesch
2007-09-25 19:09:35 UTC
Permalink
I have recently been working on creating a simple PDF title page and
attaching it to another full PDF document. In doing this, I need to center
text vertically and horizontally. I recently looked over
http://framework.zend.com/wiki/display/ZFDEV/Zend_Pdf+document+abstraction+model
that document, but didn't notice any way to have the document
"automatically" center my text on the screen (maybe I missed something?).

The current approach was to generate the page with FPDF, and combine them
using an exec() call to ghostscript. The problem with that, is that
ghostscript choked on certain PDF documents when attempting to combine them
- not to mention the messiness of the code.

I recently created a new bug report, ZF-1993, which corrects the font glyph
widths. I also commented on ZF-1254 which has my class attached which was
inspired by FPDF's cells. It wouldn't be difficult to extend this so that
if you specify a certain width, then the text can wrap inside of it,
although since it is not currently what was necessary for my needs, I didn't
implement it.

-Logan
--
View this message in context: http://www.nabble.com/Zend_PDF-use-cases-tf4325141s16154.html#a12885683
Sent from the Zend MFS mailing list archive at Nabble.com.
Willie Alberty
2007-09-25 21:46:58 UTC
Permalink
Post by ljbuesch
I have recently been working on creating a simple PDF title page and
attaching it to another full PDF document. In doing this, I need to center
text vertically and horizontally. I recently looked over
http://framework.zend.com/wiki/display/ZFDEV/Zend_Pdf+document
+abstraction+model
that document, but didn't notice any way to have the document
"automatically" center my text on the screen (maybe I missed
something?).
This capability does not yet exist in the framework. There are a
couple of efforts underway to address this limitation. The one you
mention is based on XML-FO and is currently soliciting feedback. I
also have a half-finished implementation of a text layout system that
is currently seeking work to finance its completion. :-)
Post by ljbuesch
The current approach was to generate the page with FPDF, and
combine them
using an exec() call to ghostscript. The problem with that, is that
ghostscript choked on certain PDF documents when attempting to
combine them
- not to mention the messiness of the code.
I recently created a new bug report, ZF-1993, which corrects the
font glyph widths.
Thanks for working on that and submitting a patch. As it turns out, a
patch isn't necessary. I believe there is an API call you were
missing (which underscores the need for enhanced text handling in the
framework). See my comments in the issue.
Post by ljbuesch
I also commented on ZF-1254 which has my class attached which was
inspired by FPDF's cells. It wouldn't be difficult to extend this so that
if you specify a certain width, then the text can wrap inside of it,
although since it is not currently what was necessary for my needs, I didn't
implement it.
I'll take a look at your class. Have you submitted a contributor
license agreement (CLA)?

--

Willie Alberty, Owner
Spenlen Media
willie-***@public.gmane.org

http://www.spenlen.com/
ljbuesch
2007-09-26 03:09:43 UTC
Permalink
Ahh, well, that answers a few questions that I while I was looking through
the file - I thought having fake values for widths was a bit off, but I
sorta just stuck with it under the mentality that it was on the TODO list.
I appreciate the clarification. You will probably see in my class that I
created where I used the wrong widths, but that's not a difficult change to
make. I have only spent a couple of days diving into the PDF specification,
so I will definitely have to look over those resources to get a better grasp
of what's happening. I would appreciate any feedback that you have on that
class that I had offered - so far it has gotten me by for what I have needed
to do.

I have not submitted a CLA yet, although I would be more than glad to do
that in order to contribute - I'll probably get around to that later this
week.
--
View this message in context: http://www.nabble.com/Zend_PDF-use-cases-tf4325141s16154.html#a12893158
Sent from the Zend MFS mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...