1package PDF::Writer; 2 3use strict; 4use warnings; 5 6our $VERSION = '0.06'; 7 8our $Backend; 9 10sub import { 11 my $class = shift; 12 $Backend = shift if @_; 13 require "PDF/Writer/$Backend.pm" if $Backend && $Backend eq 'mock'; 14} 15 16sub new { 17 my $class = shift; 18 19 my $backend = $Backend || ( 20 eval { require PDF::API2; 1 } ? 'pdfapi2' : 21 eval { require pdflib_pl; 1 } ? 'pdflib' : undef 22 ); 23 24 if ($backend) { 25 require "PDF/Writer/$backend.pm"; 26 } 27 else { 28 die "No supported PDF backends found!"; 29 } 30 31 $class .= "::$backend"; 32 return $class->new(@_); 33} 34 351; 36__END__ 37 38=head1 NAME 39 40PDF::Writer - PDF writer abstraction layer 41 42=head1 VERSION 43 44This document describes version 0.05 of PDF::Writer, released Oct 25, 452005. 46 47=head1 SYNOPSIS 48 49 use PDF::Writer; 50 51 # Or, to explicitly specify a back-end ... 52 use PDF::Writer 'pdflib'; 53 use PDF::Writer 'pdfapi2'; 54 use PDF::Writer 'mock'; 55 56 my $writer = PDF::Writer->new; 57 58=head1 DESCRIPTION 59 60This is a generalized API that allows a module that generates PDFs to 61transparently target multiple backends without changing its code. The 62currently supported backends are: 63 64=over 4 65 66=item * PDF::API2 67 68Available from CPAN 69 70=item * PDFlib (versions 3+) 71 72Available from L<http;//www.pdflib.com>. There is both a pay and free version. 73PDF::Writer will work with both, within their limitations. Please see the 74appropriate documentation for details. 75 76=item * Mock 77 78This allows modules that target PDF::Writer to write their tests against a 79mock interface. Please see L<PDF::Writer::mock> for more information. 80 81=back 82 83If both PDF::API2 and pdflib_pl are available, PDF::API2 is preferred. If 84neither is available, a run-time exception will be thrown. You must explicitly 85load the PDF::Writer::mock driver, if you wish to use it. 86 87=head1 METHODS 88 89=over 4 90 91=item * B<new()> 92 93This acts as a factory, loading the appropriate PDF::Writer driver. 94 95=back 96 97=head1 CODE COVERAGE 98 99We use L<Devel::Cover> to test the code coverage of our tests. Below is the 100L<Devel::Cover> report on this module's test suite. 101 102=head1 AUTHORS 103 104Originally written by: 105 106Autrijus Tang E<lt>autrijus@autrijus.orgE<gt> 107 108Currently maintained by: 109 110Rob Kinyon E<lt>rob.kinyon@iinteractive.comE<gt> 111 112Stevan Little E<lt>stevan.little@iinteractive.comE<gt> 113 114Thanks to Infinity Interactive for generously donating our time. 115 116=head1 COPYRIGHT 117 118Copyright 2004, 2005 by Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>. 119 120This program is free software; you can redistribute it and/or modify it 121under the same terms as Perl itself. 122 123See L<http://www.perl.com/perl/misc/Artistic.html> 124 125=cut 126