[Webinar] Streamline your web hosting managementRegister Today


Dynamic print solution for PHP

Posted on 2005-03-29
Medium Priority
Last Modified: 2008-03-17
Hope I am posting this in the correct place.  I am wondering the easiest and quickest solution for providing printed output from a php script..  CSS obviously has its problems and I think producing pdfs is likely to be the best choice.

I need control over page breaks, be able to generate table of contents, etc.   I would like the format to stay as it is after generated.  The files are around 100 pages.

I would be grateful to hear of solutions/software for high quality output that does not involve a lot of time to learn or setup and are dynamically produced.  Not sure if I am asking too much, but would be glad to hear from those of you who have done this yourself.  The page breaks are giving me a bit of grief at the moment.  I can see how I could  list the chapters for a table of contents, but not how to pick up the page numbers.



Question by:debbieau1
  • 3
  • 2
  • 2
  • +1

Accepted Solution

sow56091 earned 1000 total points
ID: 13659751
Hi debbieau1,

Try RandOs' PHP PDF creation library: http://www.ros.co.nz/pdf 

It's free, easy to set up, requires no rebuild of PHP or Apache, and is well documented, plus it works great with tables.

LVL 32

Assisted Solution

Batalf earned 500 total points
ID: 13659763
PDF is the definitive choice.

There are several alternatives

1) Generate the whole content from scratch using PDFLib - Library for PDFLib is embedded in PHP, but you will need a license in order to get PDFs without watermarks.

2) Use HTML->DocBook->FOP->PDF transformation.

Convert your content to DocBook(a XML format), then use FOP to convert it to PDFs. There's a lot of sources

Check out



Author Comment

ID: 13660317

Thanks very much for the responses.  Firstly the RandO's appears to be non commercial use, and I do need this for work, so I don't think that will do.

I am hoping for a solution which will be really quick to learn if possible.   I haven't time to learn xml for this project, although am defniitely interested in this.  I really need something quick to get this project out.  

I would be very grateful if you have any other suggestions, even if it means purchasing some reasonably priced software.  The time to learn is the biggest problem for this project.

The main thing is to be able to get the page breaks in. accurately.  Heading styles are working fine from the css style sheet and for this one I could do without the table of contents if I have to, although it would be great if there was a quick answer to this.


[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

LVL 32

Expert Comment

ID: 13660328
You can try this one:


I haven't tested it, but it looks promising.

Author Comment

ID: 13660389
Had a look at the digitaljunkies link, thanks and yes it does look promising, but it says it does not support  bullets which I have in several areas of the file.

Also, I am not clear with dynamic pdf generation, does it  keep any formatting put in from CSS or is one starting from scratch with formatting?

Expert Comment

ID: 13660450
Why do you say "Firstly the RandO's appears to be non commercial use?"

The documentation says, "This class is designed to provide a non-module, non-commercial alternative to dynamically creating pdf documents from within PHP."

This means that you are not *paying* to use it. It is free software as well as being recommended by Oreilley's Hugh E. Williams & David Lane who wrote "Building Effective Database-Driven Web Sites"

If you go to http://www.webdatabasebook.com/
"In this section, we show you how to use R&OS Ltd's free PHP PDF creation library (we refer to this as pdf-php throughout this section) The library has two advantages over other approaches it's free and it doesn't require any additional PHP configuration What's more, it's powerful and you can do most things you need, including producing tables containing results from database queries and inserting images into a document."
LVL 13

Assisted Solution

bochgoch earned 500 total points
ID: 13660464
FPDF is my choice, all the joy of PDFlib without the need for a licence...


It's easy to set up, you'll probably want to write some PHP code to generate some standard output -- header, footer, table, toc etc...certainly provided what I needed....


Author Comment

ID: 13660630
I'm sorry about the RandO.  I skimmed the readme file, and I think I read the non commercial as not for commercial use, but just looking back,  yes I think it is fine.    Sorry about that.  A bit too tired I think.  

Thanks very much eveyrone.  I will split the points and hope that is fair.

Thanks again.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question