0

I'm currently building an app for managing a small organization. One of the functions of the app is printing out a bunch of monthly letters to the members. The way it works is I pull data from the DB about the member (name, address, dates, etc...) and then populate a letter template that has placeholder variables for all the details.

After all the letters are populated I need to give the user the option to print the entire block of letters. This is where my problem comes in. I want it so that each letter would print on a single sheet of paper, and the content be centered and aligned in the middle of the page.

I've attempted to make a Print Media stylesheet and inject the content into a div which I then style to fill the page, but this solution doesn't seem to work properly mainly due to layout issues.

Is this something I should be doing with another format? Should I be sending this to Word or PDF for proper handling or is this something that can done with HTML, CSS?

Note: The stack i'm using is bog standard Linux/PHP and I can pretty much install any additional 3rd party library that I might need.

Any ideas?

Charles
  • 50,943
  • 13
  • 104
  • 142
Steve
  • 161
  • 1
  • 11

1 Answers1

0

HTML isn't very good for this job, especially if you have a single HTML page with many letters (i.e. you want each letter to start on a new page).

There are lots of PDF generation tools for PHP and PDF is actually rather good for print layouts.

PDF will let you control the fine-grained aspects of printing, such as keeping blocks together, when to start a new page and much, much more!

Which one is the best PDF-API for PHP?

Community
  • 1
  • 1
Fenton
  • 241,084
  • 71
  • 387
  • 401