#!/usr/bin/perl use Tk; use PDF::Create; use strict; use warnings; my $lab; my $address = "Enter file name"; my $window = MainWindow->new; $lab = $window->Label(-text => "Hello !")->pack; $window->Entry(-textvariable => \$address )->pack; $window->Button(-text => "Convert to pdf", -command => \&convert )->pack; $window->Button(-text => "Quit", -command => \&finito )->pack; MainLoop; sub convert { my $height = 842; my $width = 595; my $result = index($address, '.'); my $a = substr($address, 0, $result); $a = $a.'.pdf'; my $pdf = new PDF::Create('filename' => $a ); my $root = $pdf->new_page('MediaBox' => [ 0, 0, $width, $height ]); # Add a page which inherits its attributes from $root my $page = $root->new_page; # Prepare font my $f1 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica'); my $vert = $height -12; my $FilePath = "access.txt"; open(FILE, $address); while (my $line = ) { $page->string($f1, 10, 10,$vert, $line); $vert = $vert-12; if($vert<20){ $page = $root->new_page; $vert = $height -12; } } close FILE; $pdf->close; $lab -> configure(-text => "Congratulations $a has been created !"); $address = "Convert another one !" } sub finito{ exit; }