Some years ago I coded a simple PHP to generate PDF - using FPDF lib - sheets (both A4 and Letter) to print. It supports both CD and DVD covers.
It grabs the image from the given URL, center in the sheet and writes version and changelog (with different fonts - as example - and from dynamic â$GET[âversâ]_changes.txtâ file, if available) on it.
Hereâs the code:
<?php
// CoverGen v.0.1.1
// CC By-Nc-Sa 2009 F.O.R.A.R.T. Foundation
require(âfpdf.phpâ);
$remoto = $_GET[âremotoâ];
$pagina = $_GET[âpaginaâ];
$copertina = $_GET[âcopertinaâ];
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; $disdo=($Lcover-$Ldorso)/2;
$formato = array($Lpaper,$Apaper);
$pdf = new FPDF(âLandscapeâ,âmmâ,$formato);
$pdf->SetMargins($sx,$su,$sx);
$pdf->SetAutoPageBreak(0);
if ( file_exists(str_replace(".", ââ, $_GET[âversâ])."_changes.txt") ) { $changes = file_get_contents(str_replace(".", ââ, $_GET[âversâ])."_changes.txt"); } else { $changes = âChangelog not availableâ; }
$pdf->AddPage();
$pdf->SetAuthor(âCC by-nc-sa 2009 F.O.R.A.R.T. Foundationâ);
$pdf->image($remoto, $sx, $su, $Lcover, $Acover);
$pdf->Line(0, $su, $Lpaper, $su);
$pdf->Line(0, $su+$Acover, $Lpaper, $su+$Acover);
$pdf->Line($sx, 0, $sx, $Apaper);
$pdf->Line($sx+$Lcover, 0, $sx+$Lcover, $Apaper);
$pdf->Line($disdo+$sx, 0, $disdo+$sx, $Apaper);
$pdf->Line(($disdo+$sx)+$Ldorso, 0, ($disdo+$sx)+$Ldorso, $Apaper);
$pdf->SetDrawColor(255,0,0);
$pdf->Rect($sx, $su, $Lcover, $Acover, âDâ);
$pdf->Rect($disdo+$sx, $su, $Ldorso, $Acover, âDâ);
$pdf->SetFont(âTimesâ,âIâ,11);
$pdf->SetTextColor(255,255,255);
$pdf->SetXY(30,75);
$pdf->MultiCell( 0, 5, $changes );
$pdf->SetFont(âArialâ,âBâ,20);
$pdf->SetTextColor(0,0,0);
$pdf->SetXY(-$sx+5,$su+5);
$pdf->Cell(0, 5, $_GET[âversâ], 0, 0, âRâ);
$pdf->Output();
?>
Hope that helps.
Marco