| 1 | package HTML::HTMLDoc::PDF; | ||
| 2 | |||
| 3 | use 5.006; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use IO::File; | ||
| 7 | use vars qw(@ISA $VERSION); | ||
| 8 | |||
| 9 | @ISA = qw(); | ||
| 10 | $VERSION = '0.20'; | ||
| 11 | |||
| 12 | ############### | ||
| 13 | # create a new Object | ||
| 14 | # param: | ||
| 15 | # return: object:HTML::HTMLDOC | ||
| 16 | ############### | ||
| 17 | sub new { | ||
| 18 | my $package = shift; | ||
| 19 | my $contentref = shift; | ||
| 20 | |||
| 21 | return undef if (ref($contentref) ne 'SCALAR'); | ||
| 22 | |||
| 23 | my $self = {}; | ||
| 24 | bless($self, $package); | ||
| 25 | |||
| 26 | $self->{'content'} = $contentref; | ||
| 27 | return $self; | ||
| 28 | } | ||
| 29 | |||
| 30 | ############### | ||
| 31 | # returns the content as string | ||
| 32 | # param: | ||
| 33 | # return: conent:STRING | ||
| 34 | ############### | ||
| 35 | sub to_string { | ||
| 36 | my $self = shift; | ||
| 37 | return ${$self->{'content'}}; | ||
| 38 | } | ||
| 39 | |||
| 40 | ############### | ||
| 41 | # writes the output to a file | ||
| 42 | # specified by filename | ||
| 43 | # param: filename|STRING | ||
| 44 | # return: | ||
| 45 | ############### | ||
| 46 | sub to_file { | ||
| 47 | my $self = shift; | ||
| 48 | my $filename = shift; | ||
| 49 | |||
| 50 | my $file = new IO::File($filename, "w"); | ||
| 51 | if (!$file) { | ||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | print $file ${$self->{'content'}}; | ||
| 55 | $file->close(); | ||
| 56 | return 1; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | __END__ |