|
Posted by kielhd on February 18, 2005, 2:51 am
Please log in for more thread options
Hi NG,
I have problems using the above module.
After creating the first page ok with text and drawing.
I have Problems to put some text on the second page. I is ok to put
some lines on the secand page, but the text appears still on the first
page.
Any ideas?
Regards,
Henning
#!C:Perlbinperl.exe
use MP3::Info qw(:all);
use PDF::Create;
use File::Find;
use bytes;
use Win32API::File 0.08 qw( :ALL );
get_parameter();
#
# Ermitteln des CD-Laufwerks ( $uDriveType = 5 )
#
get_cdlw();
#
# Ermitteln des CD-Labels
#
get_cd_label();
$filename = $volume . ".pdf";
my $pdf = new PDF::Create('filename' => $filename,
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Henning Deschka',
'Title' => 'Inhaltsverzeichniss von
MP3-CDs',
'Subject' => 'Auflistung der Titel auf
einer MP3-CD',
);
my $root = $pdf->new_page('MediaBox' => [ 0, 0, 792, 612 ]);
###############################################################################
# Prepare 1st page
###############################################################################
my $page = $root->new_page;
my $toc = $pdf->new_outline('Title' => "Inhalt von >> $volume <<",
'Destination' => $page);
# Variablen für das Cover
$breite = 372 * 2;
$hoehe = 600;
COVER();
###############################################################################
# Prepare 2nd page
###############################################################################
my $page2 = $root->new_page;
my $toc2 = $pdf->new_outline('Title' => "Rückseitiges Cover von >>
$volume <<",
'Destination' => $page2);
# Variablen für das Cover
$breite2 = 450;
$hoehe2 = 351;
COVER2();
###############################################################################
# Prepare 2 fonts
my $f1 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica');
my $f2 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica-Bold');
###############################################################################
$DUMMY=""; #
$NR_CD=0; # Nr. auf der CD
$NR_ARTIST=1; # Nr. der jeweiligen CD
init_time();
#
# Variablen für PDF-Erstellung
#
$SIZE = 6;
$COL = 10;
$LINEMAX = 57;
$LINE = 0;
$SIZE2 = 12;
$COL2 = 30;
$LINEMAX2 = 57;
$LINE2 = 30;
#
# Lesen der Dateien und füllen eines Arrays
#
find(&wanted, $dir);
chomp(@dateien);
#
# Ausgabe der formatierten ID3-Tag-Informationen
#
foreach (@dateien)
{
add_time(); # Zeit jedes Albums ermitteln
$NR_CD +=1;
$NR_ARTIST +=1;
$info = get_mp3info($_);
$time = $info->;
$tag = get_mp3tag($_);
$title = $tag->;
$artist = "$tag->" if ( exists $tag-> );
$album = "$tag->" if ( exists $tag-> );
$dummy=chop($title); # Irgendwie wird
$title = substr($title,0,38); # das letzte
$title .= $dummy; # Zeichen benötigt
#
# Zusammenstellen der richtigen Überschrift
#
if ( $artist ne "" && $album ne "" )
{
$HEADER=$artist." - ".$album;
}
if ( $artist ne "" && $album eq "" )
{
$HEADER=$artist;
}
if ( $artist eq "" && $album ne "" )
{
$HEADER=$album;
}
if ( $artist eq "" && $album eq "" )
{
$album = "Diverses";
$HEADER=$album;
}
#
# Prüfen, ob eine neue CD eingelesen wird
# Ausgabe der neuen Überschrift
#
if ( ($DUMMY ne $HEADER) && ($COL == 10) )
{
print_time() if ( $NR_CD != 1 );
$LINE += 2;
print_header();
$NR_ARTIST=1;
print_back();
}
if ( $LINE >= $LINEMAX && $COL == 10 )
{
get_line();
$COL = 10 + $breite / 4 * 1;
print_header();
}
if ( ($DUMMY ne $HEADER) && ($COL == 10 + $breite / 4 * 1) )
{
print_time() if ( $NR_CD != 1 );
$LINE += 2;
print_header();
$NR_ARTIST=1;
}
if ( $LINE >= $LINEMAX && $COL == 10 + $breite / 4 * 1 )
{
get_line();
$COL = 10 + $breite / 4 * 2;
print_header();
}
if ( ($DUMMY ne $HEADER) && ($COL == 10 + $breite / 4 * 2) )
{
print_time() if ( $NR_CD != 1 );
$LINE += 2;
print_header();
$NR_ARTIST=1;
}
if ( $LINE >= $LINEMAX && $COL == 10 + $breite / 4 * 2 )
{
get_line();
$COL = 10 + $breite / 4 * 3;
print_header();
}
if ( ($DUMMY ne $HEADER) && ($COL == 10 + $breite / 4 * 3) )
{
print_time() if ( $NR_CD != 1 );
$LINE += 2;
print_header();
$NR_ARTIST=1;
}
if ( $LINE >= $LINEMAX && $COL == 10 + $breite / 4 * 3 )
{
$LINE += 5;
$LINEMAX = 96;
$COL = 10;
print_header();
}
$OUT_1 = sprintf "%03d.t%03d.t%s", $NR_CD, $NR_ARTIST, $title;
$OUT_2 = sprintf "%-5sn", $time;
#printf("%-60s%s", $OUT_1, $OUT_2);
#printf SCHREIBEN ("%-60s%s", $OUT_1, $OUT_2);
$LINE += 1;
$page->string($f1, $SIZE, $COL, 612 - 10 - $LINE * $SIZE, $OUT_1);
$page->string($f1, $SIZE, $COL + 150, 612 - 10 - $LINE * $SIZE,
$OUT_2);
}
add_time();
print_time() if ( $NR_CD != 1 );
$pdf->close;
#close(SCHREIBEN);
exit 0;
###############################################################################
# CD-Cover Zeichnen
###############################################################################
sub COVER
{
# Rahmen
$x1 = 0;
$y1 = 612 - 0;
$x2 = 0 + $breite;
$y2 = 612 - 0;
$page->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite;
$y1 = 612 - 0;
$x2 = 0 + $breite;
$y2 = 612 - 0 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite;
$y1 = 612 - 0 - $hoehe;
$x2 = 0;
$y2 = 612 - 0 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
$x1 = 0;
$y1 = 612 - 0 - $hoehe;
$x2 = 0;
$y2 = 612 - 0 ;
$page->line($x1, $y1, $x2, $y2);
$hoehe = 370;
$x1 = 0 + $breite;
$y1 = 612 - 0 - $hoehe;
$x2 = 0;
$y2 = 612 - 0 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
$hoehe = 600;
# senkrechte Striche
$x1 = 0 + $breite / 4 * 1;
$y1 = 612;
$x2 = 0 + $breite / 4 * 1;
$y2 = 612 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite / 4 * 2;
$y1 = 612;
$x2 = 0 + $breite / 4 * 2;
$y2 = 612 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite / 4 * 3;
$y1 = 612;
$x2 = 0 + $breite / 4 * 3;
$y2 = 612 - $hoehe;
$page->line($x1, $y1, $x2, $y2);
}
sub COVER2
{
# Rahmen
$x1 = 0;
$y1 = 612 - 0;
$x2 = 0 + $breite2;
$y2 = 612 - 0;
$page2->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite2;
$y1 = 612 - 0;
$x2 = 0 + $breite2;
$y2 = 612 - 0 - $hoehe2;
$page2->line($x1, $y1, $x2, $y2);
$x1 = 0 + $breite2;
$y1 = 612 - 0 - $hoehe2;
$x2 = 0;
$y2 = 612 - 0 - $hoehe2;
$page2->line($x1, $y1, $x2, $y2);
$x1 = 0;
$y1 = 612 - 0 - $hoehe2;
$x2 = 0;
$y2 = 612 - 0;
$page2->line($x1, $y1, $x2, $y2);
# senkrechte Striche
$x1 = 18;
$y1 = 612;
$x2 = 18;
$y2 = 612 - $hoehe2;
$page2->line($x1, $y1, $x2, $y2);
$x1 = $breite2 - 18;
$y1 = 612;
$x2 = $breite2 - 18;
$y2 = 612 - $hoehe2;
$page2->line($x1, $y1, $x2, $y2);
}
# CD-Lesen
sub wanted
{
if ( $_ =~ /.mp3$/ )
{
$File::Find::name =~ s///\/g;
$File::Find::name =~ s/://:/;
push (@dateien, $File::Find::name);
}
}
sub get_line
{
if ( $LINEMAX == 57 )
{
$LINE = 2;
}
else
{
$LINE = 63;
}
}
sub add_time
{
my ($min, $sec)=0;
($min, $sec) = split(/:/,$time);
$ALBUM_MIN_GESAMT += $min;
$ALBUM_SEC_GESAMT += $sec;
if ( $ALBUM_SEC_GESAMT >= 60 )
{
$ALBUM_SEC_GESAMT -= 60;
$ALBUM_MIN_GESAMT += 1;
}
if ( $ALBUM_MIN_GESAMT >= 60 )
{
$ALBUM_MIN_GESAMT -= 60;
$ALBUM_HR_GESAMT += 1;
}
#print SCHREIBEN
"n$time $ALBUM_HR_GESAMT:$ALBUM_MIN_GESAMT:$ALBUM_SEC_GESAMTn";
}
sub format_time
{
### Stunden ###
if ( $ALBUM_HR_GESAMT == 0 )
{
$ALBUM_GESAMT .= " ";
}
if ( $ALBUM_HR_GESAMT > 0 && $ALBUM_HR_GESAMT < 10)
{
$ALBUM_GESAMT .= "0" . $ALBUM_HR_GESAMT . ":";
}
if ( $ALBUM_HR_GESAMT > 10)
{
$ALBUM_GESAMT .= $ALBUM_HR_GESAMT . ":";
}
### Minuten ###
if ( $ALBUM_MIN_GESAMT == 0 )
{
$ALBUM_GESAMT .= "00:";
}
if ( $ALBUM_MIN_GESAMT > 0 && $ALBUM_MIN_GESAMT < 10)
{
$ALBUM_GESAMT .= "0" . $ALBUM_MIN_GESAMT . ":";
}
if ( $ALBUM_MIN_GESAMT > 10)
{
$ALBUM_GESAMT .= $ALBUM_MIN_GESAMT . ":";
}
### Sekunden ###
if ( $ALBUM_SEC_GESAMT == 0 )
{
$ALBUM_GESAMT .= "00";
}
if ( $ALBUM_SEC_GESAMT > 0 && $ALBUM_SEC_GESAMT < 10)
{
$ALBUM_GESAMT .= "0" . $ALBUM_SEC_GESAMT;
}
if ( $ALBUM_SEC_GESAMT > 10)
{
$ALBUM_GESAMT .= $ALBUM_SEC_GESAMT;
}
#print "$ALBUM_GESAMTn";
}
sub init_time # Spielzeit des Albums
{
$ALBUM_HR_GESAMT=0;
$ALBUM_MIN_GESAMT=0;
$ALBUM_SEC_GESAMT=0;
$ALBUM_GESAMT="";
}
sub print_time
{
format_time();
$LINE += 1;
$OUT_2 = sprintf "%8sn", $ALBUM_GESAMT;
$page->string($f2, $SIZE, $COL + 141, 612 - 10 - $LINE * $SIZE,
$OUT_2);
# $LINE += 2;
init_time();
}
sub print_header
{
$OUT = sprintf "%sn", $HEADER;
$page->string($f2, $SIZE, $COL, 612 - 10 - $LINE * $SIZE, $OUT);
$DUMMY=$HEADER;
}
sub get_parameter ### Aufrufparameter auslesen
{
if ( $ARGV[0] eq "-h" )
{
printf "
Dieses Programm erstellt ein Inhaltsverzeichniss für CD's
mit Dateien im MP3-Format.
Die ID3-Tags werden ausgelesen und daraus eine PDF-Datei generiert,
die als Cover für eine CD genutzt werden kann.
";
exit;
}
$dir = $ARGV[0];
$dir =~ tr/a-z/A-Z/;
#print "$dirn";
}
sub get_cdlw
{
@roots= getLogicalDrives();
foreach $drive (@roots)
{
$uDriveType= GetDriveType( $drive );
#print "$drivet$uDriveTypen";
if ( $uDriveType == 5 )
{
$dir = $drive;
chop($dir);
#print "Das CD-ROM befindet sich auf Laufwerk $dirn";
break;
}
}
}
sub get_cd_label
{
open(CMD,"vol $dir |");
while (<CMD>)
{
if( /ists*(.*)/ )
{$volume= $1;}
}
close(CMD);
$dir .= "\";
#$volume="Test";
#print "Label von Laufwerk $dir -> $volumen";
}
sub print_back
{
$LINE2 += 1;
$page2->string($f2, $SIZE2, $COL2, 612 - 10 - $LINE2 * $SIZE2, $OUT);
}
|
| Similar Threads | Posted | | PDF::Create (or alike) to create watermark for existing pdf file? | June 11, 2006, 6:18 pm |
| Newbie created one module but can't create another | January 2, 2005, 10:22 pm |
| problem using swig to create perl module | October 6, 2005, 8:10 am |
| module to create Zork like game maps? | June 22, 2005, 9:29 pm |
| Announce: DbBrowser, a module to create mysqll/postgresql based paginated CGI datagrids | August 23, 2005, 2:25 pm |
| PDF::Create | February 28, 2005, 11:28 pm |
| How to create brand new XML file using XML::DOM | July 9, 2004, 3:00 pm |
| Gunzip module problems | November 6, 2006, 4:56 pm |
| GD::Graph - Can it create a stock chart | October 7, 2004, 10:42 am |
| Create Excel chart from spreadsheet on Un*x? | December 28, 2006, 11:28 pm |
|