Giter Club home page Giter Club logo

pdf's People

Contributors

benoitkugler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pdf's Issues

License

This repository doesn't specify a license. Among other issues, this makes it invisible on pkg.go.dev.

PDF is blank after attempting to fill in fields

EDIT: I am attempting this on wsl2 - in case that makes a difference

I am trying to wrap my head around how a simple form can be filled but I can't seem to make it work.

I tried the examples - ie. cargo test in formfill but the filled.pdf has no information entered in the fields?

I have put together a small example using the same template - attempting to fill just one field - but I have the same result, no data entered.

Am I doing something wrong here?

PS: not really a go person but I really need to get some PDF forms filled in automatically

package main

import (
        "fmt"
        "github.com/benoitkugler/pdf/formfill"
        "github.com/benoitkugler/pdf/reader"
        "os" // Import the os package
)

var data = []formfill.FDFField{
        {T: "z2",
        Values: formfill.Values{
            V: formfill.FDFText("testing_here"),
        },

    },
}

func main() {
        const path = "original_sample.pdf"
        doc, _, err := reader.ParsePDFFile(path, reader.Options{})
        if err != nil {
                fmt.Fprintf(os.Stderr, "Error: %s\n", err)
                os.Exit(1) // Exit the program if there is an error
        }

        err = formfill.FillForm(&doc, formfill.FDFDict{Fields: data}, true)

        if err != nil {
                fmt.Fprintf(os.Stderr, "Error: %s\n", err)
                os.Exit(1) // Exit the program if there is an error
        }
        out, err := os.Create("filled.pdf")
        if err != nil {
                fmt.Fprintf(os.Stderr, "Error: %s\n", err)
                os.Exit(1) // Exit the program if there is an error
        }

        if err = doc.Write(out, nil); err != nil {
                fmt.Fprintf(os.Stderr, "Error: %s\n", err)
                os.Exit(1) // Exit the program if there is an error
        }

}

tests failing due to some missing PDFs

i wanted to have a play with the formfilling.

I have 2 files missing that stop tests in the form filling.

open test/open_action.pdf: no such file or directory

can't open file: open test/ModeleRecuFiscalEditable.pdf: no such file or directory

Is is because the files are too big for git practically ?

"missing TrueType font file"

How can I use a custom font type Courier?

func main() {

	doc, _, err := reader.ParsePDFFile("/Users/tommynanny/Desktop/PDFWorker/template3.pdf", reader.Options{})
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// if L := len(doc.Catalog.AcroForm.Flatten()); L != 65 {
	// 	fmt.Println(fmt.Errorf("expected 65 fields, got %d", L))
	// 	os.Exit(1)
	// }

	err = formfill.FillForm(&doc, formfill.FDFDict{
		Fields: []formfill.FDFField{
			{
				T: "z1",
				Values: formfill.Values{
					V: formfill.Text("Nanlin Sun"),
				},
			},
		},
	}, true)

	if err != nil {
		fmt.Println(err)    // << --- "missing TrueType font file"
		os.Exit(1)
	}

	out, err := os.Create("/Users/tommynanny/Desktop/PDFWorker/output.pdf")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	if err = doc.Write(out, nil); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

Error on empty Outline item

I realize my pdf full of Japanese characters doesn't seem to work with reader.ParsePDFFile which gives me the error of "unexpected type for Outline item: <nil>". I was wondering if there is a work around?

Originally posted by @tommynanny in #4 (comment)

Error on field name with a special character

When attempting to fill in the attached file, everything works fine until it attempts to fill the 3.2 Companies' House Reg No field.
I assume this is due to the ' in the field name but I can't figure out how to escape it. Is this something that is caused by the library or go?

Any advice would be welcome...

Error: unexpected value type for text field: formfill.FDFName
exit status 1

g02.pdf

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.