Giter Site home page Giter Site logo

fdf-raku's Introduction

[Raku PDF Project] / [FDF Module]

FDF-raku

A Raku module for the creation and manipulation of FDF (Form Data Format) files, including PDF export and import.

Classes/Roles in this Distribution

Synopsis

Export fields from a PDF to an FDF

use PDF::Class;
use FDF;
my PDF::Class $from .= open: "MyDoc.pdf";
my FDF $fdf .= new;

# fill the email field, overriding PDF value
my %fill = :email<[email protected]>;

# Combined import and filling
$fdf.import: :$from, :%fill;
# -OR- import then fill
$fdf.import: :$from;
$fdf.import: :%fill;

note "saving fields :-"
for $fdf.field-hash.sort {
    note " - {.key}: {.value.perl}";
}

$fdf.save-as: "MyDoc.fdf";

List field values in an FDF file

use FDF;
use FDF::Field;
my FDF $fdf .= open: "MyDoc.fdf";

my FDF::Fields @fields = $fdf.fields;
for @fields {
    say .key ~ ': ' ~ .value.raku;
}

Export field data from an FDF to a PDF

use PDF::Class;
use FDF;
my PDF::Class $to .= open: "MyDoc.pdf";
my FDF $fdf .= open: "MyDoc.fdf";

# populate form data from the PDF
$fdf.export: :$to;

# save updated fields
$to.update;

Description

FDF (Form Data Format) is a format for storing form data and formatting or annotations seperately from PDF files.

Bugs and Limitations

Not yet handled:

  • Form signing and signature manipulation
  • Import/export of annotations and pages
  • Custom encodings (/Encoding entry in the FDF dictionary)

fdf-raku's People

Contributors

dwarring avatar

Watchers

 avatar  avatar

Forkers

tbrowder

fdf-raku's Issues

pdf-fields.raku fails on two input files

I use two valid PDF files as input for the --list mode:

pdf-fields.raku --list t.fdf
Type check failed in assignment to $doc; expected PDF::Class but got FDF (${:Root(:ind-ref($[1,...)
  in sub MAIN at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 18
  in block <unit> at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 6
  in sub MAIN at /home/tbrowde/.raku/bin/pdf-fields.raku line 3
  in block <unit> at /home/tbrowde/.raku/bin/pdf-fields.raku line 1

And another input file:

pdf-fields.raku --list page-13-of-16.pdf
Earlier failures:
 (HANDLED) Failed to open file /usr/local/git-private-repos/my-win10-docs/Personal/001-Taxes-Finance-Insurance/0-Tax-returns-and-info/2019/TDAmeritrade/raku/demo-clone/page-13-of-16.pdf: No such file or directory
  in method coerce at /home/tbrowde/.raku/sources/9A1227A27EC7660B052D6BC05E82C88FB14D245A (PDF::IO) line 17
  in method open at /home/tbrowde/.raku/sources/6C9000FB47F7CA8CB5039F13245FA33D596CEACA (PDF::Reader) line 282
  in method open at /home/tbrowde/.raku/sources/6C9000FB47F7CA8CB5039F13245FA33D596CEACA (PDF::Reader) line 216
  in method open at /home/tbrowde/.raku/sources/3534A22AA69DD739E638541259ECC395BB942FE1 (PDF) line 41
  in method open at /home/tbrowde/.raku/sources/107FA69D1F1118140500EB4080F4BF8288AC58BF (PDF::Class) line 34
  in sub MAIN at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 22
  in block <unit> at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 6
  in sub MAIN at /home/tbrowde/.raku/bin/pdf-fields.raku line 3
  in block <unit> at /home/tbrowde/.raku/bin/pdf-fields.raku line 1

Final error:
 Cannot resolve caller coerce((IO): Failure); none of these signatures match:
    (PDF::IO: PDF::IO $value, :$path, *%_)
    (PDF::IO: IO::Path $value, |c)
    (PDF::IO: IO::Handle $value, |c)
    (PDF::IO: Str $value where { ... }, |c)
    (PDF::IO: Blob $_, |c)
  in method coerce at /home/tbrowde/.raku/sources/9A1227A27EC7660B052D6BC05E82C88FB14D245A (PDF::IO) line 17
  in method open at /home/tbrowde/.raku/sources/6C9000FB47F7CA8CB5039F13245FA33D596CEACA (PDF::Reader) line 282
  in method open at /home/tbrowde/.raku/sources/6C9000FB47F7CA8CB5039F13245FA33D596CEACA (PDF::Reader) line 216
  in method open at /home/tbrowde/.raku/sources/3534A22AA69DD739E638541259ECC395BB942FE1 (PDF) line 41
  in method open at /home/tbrowde/.raku/sources/107FA69D1F1118140500EB4080F4BF8288AC58BF (PDF::Class) line 34
  in sub MAIN at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 22
  in block <unit> at /home/tbrowde/.raku/resources/925E7C33EED9EA672F51B5EDE9CBA9CB63D97FD6 line 6
  in sub MAIN at /home/tbrowde/.raku/bin/pdf-fields.raku line 3
  in block <unit> at /home/tbrowde/.raku/bin/pdf-fields.raku line 1

The input files have no private data except our names, so I can email them to you or get them to you in whatever way you say.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.