| WebService-Trynt-PDF documentation | Contained in the WebService-Trynt-PDF distribution. |
WebService::Trynt::PDF::File - Interface to manage information about the file created with WebService::Trynt::PDF
Version 0.01
WebService::Trynt::PDF is an interface for Trynt Web Services, so you can convert an URL into a PDF file.
use WebService::Trynt::PDF;
my $trynt_ws = WebService::Trynt::PDF->new( url => "http://www.cnn.com", cache_flush => 0);
my $file = $trynt_ws->get();
$file->save_to("./cnn.pdf");
or shortly
my $trynt_ws = WebService::Trynt::PDF->new( url => "http://www.cnn.com");
$trynt_ws->get("./cnn.pdf");
Manu, <<manu at bjornoya.net>>
Please report any bugs or feature requests to
bug-webservice-trynt-pdf-file at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-Trynt-PDF.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc WebService::Trynt::PDF
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-Trynt-PDF
Copyright 2006 Manu, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WebService-Trynt-PDF documentation | Contained in the WebService-Trynt-PDF distribution. |
package WebService::Trynt::PDF::File;
our $VERSION = '0.01'; use warnings; use strict; use XML::Simple; use File::Temp; use File::Copy; use LWP::UserAgent;
sub new { my ( $class, $xml ) = @_; my $self = bless { _xml => $xml, _tmp_file => File::Temp->new( UNLINK => 0 ), }, $class; $self->_parse_xml(); $self->_get_file(); $self; }
sub save_to { my $self = shift; my $filename = shift; move( $self->{_tmp_file}->filename, $filename ); } sub _get_file { my ($self) = @_; my $ua = LWP::UserAgent->new(); $ua->agent("WebService::Trynt::PDF/$VERSION"); $ua->get( $self->{url}, ':content_file' => $self->{_tmp_file}->filename ); } sub _parse_xml { my ($self) = @_; my $xml = XMLin( $self->{_xml} ); $self->{md5} = $xml->{PDF}->{MD5}; $self->{url} = $xml->{PDF}->{PDF}; }
1; # End of WebService::Trynt::PDF::File