PDF-Create-1.08/ 000755 000765 000024 00000000000 12251772757 013530 5 ustar 00gabor staff 000000 000000 PDF-Create-1.08/CHANGES 000644 000765 000024 00000002304 12251772645 014516 0 ustar 00gabor staff 000000 000000
1.08 2013.12.11
Eliminate pipe from CGI test script t/09
Filehandle => FileHandle typo fixed #91312
1.07 2013.12.10
New maintainer SZABGAB
Tried to reconstruct entries in the CHANGES file
Some more test case
Code clean-up (remove indirect calls)
Remove Build.PL
use warnings;
Officially require perl 5.006.
Move example file to the eg/ directory
1.06 2010.07.06
1.05 2010.02.26
1.04 2009.07.13
1.03 200 2009.03.24
1.02 208.07.10
1.01 2008.06.03
1.00 2008.05.31
0.10 2008.05.31
0.09 2007.09.30
- Markus Baertschi, markus@markus.org
- Added stringml for multi-line strings
- Changed get_page_size to case-independent
0.08 2007.09.03
- Markus Baertschi, markus@markus.org
- Get back in sync with CPAN/PAUSE
- Fixed check for open file in Create.pm
- Touched up the README
0.07
- Markus Baertschi, markus@markus.org
- Added image samples to sample.pl
- Touched up the README
- Added check for open file in JPEG/GIFImages
0.06
- Fabien Tassin
- Added support for JPEG and GIF images
- Markus Baertschi, markus@markus.org
- Packaged for release on CPAN
0.01
- Fabien Tassin
- Original Release
PDF-Create-1.08/eg/ 000755 000765 000024 00000000000 12251772756 014122 5 ustar 00gabor staff 000000 000000 PDF-Create-1.08/lib/ 000755 000765 000024 00000000000 12251772756 014275 5 ustar 00gabor staff 000000 000000 PDF-Create-1.08/Makefile.PL 000644 000765 000024 00000001165 12251766376 015505 0 ustar 00gabor staff 000000 000000 #
# Makefile.PL for PDF::Create
#
use 5.006;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => "PDF::Create",
VERSION_FROM => "lib/PDF/Create.pm",
ABSTRACT_FROM => "lib/PDF/Create.pm",
'PREREQ_PM' => {
'Carp' => 0,
'FileHandle' => 0,
'Data::Dumper' => 0,
},
LICENSE => "perl",
dist => { COMPRESS => "gzip", SUFFIX => "gz" },
clean => { FILES => '*.bak *.old mibs/*.dump *.pdf' . 'lib/*/*~ lib/*/*/*~' },
META_MERGE => {
resources => {
repository => 'http://github.com/szabgab/pdf-create',
}
},
);
PDF-Create-1.08/MANIFEST 000644 000765 000024 00000001136 12251772757 014662 0 ustar 00gabor staff 000000 000000 CHANGES
eg/sample-cgi.pl
eg/sample.pl
lib/PDF/Create.pm
lib/PDF/Create/Outline.pm
lib/PDF/Create/Page.pm
lib/PDF/Image/GIF.pm
lib/PDF/Image/JPEG.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
pdf-logo.svg
README
t/01-basic.t
t/02-string.t
t/03-image.t
t/04-drawing.t
t/05-outline.t
t/06-annotation.t
t/07-fonts.t
t/09-cgi-script.pl
t/09-cgi.t
t/11-encode.t
t/50-versioning.t
t/99-wifi-parabola.t
t/pdf-logo.gif
t/pdf-logo.jpg
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
PDF-Create-1.08/MANIFEST.SKIP 000644 000765 000024 00000000215 12251676677 015430 0 ustar 00gabor staff 000000 000000 ^Makefile(\.old)?$
^MANIFEST\.bak$
^Maintenance-.*
.*~$
(^|/)TAGS$
.*\.tar\.gz$
blib/
pm_to_blib
\.pdf$
\.tmp$
^devel/
.git/
^\..*
^MYMETA.*
PDF-Create-1.08/META.json 000644 000765 000024 00000001761 12251772757 015156 0 ustar 00gabor staff 000000 000000 {
"abstract" : "create PDF files",
"author" : [
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132661",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "PDF-Create",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"Data::Dumper" : "0",
"FileHandle" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"repository" : {
"url" : "http://github.com/szabgab/pdf-create"
}
},
"version" : "1.08"
}
PDF-Create-1.08/META.yml 000644 000765 000024 00000001031 12251772757 014774 0 ustar 00gabor staff 000000 000000 ---
abstract: 'create PDF files'
author:
- unknown
build_requires:
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132661'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: PDF-Create
no_index:
directory:
- t
- inc
requires:
Carp: 0
Data::Dumper: 0
FileHandle: 0
resources:
repository: http://github.com/szabgab/pdf-create
version: 1.08
PDF-Create-1.08/pdf-logo.svg 000644 000765 000024 00000012203 12251673270 015744 0 ustar 00gabor staff 000000 000000
PDF-Create-1.08/README 000644 000765 000024 00000007613 12251673270 014405 0 ustar 00gabor staff 000000 000000 NAME
PDF::Create - create PDF files
DESCRIPTION
PDF::Create allows you to create PDF documents using a large
number of primitives, and emit the result as a PDF file or
stream. PDF stands for Portable Document Format.
Documents can have several pages, a table of content, an
information section and many other PDF elements. More
functionnalities will be added as needs arise.
Documents are constructed on the fly so the memory footprint is
not tied to the size of the pages but only to their number.
It's main advantage over the other PDF modules is that it does
not depend on other modules and is perl only (no compiler needed).
If you want a quick and dirty way of creating pdf's, PDF::Create
is for you. If you need a complete Framework to create complex
PDF stuff, you better dive into the PDF::API2 based modules.
More information about this module is included in this package.
SYNOPSIS
use PDF::Create;
my $pdf = new PDF::Create('filename' => 'mypdf.pdf',
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Fabien Tassin',
'Title' => 'My title',
);
my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
# Prepare 2 fonts
my $f1 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica');
my $f2 = $pdf->font('Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica-Bold');
# Prepare a Table of Content
my $toc = $pdf->new_outline('Title' => 'Document',
'Destination' => $page);
$toc->new_outline('Title' => 'Section 1');
my $s2 = $toc->new_outline('Title' => 'Section 2');
$s2->new_outline('Title' => 'Subsection 1');
$page->stringc($f2, 40, 306, 426, "PDF::Create");
$page->stringc($f1, 20, 306, 396, "version $PDF::Create::VERSION");
# Add another page
my $page2 = $root->new_page;
$page2->line(0, 0, 612, 792);
$page2->line(0, 792, 612, 0);
$toc->new_outline('Title' => 'Section 3');
$pdf->new_outline('Title' => 'Summary');
# Add something to the first page
$page->stringc($f1, 20, 306, 300,
'by Fabien Tassin ');
# Add the missing PDF objects and a the footer then close the file
$pdf->close;
INSTALLATION
Quick answer:
perl -MCPAN -e 'install PDF::Create'
Long answer:
To install manually, cd to the directory containing the unpacked
distribution and do one of the following:
a. Create a makefile by running Makefile.PL using the perl
program into whose library you want to install and then run
make three times:
perl Makefile.PL
make
make test
make install
b. To install into a private library, for example your home
directory:
perl Makefile.PL INSTALLSITELIB=$HOME/lib INSTALLMAN3DIR=$HOME/man
make
make test
make pure_install
AUTHORS
- Fabien Tassin
Original Author of PDF::Create
- Markus Baertschi, markus@markus.org
I have taken over maintenence of PDF::Create as Fabien has disappeared
and did no longer maintain it in the last years.
The last version of PDF::Create from Fabien is 0.06. All never versions
have been modified by me.
I maintain PDF::Create in git. You can access the repository directly
at http://github.com/markusb/pdf-create.
PDF-Create-1.08/t/ 000755 000765 000024 00000000000 12251772756 013772 5 ustar 00gabor staff 000000 000000 PDF-Create-1.08/t/01-basic.t 000755 000765 000024 00000004236 12251673270 015455 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing basic stuff
# - open / close
# - page root / new page
# - comment
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 11;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Testing Basic Stuff',
);
isa_ok( $pdf, 'PDF::Create' );
ok( $pdf->add_comment("Testing Basic Stuff"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
#ok( defined $root, "Create page root" );
isa_ok( $root, 'PDF::Create::Page' );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $page, "Page defined" );
# Page title and description
ok( $page->stringc( $f1, 40, 306, 700, 'PDF::Create' ), "stringc" );
ok( $page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" ), "stringc" );
ok( $page->stringc( $f1, 20, 306, 600, "Test: $0" ), "stringc" );
ok( $page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' ), "stringc" );
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/02-string.t 000755 000765 000024 00000006173 12251673270 015705 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing string functions
# - string l/r/c
# - string_underline
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 19;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Testing String Functions',
'Debug' => 0,
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("The is a PDF for testing"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Page title and description
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, "Test: $0" );
$page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' );
# Use the string functions
ok( $page->string( $f1, 15, 306, 380, 'Default string' ), "string" );
ok( $page->stringc( $f1, 15, 306, 360, 'Centered string (stringc)' ), "stringc" );
ok( $page->stringl( $f1, 15, 306, 340, 'Left aligned string (stringl)' ), "stringl" );
ok( $page->stringr( $f1, 15, 306, 320, 'Right aligned string (stringr)' ), "stringr" );
ok( $page->string( $f1, 15, 306, 280, 'Default string underlined' ), "string" );
ok( $page->string_underline( $f1, 15, 306, 280, 'Default string underlined' ), "string_underline" );
ok( $page->string( $f1, 15, 306, 260, 'Left string underlined', 'l' ), "string l" );
ok( $page->string_underline( $f1, 15, 306, 260, 'Left string underlined', 'l' ), "string_underline l" );
ok( $page->string( $f1, 15, 306, 240, 'Right string underlined', 'r' ), "string r" );
ok( $page->string_underline( $f1, 15, 306, 240, 'Right string underlined', 'r' ), "string_underline r" );
ok( $page->string( $f1, 15, 306, 220, 'Centered string underlined', 'c' ), "string c" );
ok( $page->string_underline( $f1, 15, 306, 220, 'Centered string underlined', 'c' ), "string_underline c" );
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/03-image.t 000755 000765 000024 00000005047 12251673270 015461 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing image-related functions
# - image
# - JPEG/GIF
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use File::Basename;
use Test::More tests => 9;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
my $gifname = dirname($0) . "/pdf-logo.gif";
my $jpgname = dirname($0) . "/pdf-logo.jpg";
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Testing Images (jpg, gif)',
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("The is a PDF for testing"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, "Test: $0" );
$page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' );
# Add a JPEG image
$page->string( $f1, 20, 200, 400, 'JPEG Image:' );
my $jpg1 = $pdf->image($jpgname);
ok( $page->image( 'image' => $jpg1, 'xscale' => 0.2, 'yscale' => 0.2, 'xpos' => 350, 'ypos' => 400 ), "jpg created" );
# Add a GIF image
$page->string( $f1, 20, 200, 200, 'GIF Image:' );
my $gif1 = $pdf->image($gifname);
ok( $page->image( 'image' => $gif1, 'xscale' => 0.2, 'yscale' => 0.2, 'xpos' => 350, 'ypos' => 200 ), "gif created" );
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/04-drawing.t 000755 000765 000024 00000006427 12251673270 016036 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing drawing-related functions
# - line, path, stroke
# - color
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 21;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Simple Test Document',
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("The is a PDF for testing"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 620, "Test: $0" );
$page->stringc( $f1, 20, 306, 590, 'Markus Baertschi (markus@markus.org)' );
# Draw some graphics
ok( $page->line( 100, 200, 100, 600 ), "line" );
$page->line( 100, 200, 500, 200 );
$page->line( 100, 600, 500, 600 );
$page->line( 500, 200, 500, 600 );
$page->line( 300, 200, 300, 600 );
$page->line( 100, 400, 500, 400 );
for ( my $x = 100 ; $x <= 500 ; $x = $x + 25 ) { $page->line( $x, 395, $x, 405 ); }
for ( my $y = 200 ; $y <= 600 ; $y = $y + 25 ) { $page->line( 295, $y, 305, $y ); }
#ok($page->newpath(),"newp0ath");
#ok($page->setrgbcolorstroke(1, 0.0, 0.0),"setrgbcolorstroke");
ok($page->setrgbcolor(0.1, 0.3, 0.8),"setrgbcolor");
ok($page->set_width(10),"setwidth");
ok($page->moveto(270,100),"moveto");
ok($page->lineto(300,160),"lineto");
ok($page->lineto(330,100),"lineto");
ok($page->lineto(270,100),"lineto");
#ok($page->closepath(),"closepath");
#ok($page->closestroke(),"stroke");
ok($page->fill(),"fill");
ok($page->stroke(),"stroke");
ok( $page->set_width(2), "set_width" );
my ( $x, $y, $x2, $y2 );
ok( $page->newpath, "newpath" );
ok( $page->setrgbcolorstroke( 0.1, 0.2, 1 ), "setrgbcolorstroke" );
ok( $page->moveto( 100, 400 ), "moveto" );
for ( $x = -3.14 ; $x <= 3.14 ; $x = $x + 0.03 ) {
$y = sin($x);
$y2 = 400 + int( $y * 2000 ) / 10;
$x2 = 300 + int( $x * 2000 / 3.14 ) / 10;
$page->lineto( $x2, $y2 );
}
ok( $page->stroke, "stroke" );
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/05-outline.t 000755 000765 000024 00000006055 12251673270 016060 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing TOC/Outline
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 13;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Simple Test Document',
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("The is a PDF for testing"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, "Test: $0" );
$page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' );
# Create a Outline/TOC
ok( my $out0 = $pdf->new_outline( 'Title' => 'Title page', 'Destination' => $page ), "new_outline" );
# Some more pages with outline
$page = $root->new_page;
$page->stringc( $f1, 40, 306, 700, 'Section 1' );
ok( my $out1 = $pdf->new_outline( 'Title' => 'Section 1', 'Destination' => $page ), "new_outline" );
$page = $root->new_page;
$page->stringc( $f1, 40, 306, 700, 'Section 2' );
ok( my $out2 = $pdf->new_outline( 'Title' => 'Section 2', 'Destination' => $page ), "new_outline" );
$page = $root->new_page;
$page->stringc( $f1, 40, 306, 700, 'Section 2.1' );
ok( my $out21 = $pdf->new_outline( 'Title' => 'Section 2.1', 'Destination' => $page, 'Parent' => $out2 ),
"new_outline with parent" );
$page = $root->new_page;
$page->stringc( $f1, 40, 306, 700, 'Section 2.2' );
ok( my $out22 = $pdf->new_outline( 'Title' => 'Section 2.2', 'Destination' => $page, 'Parent' => $out2 ),
"new_outline with parent" );
$page = $root->new_page;
$page->stringc( $f1, 40, 306, 700, 'Appendix' );
ok( my $app = $pdf->new_outline( 'Title' => 'Appendix', 'Destination' => $page ), "new_outline" );
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/06-annotation.t 000755 000765 000024 00000006062 12251673270 016552 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing annitations
# - Link
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 13;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Testing Basic Stuff',
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("Testing Basic Stuff"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, "Test: $0" );
$page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' );
my $uri = 'http://search.cpan.org/~markusb/PDF-Create/';
# Clickable URI with visible box around it
$page->string( $f1, 15, 150, 440, "Clickable Link" );
ok( $page->string( $f1, 15, 150, 400, "$uri" ), "string" );
ok( $page->string_underline( $f1, 15, 150, 400, "$uri" ), "string_underline" );
ok( $pdf->annotation( 'Subtype' => 'Link',
'x' => 145,
'y' => 395,
'w' => 321,
'h' => 25,
'URI' => 'http://search.cpan.org/~markusb/PDF-Create',
'Border' => [ 1, 1, 1 ]
),
"annotation"
);
# Clickable URI with invisible box around it
$page->stringc( $f1, 15, 306, 240, "Clickable Link Centered" );
ok( $page->string( $f1, 15, 306, 200, "$uri", 'c' ), "string" );
ok( my $len = $page->string_underline( $f1, 15, 306, 200, "$uri", 'c' ), "string_underline" );
ok( $pdf->annotation( 'Subtype' => 'Link',
'x' => 306 - ( $len / 2 ),
'y' => 200,
'w' => $len,
'h' => 15,
'URI' => 'http://search.cpan.org/~markusb/PDF-Create',
'Border' => [ 0, 0, 0 ]
),
"annotation"
);
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
PDF-Create-1.08/t/07-fonts.t 000755 000765 000024 00000006411 12251673270 015530 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Testing fonts
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 32;
# we want the resulting pdf file to have the same name as the test
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
###################################################################
#
# start testing
#
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Testing Basic Stuff',
);
ok( defined $pdf, "Create new PDF" );
ok( $pdf->add_comment("Testing Fonts"), "Add a comment" );
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
ok( defined $root, "Create page root" );
# Prepare font
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
ok( defined $f1, "Define Font" );
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
ok( defined $root, "Page root defined" );
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, "Test: $0" );
$page->stringc( $f1, 20, 306, 550, 'Markus Baertschi (markus@markus.org)' );
# Prepare fonts
my %font;
my $f_helv = define_font('Helvetica');
$font{'Courier'} = define_font('Courier');
$font{'Courier-Bold'} = define_font('Courier-Bold');
$font{'Courier-Oblique'} = define_font('Courier-Oblique');
$font{'Courier-BoldOblique'} = define_font('Courier-BoldOblique');
$font{'Helvetica'} = define_font('Helvetica');
$font{'Helvetica-Bold'} = define_font('Helvetica-Bold');
$font{'Helvetica-Oblique'} = define_font('Helvetica-Oblique');
$font{'Helvetica-BoldOblique'} = define_font('Helvetica-BoldOblique');
$font{'Times-Roman'} = define_font('Times-Roman');
$font{'Times-Bold'} = define_font('Times-Bold');
$font{'Times-Italic'} = define_font('Times-Italic');
$font{'Times-BoldItalic'} = define_font('Times-BoldItalic');
my $y = 500;
foreach my $f ( sort keys %font ) {
ok( $page->stringc( $font{$f}, 20, 300, $y, $f ), "Writing with font $f" );
$y -= 30;
}
# Wrap up the PDF and close the file
ok( !$pdf->close(), "Close PDF" );
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
#
# TODO: Add test with ghostscript
#
#echo | gs -q -sDEVICE=bbox 06-wifi-parabola-broken.pdf
exit;
sub define_font
{
my $fname = shift;
my $ftype = shift;
my $fencoding = shift;
if ( !defined $ftype ) { $ftype = 'Type1'; }
if ( !defined $fencoding ) { $fencoding = 'WinAnsiEncoding'; }
ok( my $f = $pdf->font( 'BaseFont' => $fname,
'Subtype' => $ftype,
'Encoding' => $fencoding
),
"Defining font $fname"
);
return $f;
}
PDF-Create-1.08/t/09-cgi-script.pl 000755 000765 000024 00000002625 12251673270 016620 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# sample cgi-script to produce a PDF on the fly
#
# Markus Baertschi, markus@markus.org
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use CGI;
#
# Write HTTP header with application/pdf as doc type
#
# If you want the PDF to open in an external application
# You should change this to
# -type => 'application/x-pdf', -attachment => $pdfname
#
print CGI::header( -type => 'application/pdf' );
#
# Start the pdf with '-' (stdout) as filename
#
my $pdf = PDF::Create->new( 'filename' => "-",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Simple Test Document',
);
# create the document root
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
# Prepare 2 fonts
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
# Write some text to the page
$page->stringc( $f1, 40, 306, 700, 'PDF::Create' );
$page->stringc( $f1, 20, 306, 650, "version $PDF::Create::VERSION" );
$page->stringc( $f1, 20, 306, 600, 'Simple Test Document' );
$page->stringc( $f1, 20, 300, 300, 'Fabien Tassin' );
$page->stringc( $f1, 20, 300, 250, 'Markus Baertschi (markus@markus.org)' );
# Wrap up the PDF and close the file
$pdf->close;
PDF-Create-1.08/t/09-cgi.t 000755 000765 000024 00000001601 12251701537 015135 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# 09-cgi.t
#
# cgi test script
#
# run the cgi-test and check the resulting output
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use File::Basename qw(dirname);
use File::Spec;
use PDF::Create;
use Test::More tests => 2;
use Config;
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
my $cginame = File::Spec->catfile(dirname($0) . "/09-cgi-script.pl");
#
# run the cgi
#
my @out = `$Config{"perlpath"} $cginame`;
shift @out;
shift @out;
#diag $out;
diag $pdfname;
if (open my $fh, '>', $pdfname) {
print $fh @out;
close $fh;
}
ok scalar(@out), "CGI executes";
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
PDF-Create-1.08/t/11-encode.t 000644 000765 000024 00000006452 12251673270 015631 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
use strict;
use PDF::Create;
use Test::More;
# The cases array contains test-cases
# In each triple the first value is the expected return value
# of the encode() method.
# The second and third values are the two parameters
# of the encode() method.
# The third parameter is optional but it can also be a complex
# data structure.
# expected, type, value
my @cases = (
[undef, 'null'],
['anything', 'null', 'anything'], # any value
[undef, 'number'],
['value', 'number', 'value'], # any value
["\n", 'cr'],
["\n", 'cr', 'abc'], # TODO: probably should complain that a 2nd, unnecesssary param was given
['true', 'boolean', 'true'],
['false', 'boolean', 'false'],
['false', 'boolean', '0'],
['true', 'boolean', '42'], # any other value as the 3rd item
# ['true', 'boolean', undef], # TODO: give error or eliminate warnings
['any string', 'verbatim', 'any string'], # anything
['x', 'verbatim', 'x'], # anything
# [undef, 'verbatim', undef], # TODO should give error, now fails with unknown type as the do{} fails
# [0, 'verbatim', 0], # TODO should work?, now fails with unknown type as the do{} fails
['(any string)', 'string', 'any string'], # anything
['(x)', 'string', 'x'], # anything
['()', 'string', undef], # TODO what should happen? eliminate warnings
['(0)', 'string', 0],
# TODO: shouldn't this check if the given value was indeed a number?
['any string', 'number', 'any string'], # anything
['x', 'number', 'x'], # anything
[undef, 'number', undef], # TODO eliminate warnngs
[0, 'number', 0],
['/any string', 'name', 'any string'], # anything
['/x', 'name', 'x'], # anything
['/', 'name', undef], # TODO ???, eliminate warnings
['/0', 'name', 0],
['[/anything]', 'array', [
['name', 'anything'],
]
],
['[/42 abc]', 'array', [
['name', 42],
['verbatim', 'abc'],
]
],
# TODO more complex test cases for dictionary
["<<\n/42 /text\n/abc (qwe)\n>>", 'dictionary', {
42 => ['name', 'text'],
abc => ['string', 'qwe'],
}
],
# TODO more complex test cases for object
["abc 43 obj\n/qwe\nendobj", 'object', [
'abc', 43, ['name', 'qwe']
]
],
["abc 45 R", 'ref', ['abc', 45]],
["<<\n/abc 46\n/23 /qwe\n>>\nstream\nsome data\nendstream\n",
'stream', {
Data => 'some data',
abc => ['number', 46],
23 => ['name', 'qwe'],
}
],
);
plan tests => 2 + @cases;
{
my @warn;
local $SIG{__WARN__} = sub { push @warn, @_ };
PDF::Create::encode();
# TODO eliminat warning from code caused by undef in $type
like $warn[1], qr/PDF::Create::encode: empty argument, called by/, 'no params';
};
eval {
PDF::Create::encode('something');
};
like $@, qr{Error: unknown type 'something'}, 'exception';
my %too_random = map { $_ => 1 } qw(dictionary stream);
foreach my $c (@cases) {
my ($expected, $type, $value) = @$c;
SKIP: {
if ($too_random{$type}) {
if (defined $ENV{PERL_PERTURB_KEYS} and $ENV{PERL_PERTURB_KEYS} == 2
and defined $ENV{PERL_HASH_SEED} and $ENV{PERL_HASH_SEED} == 1) {
} else {
skip 'PERL_PERTURB_KEYS=2 and PERL_HASH_SEED=1 has to be in order to have predictable Hashes', 1;
}
}
my $name = $type . (defined $value ? ",$value" : '');
is PDF::Create::encode($type, $value), $expected, $name;
}
}
PDF-Create-1.08/t/50-versioning.t 000644 000765 000024 00000001554 12251673270 016560 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# Check module versions against PDF::Create version
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 5;
my $version = $PDF::Create::VERSION;
ok($version eq $PDF::Create::VERSION,"PDF::Create version is $PDF::Create::VERSION");
ok($version eq $PDF::Create::Page::VERSION,"PDF::Create::Page version is $PDF::Create::Page::VERSION");
ok($version eq $PDF::Create::Outline::VERSION,"PDF::Create::Outline version is $PDF::Create::Outline::VERSION");
ok($version eq $PDF::Image::GIF::VERSION,"PDF::Image::GIF version is $PDF::Image::GIF::VERSION");
ok($version eq $PDF::Image::JPEG::VERSION,"PDF::Image::JPEG version is $PDF::Image::JPEG::VERSION");
PDF-Create-1.08/t/99-wifi-parabola.t 000755 000765 000024 00000011560 12251673270 017130 0 ustar 00gabor staff 000000 000000 #!/usr/bin/perl -w
#
# PDF::Create - Test Script
#
# Copyright 2010- Markus Baertschi
#
# Please see the CHANGES and Changes file for the detailed change log
#
# As example we draw a parabola which can be used to focus wifi signals
#
# This has not much to do with testing, but I like it, so it remains :-).
#
BEGIN { unshift @INC, "lib", "../lib" }
use strict;
use PDF::Create;
use Test::More tests => 1;
my $pdfname = $0;
$pdfname =~ s/\.t/\.pdf/;
my $pdf = PDF::Create->new( 'filename' => "$pdfname",
'Version' => 1.2,
'PageMode' => 'UseOutlines',
'Author' => 'Markus Baertschi',
'Title' => 'Parabolic WiFi Antenna'
);
my $root = $pdf->new_page( 'MediaBox' => $pdf->get_page_size('A4') );
# Prepare 2 fonts
my $f1 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica'
);
my $f2 = $pdf->font( 'Subtype' => 'Type1',
'Encoding' => 'WinAnsiEncoding',
'BaseFont' => 'Helvetica-Bold'
);
# Add a page which inherits its attributes from $root
my $page = $root->new_page;
# Write the title
$page->stringc( $f2, 25, 300, 770, 'Parabolic WiFi Reflector Template' );
$page->stringc( $f1, 12, 300, 740, 'Markus Baertschi (markus@markus.org)' );
# General parameters
my $dy = 310; # y offset from page origin
my $ay = 280; # y amplitude
my $dx = 100; # x offset from page origin
my $p = 100; # distance from back to focal point
$page->stringl( $f2, 10, 100, 710, 'Introduction' );
$page->stringl( $f1, 10, 100, 700,
'This template allows you to build a simple, but effective WiFi range extender. The reflector described' );
$page->stringl( $f1, 10, 100, 690,
'here will concentrate the signal of your access point in one direction. THe range in this direction will' );
$page->stringl( $f1, 10, 100, 680, 'be much better at the expense of the range in all other directions.' );
# Write instructions
$page->stringl( $f2, 10, 100, 660, 'Instructions:' );
$page->stringl( $f1, 10, 100, 650, '- Make square or rectangular reflector from metallic material (Tin foil, etc)' );
$page->stringl( $f1, 10, 100, 640, '- Bend reflector to parabolic shape' );
$page->stringl( $f1, 10, 100, 630, '- Fix reflector with the antenna at the focal point' );
# Write the labels
$page->stringl( $f1, 12, $dx + $p + 10, 460, 'Parabola (The reflector must be shaped like this)' );
$page->stringl( $f1, 10, $dx + $p + 30, $ay - 10, 'Focal Point (Antenna goes here)' );
# Draw the focal point
my $l = 30; # Length of cross
$page->line( $dx + $p - $l, $dy, $dx + $p + $l, $dy );
$page->line( $dx + $p, $dy - $l, $dx + $p, $dy + $l );
$page->newpath;
$page->set_width(0.5);
$page->setrgbcolorstroke( 0, 0, 0 );
$page->moveto( $dx + $p - $l / 2, $dy );
$page->curveto( $dx + $p - $l / 2, $dy + $l / 2 * 0.55, $dx + $p - $l / 2 * 0.55, $dy + $l / 2, $dx + $p, $dy + $l / 2 );
$page->curveto( $dx + $p + $l / 2 * 0.55, $dy + $l / 2, $dx + $p + $l / 2, $dy + $l / 2 * 0.55, $dx + $p + $l / 2, $dy );
$page->curveto( $dx + $p + $l / 2, $dy - $l / 2 * 0.55, $dx + $p + $l / 2 * 0.55, $dy - $l / 2, $dx + $p, $dy - $l / 2 );
$page->curveto( $dx + $p - $l / 2 * 0.55, $dy - $l / 2, $dx + $p - $l / 2, $dy - $l / 2 * 0.55, $dx + $p - $l / 2, $dy );
$page->stroke;
$ay = 50; # y amplitude
$dy = 100; # y offset from page origin
$dx = 300; # x offset from page origin
$p = 10; # distance from back to focal point
$page->newpath;
$page->set_width(2);
$page->setrgbcolorstroke( 0.1, 0.2, 1 );
$page->moveto( $ay * $ay / ( 4 * $p ), -$ay );
for ( my $y = -$ay ; $y <= $ay ; $y = $y + 2 ) {
my $x = $y * $y / ( 4 * $p );
$page->lineto( $x + $dx, $y + $dy );
}
$page->stroke;
my $i = 0;
$page->newpath;
$page->set_width(1);
$page->setrgbcolorstroke( 0.1, 0.2, 1 );
$page->moveto( $ay * $ay / ( 4 * $p ), -$ay );
for ( my $y = -$ay ; $y <= $ay ; $y = $y + 2 ) {
my $x = $y * $y / ( 4 * $p );
$page->lineto( $x + $dx + $i, $y + $dy );
$i++;
$i++;
}
$page->stroke;
$page->newpath;
$i = 0;
$page->moveto( $ay * $ay / ( 4 * $p ), -$ay );
for ( my $y = -$ay ; $y <= $ay ; $y = $y + 2 ) {
my $x = $y * $y / ( 4 * $p );
$page->lineto( $x + $dx + $i, $y + $dy + $ay * 2 );
$i++;
$i++;
}
$page->stroke;
$page->line( $dx + $ay + 12, $dy - $ay, $dx + $ay + 12, $dy + $ay );
$page->line( $dx + $ay - 10, $dy - $ay + 30, $dx + $ay - 10, $dy + $ay + 30 );
$page->line( $dx + $ay * 3 + 12, $dy + $ay, $dx + $ay * 3 + 12, $dy + $ay * 3 );
$page->set_width(3);
$page->line( $dx + $ay * 2, $dy, $dx + $ay * 2, $dy + $ay * 2 );
# Wrap up the PDF and close the file
$pdf->close;
################################################################
#
# Check the resulting pdf for errors with pdftotext
#
SKIP: {
skip '/usr/bin/pdftotext not installed', 1 if (! -x '/usr/bin/pdftotext');
my $out = `/usr/bin/pdftotext $pdfname /dev/null 2>&1`;
ok( $out eq "", "pdftotext $out");
}
PDF-Create-1.08/t/pdf-logo.gif 000755 000765 000024 00000060620 12251673270 016166 0 ustar 00gabor staff 000000 000000 GIF89a,qçÿ
!"$"')&*,),-+-/,342796=>