Daelan
Daelan

Reputation: 723

Dynamically create a PDF with a background image

I'm trying to dynamically create a PDF (on the server) with some text on top of a pre-defined background image. I'm using PHP and I can't seem to find anyway to do this.

I've looked into http://www.fpdf.org/ and a bunch of other options.

I'm not opposed to using Flash either if it will do the trick.

Does anyone have any ideas on how to get this to work?

Upvotes: 5

Views: 48611

Answers (5)

arhakim
arhakim

Reputation: 174

You just need to re-order your code. Then your next content will automatically placed on the top of the image. example:

$fpdf = new FPDF();
$fpdf->AddPage();

// put the image in first order
$fpdf->Image('background-image.png', 0, 0, $fpdf->w, $fpdf->h);

$fpdf->cell(...);
...
...
$fpdf->Output();

Upvotes: 0

Tokk
Tokk

Reputation: 4502

You should take a look at this class, I really love it. It renders HTML to PDF, and if you define a Background-Image with CSS it will be in the created PDF.

Upvotes: 9

Sam
Sam

Reputation: 5526

With FPDF you can do it like this:

$fpdf = new FPDF();
$fpdf->AddPage();
$fpdf->Image('background-image.png', 0, 0, $fpdf->w, $fpdf->h);
$fpdf->Output();

Old question I know, but this might help someone.

Upvotes: 25

BrianS
BrianS

Reputation: 13914

Also, dompdf.

You were thinking too hard about what you wanted to do ;) ... always start with something you're familiar with (PHP, HTML) and see if there's something that will create the desired result (PDF). For a full list of converters you could try see the community wiki List of HTML to PDF converters (it covers more than just PHP-based libraries).

Upvotes: 0

wimvds
wimvds

Reputation: 12850

Another good alternative is TCPDF, it also supports (basic) HTML as output. Just look at the TCPDF Examples for a quick overview of what it can do (Example 51 might be helpful for you).

Upvotes: 2

Related Questions