Help language development. Donate to The Perl Foundation

FDF cpan:WARRINGD last updated on 2020-10-14

use v6;
use Test;
use FDF;
use FDF::Dict;

mkdir ('tmp');

lives-ok { "tmp/create-minimal.fdf" }, "create minimal";

my $fdf-doc =;
my FDF::Dict $fdf = $fdf-doc.Root.FDF;

$fdf.F = 't/fdf/create-simple.pdf';
my $fields = $fdf.Fields //= [];

$fields.push: { :T( :name<Greeting> ), :V<Hello> };

$ "tmp/create-simple.fdf";

lives-ok {$fdf-doc .= open: "tmp/create-simple.fdf"};
is +$fdf-doc.catalog.FDF.ID, 2, 'ID generated';

my $id0 = $fdf-doc.catalog.FDF.ID[0];
my $id1 = $fdf-doc.catalog.FDF.ID[1];

is $id0, $id1, 'created with two identical ID fields';
$fields = $fdf-doc.Root.FDF.Fields;
$fields.push: { :T( :name<Recipient> ), :V<World> };


is $fdf-doc.catalog.FDF.ID[0], $id0, 'first ID retained after updated';
isnt $fdf-doc.catalog.FDF.ID[1], $id1, 'second ID changed after update';