2008-04-29 12:55:25 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
require 5.008;
|
|
|
|
BEGIN { $^W = 1; }
|
|
|
|
use strict;
|
|
|
|
use File::Copy;
|
|
|
|
|
|
|
|
chdir("mod-info");
|
|
|
|
|
|
|
|
require TestDriver;
|
|
|
|
|
|
|
|
my $td = new TestDriver('pdf-mod-info');
|
|
|
|
|
|
|
|
my $prg = "pdf-mod-info";
|
|
|
|
my $qpdf = $ENV{'QPDF_BIN'} or die;
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
$td->runtest("usage #1",
|
|
|
|
{$td->COMMAND => "$prg -in target.pdf"},
|
|
|
|
{$td->FILE => "usage.out",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 2},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("usage #2",
|
|
|
|
{$td->COMMAND => "$prg -key abc -val def"},
|
|
|
|
{$td->FILE => "usage.out",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 2},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("usage #3",
|
|
|
|
{$td->COMMAND => "$prg -key abc -val def abc"},
|
|
|
|
{$td->FILE => "usage.out",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 2},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("usage #4",
|
2009-10-14 01:06:18 +00:00
|
|
|
{$td->COMMAND => "$prg -in source1.pdf -key date -val 01/01/01 -val 12/12/12"},
|
2008-04-29 12:55:25 +00:00
|
|
|
{$td->FILE => "usage.out",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 2},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("dump #1",
|
|
|
|
{$td->COMMAND => "$prg --dump -in files/source1.pdf"},
|
|
|
|
{$td->FILE => "dump.out",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 0},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("dump #2",
|
|
|
|
{$td->COMMAND => "$prg --dump -in files/no-info.pdf"},
|
|
|
|
{$td->STRING => "",
|
2009-07-15 04:26:32 +00:00
|
|
|
$td->EXIT_STATUS => 0},
|
|
|
|
$td->NORMALIZE_NEWLINES);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
$td->runtest("dump #3",
|
|
|
|
{$td->COMMAND => "$prg --dump -in files/empty-info.pdf"},
|
|
|
|
{$td->STRING => "",
|
|
|
|
$td->EXIT_STATUS => 0});
|
|
|
|
|
|
|
|
run_and_cmp("modify Subject",
|
2009-10-14 01:06:18 +00:00
|
|
|
"$prg -in files/source1.pdf -out out.pdf -key Subject " .
|
2008-04-29 12:55:25 +00:00
|
|
|
"-val \"Export Business\"",
|
|
|
|
"", "out.pdf", "files/1.qdf");
|
|
|
|
|
|
|
|
run_and_cmp("add Subject, remove Producer, modify CreationDate",
|
2009-10-14 01:06:18 +00:00
|
|
|
"$prg -in files/source2.pdf -out out.pdf -key Subject " .
|
|
|
|
"-val \"Tammlin\" -key Producer -key CreationDate -val 12/12",
|
2008-04-29 12:55:25 +00:00
|
|
|
"", "out.pdf", "files/2.qdf");
|
|
|
|
|
|
|
|
run_and_cmp("add Subject (empty-info file)",
|
2009-10-14 01:06:18 +00:00
|
|
|
"$prg -in files/empty-info.pdf -out out.pdf -key Subject " .
|
2008-04-29 12:55:25 +00:00
|
|
|
"-val Tammlin",
|
|
|
|
"", "out.pdf", "files/3.qdf");
|
|
|
|
|
|
|
|
copy("files/no-info.pdf", "no-info.pdf") or die "can't copy no-info: $!";
|
|
|
|
run_and_cmp("in-place Producer added (no-info file)",
|
2009-10-14 01:06:18 +00:00
|
|
|
"$prg -in no-info.pdf -key Producer -val \"Obivan Kinobi\"",
|
2008-04-29 12:55:25 +00:00
|
|
|
"", "no-info.pdf", "files/4.qdf");
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
$td->report(15);
|
|
|
|
|
|
|
|
sub cleanup
|
|
|
|
{
|
|
|
|
unlink (<*.pdf>);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub run_and_cmp
|
|
|
|
{
|
|
|
|
my ($dsc, $cmd, $out, $fout, $fexp) = @_;
|
|
|
|
$td->runtest($dsc,
|
|
|
|
{$td->COMMAND => "$cmd --static-id"},
|
|
|
|
{$td->STRING => $out,
|
|
|
|
$td->EXIT_STATUS => 0});
|
|
|
|
$td->runtest("$dsc output",
|
2009-03-09 16:57:37 +00:00
|
|
|
{$td->COMMAND => "$qpdf --static-id" .
|
|
|
|
" --no-original-object-ids -qdf $fout -"},
|
2008-04-29 12:55:25 +00:00
|
|
|
{$td->FILE => $fexp,
|
|
|
|
$td->EXIT_STATUS => 0});
|
|
|
|
}
|