[PROJECT] PDF Covers generator PHP script

Suggestions and comments about the ReactOS website

Moderator: Moderator Team

Post Reply
forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

[PROJECT] PDF Covers generator PHP script

Post 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 !
Last edited by forart on Sun May 24, 2009 9:26 am, edited 1 time in total.
»Forward Agency NPO
In progress we (always) trust.

gyROS
Posts: 197
Joined: Sun Nov 09, 2008 8:10 pm
Location: Deutschland

Re: [IDEA] Dynamic covers generator script

Post 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.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post 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.
»Forward Agency NPO
In progress we (always) trust.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post 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:
»Forward Agency NPO
In progress we (always) trust.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post by forart »

UPDATE: some other webhunts results...

I'll update the online test script soon...
»Forward Agency NPO
In progress we (always) trust.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post 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 ?
»Forward Agency NPO
In progress we (always) trust.

Yazou
Posts: 31
Joined: Sat Dec 20, 2008 2:36 am
Location: France

Re: [IDEA] Dynamic covers generator script

Post 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.
[ external image ]
[ external image ]
Sorry for my bad English.
My ReactOS stuff on MediaFire | Photobucket

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post 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.
»Forward Agency NPO
In progress we (always) trust.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post 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.
»Forward Agency NPO
In progress we (always) trust.

forart
Posts: 1050
Joined: Mon Nov 29, 2004 1:36 pm
Location: Italy
Contact:

Re: [IDEA] Dynamic covers generator script

Post by forart »

»Forward Agency NPO
In progress we (always) trust.

vicmarcal
Test Team
Posts: 2732
Joined: Mon Jul 07, 2008 12:35 pm

Re: [PROJECT] PDF Covers generator PHP script

Post 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. ;)

SuperDog
Translation Team
Posts: 124
Joined: Tue Mar 04, 2008 2:52 am

Re: [PROJECT] PDF Covers generator PHP script

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests