fillpdf

package module
v0.0.0-...-5ea2313 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

FillPDF

FillPDF is a golang library to easily fill PDF forms. This library uses the pdftk utility to fill the PDF forms with fdf data. Currently this library only supports PDF text and checkbox field values. Feel free to add support to more form types (Send pull request to original developer) This fork extends with some more pdftk commands

  • Multistamp
  • Ability to generate PDF's with special characters (with flatten) with pdftk. (Limited by font in PDF)

Documentation

Check the Documentation at GoDoc.org.

Sample

There is an example:

package main

import (
	"log"

	"github.com/phelian/fillpdf"
)

func main() {
	// Create the form values.
	form := fillpdf.Form{
		"field_1": "Hello",
		"field_2": "World",
		"field_3": "with special åäöéè",
	}

	// Fill the form PDF with our values.
	err := fillpdf.Fill(form, "form.pdf", "filled.pdf", "On", "Off", true)
	if err != nil {
		log.Fatal(err)
	}
}

Run the example as following:

cd sample
go build
./sample

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeUTF16

func EncodeUTF16(s string, addBom bool) []byte

Taken from https://gist.github.com/ik5/65de721ca495fa1bf451 EncodeUTF16 get a utf8 string and translate it into a slice of bytes of ucs2

func Fill

func Fill(form Form, formPDFFile, destPDFFile, checkedString, uncheckedString string, overwrite bool) error

Fill a PDF form with the specified form values and create a final filled PDF file. One variadic boolean specifies, whenever to overwrite the destination file if it exists. Checkboxes specify one string for checked (checkedString) and one string for unchecked (uncheckedString). The specification can be done on each individual checkbox, but lets assume that all checkboxes in the same document will use the same strings.

func Merge

func Merge(files ...string) (io.Reader, error)

Merge concatenates all input <files> and outputs one single pdf in <output>

func Multistamp

func Multistamp(stampontoPDFFile, stampPDFFile string) (io.Reader, error)

Multistamp stamps one PDF ontop of another, returns a reader to bytes generated.

Types

type Form

type Form map[string]interface{}

Form represents the PDF form. This is a key value map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL