Wizard to Create PDF from MySQL Data?

Wizard to Create PDF from MySQL Data?

am 05.03.2006 00:58:20 von AK

Kinda new - well ,really new, but here goes.

I have a mySQL database that resides on the third party commercial web
server/service away from our offices. We upload data to that database, and
then use scripts to extract various data elements and place them on an
invoice which we email out to customers. (an invoice showing items,
quantity, amounts etc.)

No problem with extraction and sending of the email. Problem comes in that
the formatting of the email is not "locked down. What I mean by this is that
the columns of data that are supposed to line up, do so exactly when viewed
on email program #1, but then are misaligned whe viewed with email program
#2. (Took us a week to figure out it was the email viewer at the customers
that was causing the "bad" behaviour.)


Someone said that email formatting was squirrely like that and that we
should consider creating a pdf invoice and then sending that out. This is
what we want to try. (Yes, we can send a word document, etx, but want to try
this pdf thing right now)

I see in the php manual I got at the bookstore that pph can write data to a
pdf, BUT, to me it seems like a pretty brute force raw-code method - almost
as bad as coding an html webpage entirely by hand, instead of using a html
page generator/widard.

Question - Is there some utility/widard that folks use on the web server end
to get data out of the My SQL and onto a pdf , which I would then send by
email?

Seems like ther must be, but, I am so in-initiated that I don't know what to
look for. I think I am needing a utility that will write the appropriate php
script based on where I set up tables etc on the pdf template page.

Thanks.

Re: Wizard to Create PDF from MySQL Data?

am 05.03.2006 02:13:18 von Shion

AK wrote:

> Question - Is there some utility/widard that folks use on the web server end
> to get data out of the My SQL and onto a pdf , which I would then send by
> email?

As people has different needs, it's difficult to make a script that will
generate a pdf on a result from a sql query.

It's really better to write that yourself, you know how you want your pages to
look, if you just fetch rows with X columns, the method to get it appear on
your HTML page wouldn't be so much different that the one needed for pdf.

You would need to think of that 0,0 is the right bottom corner and that you
need to keep check of the page size. When you made the general code for
generating one page, you easily make that to work in a loop to generate many
pages. You get a lot more control of how things should be than if you had used
some general code someone else had written.


Keep in mind, before you start to use pdf in php, see that your webhost does
have pdf support in their php.


//Aho

Re: Wizard to Create PDF from MySQL Data? Clarification

am 05.03.2006 03:41:13 von AK

A Clarification

The invoice email is sent from the server, not from our client side system.
It is a server side, automated cron tab, pdf generation and sending of the
pdf invoice by the 3party sender, that I am trying to accomplish.

AK


"AK" wrote in message
news:wQpOf.3428$gm.2718@tornado.texas.rr.com...
> Kinda new - well ,really new, but here goes.
>
> I have a mySQL database that resides on the third party commercial web
> server/service away from our offices. We upload data to that database, and
> then use scripts to extract various data elements and place them on an
> invoice which we email out to customers. (an invoice showing items,
> quantity, amounts etc.)
>
> No problem with extraction and sending of the email. Problem comes in that
> the formatting of the email is not "locked down. What I mean by this is
> that the columns of data that are supposed to line up, do so exactly when
> viewed on email program #1, but then are misaligned whe viewed with email
> program #2. (Took us a week to figure out it was the email viewer at the
> customers that was causing the "bad" behaviour.)
>
>
> Someone said that email formatting was squirrely like that and that we
> should consider creating a pdf invoice and then sending that out. This is
> what we want to try. (Yes, we can send a word document, etx, but want to
> try this pdf thing right now)
>
> I see in the php manual I got at the bookstore that pph can write data to
> a pdf, BUT, to me it seems like a pretty brute force raw-code method -
> almost as bad as coding an html webpage entirely by hand, instead of using
> a html page generator/widard.
>
> Question - Is there some utility/widard that folks use on the web server
> end to get data out of the My SQL and onto a pdf , which I would then send
> by email?
>
> Seems like ther must be, but, I am so in-initiated that I don't know what
> to look for. I think I am needing a utility that will write the
> appropriate php script based on where I set up tables etc on the pdf
> template page.
>
> Thanks.
>

Re: Wizard to Create PDF from MySQL Data?

am 05.03.2006 03:42:58 von AK

OK Thanks for the reply - I will check. Also see my clarification. I think
though that you understood what I was trying to do.

AK


