package ImgCalMonth; use base main; use warnings; use strict; use Scaliger; sub init{ my $self = shift; $self->nocache; my $d = [localtime]; $self->{STASH}{year} = $d->[5] + 1900; $self->{STASH}{month} = $d->[4] + 1; } sub control{ my $self = shift; return if $ENV{REQUEST_METHOD} ne "POST"; $self->{STASH}{year} = $self->trim($self->param('year')); $self->{STASH}{month} = $self->trim($self->param('month')); my $sca = Scaliger->new( date => sprintf("1.%s.%s", $self->{STASH}{month}, $self->{STASH}{year}) ) or return $self->errmsg("$@"); my $img = $self->param('image') || $self->imgmap_month( $self->{STASH}{month} ); return $self->errmsg('Kein Bild ausgewählt!') if ! $img; # Prüfung jpeg, png return $self->errmsg('Grafikformat nicht unterstützt!') unless $img->{content_type} =~ /jpeg/i; #|| $img->{content_type} eq 'image/png'; # liefert Pfad zur TTF-Datei my $ttf = $self->font( $self->param('ttf') ); $self->{CONTENT} = $self->pdfmonth( month => $self->{STASH}{month}, year => $self->{STASH}{year}, imgtype => 'jpeg', imgfile => $img->{iohandle}, string => 1, ttf => $ttf ) || die "$@\n"; if($self->param('down')){ $self->header( 'Content-Length' => length($self->{CONTENT}), 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'Attachment;filename=sheet.pdf' ); } else{ $self->header( 'Content-Length' => length($self->{CONTENT}), 'Content-Type' => 'application/pdf' ); } } 1;