in reply to PDF::Create Questions

In the PDF::Create constructor code, I find the following line:
my $fh = new FileHandle "> $self->{'filename'}";
It means that the file will be overwritten automatically, (provided you have write permission to the old file).

The pod for Create.pm contains a command to add a rectangle to the path. Then you can either stroke or fill that path. For example:

$page2->rectangle(0,0,40,60); $page2->stroke();
Update: improved rectangle example.

Replies are listed 'Best First'.
Re: Re: PDF::Create Questions
by peppiv (Curate) on Apr 08, 2003 at 14:32 UTC
    Thank for the help. The rectangle works like a charm. It's a shame you couldn't shade with the fill command. That would rock.

    In the FileHandle example (your code explains more than the docs) how do I declare $self? Would this line come after the Create line? Sorry for all the questions.

    peppiv

      You don't have to declare $self. I just clipped out a line from the PDF::Create "new" function to show you that it opens the file with a '>' in front of the name, which means that it will overwrite the old file automatically. There's no extra code you have to put in.
        I can't seem to get it right. I understand using the '>' to open a file to overwrite, but no matter how I try to make the syntax work, I fail.

        How do I get from here

        my $fh = new FileHandle "> $self->{'filename'}";
        to here?

        my $pdf = new PDF::Create ('filename' => '/html/mypdf.pdf', 'PageMode' => 'UseNone', );
        Even trying this
        my $pdf = new PDF::Create "> ('filename' => '/html/mypdf.pdf', 'PageMode' => 'UseNone', )";
        and giving the pdf file 777 permissions doesn't work. Please help!

        peppiv