"J.O. Aho" wrote in message
news:46us9fFcvhlfU1@individual.net...
> AK wrote:
>
>> Question - Is there some utility/widard that folks use on the web server
>> end to get data out of the My SQL and onto a pdf , which I would then
>> send by email?
>
> As people has different needs, it's difficult to make a script that will
> generate a pdf on a result from a sql query.
>
> It's really better to write that yourself, you know how you want your
> pages to look, if you just fetch rows with X columns, the method to get it
> appear on your HTML page wouldn't be so much different that the one needed
> for pdf.
>
> You would need to think of that 0,0 is the right bottom corner and that
> you need to keep check of the page size. When you made the general code
> for generating one page, you easily make that to work in a loop to
> generate many pages. You get a lot more control of how things should be
> than if you had used some general code someone else had written.
>
>
> Keep in mind, before you start to use pdf in php, see that your webhost
> does have pdf support in their php.
>
>
> //Aho

Re: Wizard to Create PDF from MySQL Data?

am 05.03.2006 09:11:17 von David Quinton

On Sun, 05 Mar 2006 02:13:18 +0100, "J.O. Aho"
wrote:

>AK wrote:
>
>> Question - Is there some utility/widard that folks use on the web server end
>> to get data out of the My SQL and onto a pdf , which I would then send by
>> email?
>
>As people has different needs, it's difficult to make a script that will
>generate a pdf on a result from a sql query.
>
>It's really better to write that yourself, you know how you want your pages to
>look, if you just fetch rows with X columns, the method to get it appear on
>your HTML page wouldn't be so much different that the one needed for pdf.

The way that I've done it (and I'm not saying is the best / the only
way) if to write out on server as an html file, then exec() html2ps
and then ghostscript it to a PDF.

But our App needs the PS and html files too, so there's probably a
quicker way around it without my intermediate stages!
--
Locate your Mobile phone:
Great gifts:

Re: Wizard to Create PDF from MySQL Data?

am 05.03.2006 09:22:40 von Shion

David Quinton wrote:
> On Sun, 05 Mar 2006 02:13:18 +0100, "J.O. Aho"
> wrote:
>
>> AK wrote:
>>
>>> Question - Is there some utility/widard that folks use on the web server end
>>> to get data out of the My SQL and onto a pdf , which I would then send by
>>> email?
>> As people has different needs, it's difficult to make a script that will
>> generate a pdf on a result from a sql query.
>>
>> It's really better to write that yourself, you know how you want your pages to
>> look, if you just fetch rows with X columns, the method to get it appear on
>> your HTML page wouldn't be so much different that the one needed for pdf.
>
> The way that I've done it (and I'm not saying is the best / the only
> way) if to write out on server as an html file, then exec() html2ps
> and then ghostscript it to a PDF.
>
> But our App needs the PS and html files too, so there's probably a
> quicker way around it without my intermediate stages!

If you use PDFlib, then you can generate pdf files without using html2ps and
ghostscript and you will gain quite much speed in the process too. You may
want a license to use it, www.pdflib.com www.php.net/manual/en/ref.pdf.php


//Aho

Re: Wizard to Create PDF from MySQL Data? Clarification

am 05.03.2006 09:26:44 von Shion

AK wrote:

> The invoice email is sent from the server, not from our client side system.
> It is a server side, automated cron tab, pdf generation and sending of the
> pdf invoice by the 3party sender, that I am trying to accomplish.

Using pdflib (see http://www.php.net/manual/en/ref.pdf.php), you generate pdf
on the server, you can have function in your web-application that auto
generates the pdf, fetches e-mail address from a database (or allow the one
visiting the page enter the e-mail) and mail the pdf to the client.

This don't require any cron jobs.


//Aho

Re: Wizard to Create PDF from MySQL Data? Clarification

am 05.03.2006 14:05:13 von zac.carey

I can't pretend to fully understand the process that you're using here
- but it might be worth looking at fpdf (www.fpdf.org) to see if it can
provide the functionality you require.

There's lots of useful scripts included on the site - and loads of
extra info provided in the forums. I use it for generating mailing
labels - but I guess that's a much simpler operation than what you're
after.

Re: Wizard to Create PDF from MySQL Data?

am 05.03.2006 21:37:08 von nc

AK wrote:
>
> I see in the php manual I got at the bookstore that pph can write
> data to a pdf,

Be sure your server has required extentions installed; if not, you
might be forced to use a pure PHP solution such as FPDF; it will still
work, but somewhat slower.

> BUT, to me it seems like a pretty brute force raw-code method -
> almost as bad as coding an html webpage entirely by hand,
> instead of using a html page generator/widard.

Well, that's PDF for you...

> Question - Is there some utility/widard that folks use on the web
> server end to get data out of the My SQL and onto a pdf , which
> I would then send by email?

Think about it... How do you generate PDF on your computer? You
generate the document first in another program and then "print" it into
PDF, directly or by generating PostScipt first... PDF is not something
that is easy to create from scratch...

You could look into software that converts HTML into PDF. This,
however, will require installing additional executables on your Web
server...

Cheers,
NC