Page 1 of 1

[PROJECT] PDF Covers generator PHP script

Posted: Fri Mar 20, 2009 9:42 am
by forart
As already suggested here, due to multilanguage attitude and version changes, it would be usefull to have a "dynamic cover generator".

It would not be so difficoult to setup an FPDF-based PHP script to achieve this.
forart wrote:Quick test:

http://www.forart.it/cover.php?image=01.png&ver=0.38a

Try to type anything in place of "0.38a" and change "01.png" with "02.jpg" parameters...

Can you understand what i mean ?

Easy as:

Code: Select all

<?php
require('../classes/fpdf.php');

$pdf = new FPDF('L', 'pt', 'a4');
$pdf->AddPage();
$pdf->SetAuthor('CC by-nc-sa / Associazione Culturale >>Forward Agency');
$pdf->Image('../images/'.$image, 0, 0, $size[0], $size[1]);
$pdf->SetFont('Arial','B',16);
$pdf->SetTextColor(128);
$pdf->Cell(40,10,$ver);
$pdf->Output();
?>
Note that you can also easily get text from txt files, put images with alpha transparency, etc.

Check out tutorial and script examples.

Here's a good collection of PDF DVD templates and not only...
Note that this kind of script could help out other projects too.

Hope that helps or at least inspires !

Re: [IDEA] Dynamic covers generator script

Posted: Fri Mar 20, 2009 4:19 pm
by gyROS
Sounds like a good idea and worth the new thread.
You could then put all the translated text files in the same folder and pass the language id as a parameter.

One question: Is it possible to use svg elements?
If not, one would have to use a png template that includes everything but the text elements.

Re: [IDEA] Dynamic covers generator script

Posted: Mon Mar 23, 2009 11:55 am
by forart
Well, browsing the FPDF.de addon page, you can find an SVG template engine.
Dunno if can solve, btw you can always ask its author (Alan Knowles - alan _at_ akbkhome _dot_ com) an help.

Re: [IDEA] Dynamic covers generator script

Posted: Mon Apr 13, 2009 2:05 am
by forart
OK, after some googling here's some links about online cd covers generators:

1st of all, i found an interesting 2005 3ad @ Jinzora forums like this titled Creation of PDF cover art, where you can read this code:

Code: Select all

<?php
require('../fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Stevie Ray Vaughan Greatest Hits');
$pdf->SetFillColor(230,230,0);
$pdf->SetTextColor(220,50,50);
$pdf->SetLineWidth(1);
$pdf->Line(10,50,40,50);
$pdf->Line(40,20,40,50);
$pdf->Line(155,50,185,50);
$pdf->Line(155,20,155,50);
$pdf->Image('picture.jpg',45,55);
$pdf->Line(10,145,40,145);
$pdf->Line(40,145,40,175);
$pdf->Line(10,145,40,145);
$pdf->Line(155,145,185,145);
$pdf->Line(155,145,155,175);
$pdf->Output();
?>
Then here are other *very* interesting links (to involve authors): Simple paper CD cover

More to come... :wink:

Re: [IDEA] Dynamic covers generator script

Posted: Sat May 16, 2009 3:29 pm
by forart
UPDATE: some other webhunts results...

I'll update the online test script soon...

Re: [IDEA] Dynamic covers generator script

Posted: Sat May 16, 2009 4:20 pm
by forart
pochette de dvd is cool but very hard to mod.
It always returns me error when i try to change static values with variables.

Any1 ?

Re: [IDEA] Dynamic covers generator script

Posted: Sat May 16, 2009 4:49 pm
by Yazou
Show your code to see where is the problem.
Normally, it shouldn't have problem with the variables because the author used one ($texte). Just be sure that you didn't declare one that is already used in fpdf.php.

Re: [IDEA] Dynamic covers generator script

Posted: Sun May 17, 2009 1:01 am
by forart
I tried to change almost everything (image, text, title, etc.) - even separately - but it returns:

FPDF error: Some data has already been output, can't send PDF file

That script is not very well coded, IMHO.

BTW it could be useful as codebase for us.

Re: [IDEA] Dynamic covers generator script

Posted: Tue May 19, 2009 1:10 pm
by forart
OK, i finally re-coded it from scratch. The 1st goal was to place and draw the template+background dynamically:

Code: Select all

<?php
require('fpdf.php');

if ($copertina == "DVD") { $Lcover= 270; $Acover= 180; $Ldorso=15; } else { $Lcover= 250; $Acover= 125; $Ldorso=0;};

if ($pagina == "A4") { $Lpaper=297; $Apaper=210; } else { $Lpaper=279; $Apaper=216; };

$sx=($Lpaper-$Lcover)/2; $su=($Apaper-$Acover)/2;

$pdf = new FPDF('P','mm',array($Lpaper,$Apaper));

$pdf->SetMargins($sx,$su,$sx);

$pdf->SetAutoPageBreak(0);

$pdf->AddPage();
$pdf->SetAuthor('CC by-nc-sa / Associazione Culturale >>Forward Agency');
$pdf->image($sfondo, $sx, $su, $Lcover, $Acover);
$pdf->Rect($sx, $su, $Lcover, $Acover, "D");
$pdf->Rect((($Lcover-$Ldorso)/2)+$sx, $su, $Ldorso, $Acover, "D");
$pdf->Output();
?>
DEMOs:
- http://www.forart.it/cover.php?&pagina= ... pertina=CD (draws a CD template with picture.jpg background on Letter page)
- http://www.forart.it/cover.php?&pagina= ... ertina=DVD (draws a DVD template with test.jpg background on A4 page)

EDIT: added background support !

As you can see it supports only 2 templates (CD and DVD) on 2 types of papers (A4 and Letter)...

Suggestion, corrections, improvements and anything constructive are welcomed.

Re: [IDEA] Dynamic covers generator script

Posted: Sat May 23, 2009 1:09 pm
by forart

Re: [PROJECT] PDF Covers generator PHP script

Posted: Wed Nov 18, 2009 12:16 pm
by vicmarcal
nabritta wrote:How to convert a PDF Document to a Word Document? How can I convert a PDF Document that I received in my e-mail box to a Word Document. I failed to open this document from my e-mail box. When I tried to open it, I only got numericals/numbers and no letters or words. Please assist me if you know how to do it.
Totally OffTopic ;)
Use PDF2DOC app. ;)

Re: [PROJECT] PDF Covers generator PHP script

Posted: Tue Dec 22, 2009 12:42 pm
by SuperDog
Not worthwhile. Official releases are not done on a daily basis to require such automation. 5 minutes of work every few months is not a big deal.