fillpdf

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 11 Imported by: 8

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 field values. Feel free to add support to more form types.

Documentation

Check the Documentation at GoDoc.org.

Requirements

FillPDF, under the hood, leverages the toolchain provided by PDFtk. Windows and Mac users need to install this dependency separately, the pdftk-sever executable is available here. After the installation is complete ensure that the install directory has been added to the system PATH (should be added automatically during the installation process).

Sample

There is an example in the sample directory:

package main

import (
	"log"

	"github.com/desertbit/fillpdf"
)

func main() {
	// Create the form values.
	form := fillpdf.Form{
		"field_1": "Hello",
		"field_2": "World",
	}

	// Fill the form PDF with our values.
	err := fillpdf.Fill(form, "form.pdf", "filled.pdf", 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 Fill

func Fill(form Form, formPDFFile, destPDFFile string, options ...Options) (err error)

Fill a PDF form with the specified form values and create a final filled PDF file. The options parameter alters few aspects of the generation.

Types

type Form

type Form map[string]interface{}

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

type Options

type Options struct {
	// Overwrite will overwrite any pre existing filled PDF
	Overwrite bool
	// Flatten will flatten the document making the form fields no longer editable
	Flatten bool
}

Options represents the options to alter the PDF filling process

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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