| WebService-Trynt-PDF documentation | Contained in the WebService-Trynt-PDF distribution. |
WebService::Trynt::PDF - Easy Interface for Trynt PDF Web Services
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");
Emmanuel Di Pretoro, <<manu at bjornoya.net>>
http://trynt.com/trynt-api-pdf/
Please report any bugs or feature requests to
bug-webservice-trynt-pdf 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 Emmanuel Di Pretoro, 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;
our $VERSION = '0.01';
use warnings; use strict; use LWP::UserAgent; use URI; use constant URL => "http://www.trynt.com/pdf-api/v1/"; use WebService::Trynt::PDF::File;
sub new { my ($class, %p) = @_; my $ua = LWP::UserAgent->new(); $ua->agent("WebService::Trynt::PDF/$VERSION"); bless { %p, ua => $ua }, $class; } sub _var { my $self = shift; my $key = shift; $self->{$key} = shift if @_; $self->{$key}; } sub _request { my ($self, %param) = @_; my $uri = URI->new(URL); $uri->query_form(%param); my $request = HTTP::Request->new(GET => $uri); return $self->{ua}->request($request); }
sub get { my $self = shift; if (exists $self->{url}) { my $res = $self->_request(u => $self->{url}, f => $self->{cache_flush}); $self->{output} = shift if @_; my $file = WebService::Trynt::PDF::File->new($res->content); $file->save_to($self->{output}); return $file; } else { require Carp; Carp::croak "You must specify an url to convert to PDF"; } }
sub url { shift->_var('url', @_) };
sub cache_flush { shift->_var('cache_flush', @_) };
sub output { shift->_var('output', @_) };
1; # End of WebService::Trynt::PDF