pdfinject

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

pdfinject-go

Inject Value into Adobe PDF Form with GoLang. You can create FDF Data with values to fill in the PDF Form you create from Adobe Acrobat Pro DC.

This library is support for text field, radio button, check box and also support for pdf overlay on pdf function

Inspiration from : https://github.com/desertbit/fillpdf

Usage:

Define you form with pdfinject.Form (type map[string]interface{})

input your source file name replace in "sample.pdf" and define your output file name replace in "filled.pdf"


form := pdfinject.Form{
		"location": "Hello",
		"function": "World",
		"reason": "Kim",
		"headcountAddition": "Yes",
		"directors.0": "Yo",
		"kazekim_checkbox": "Yes",
	}

	pdfInject := pdfinject.New()
	err := pdfInject.FillWithDestFile(form, "sample.pdf", "filled.pdf")
	if err != nil {
		panic(err)
	}

You can see example in sample directory

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form map[string]interface{}

Form represents fields from the PDF form. define in key value map.

type PDFInject

type PDFInject struct {
	// contains filtered or unexported fields
}

func New

func New() PDFInject

func NewWithDestFile

func NewWithDestFile(destPDFFile string) PDFInject

func (PDFInject) Fill

func (pdf PDFInject) Fill(form Form, formPDFFile string) error

func (PDFInject) FillWithDestFile

func (pdf PDFInject) FillWithDestFile(form Form, formPDFFile, destPDFFile string) error

func (PDFInject) SetOverWrite

func (pdf PDFInject) SetOverWrite(canOverwrited bool)

SetOverWrite allow overWrite to Destination file

func (PDFInject) Stamp

func (pdf PDFInject) Stamp(stampPDFFile, srcPDFFile string) error

func (PDFInject) StampWithDestFile

func (pdf PDFInject) StampWithDestFile(stampPDFFile, srcPDFFile, destPDFFile string) error

type ShellCommand

type ShellCommand struct {
	// contains filtered or unexported fields
}

func NewShellCommand

func NewShellCommand(name string) ShellCommand

func (*ShellCommand) RunInPath

func (s *ShellCommand) RunInPath(dir string, args ...string) error

runCommandInPath runs a command and waits for it to exit. The working directory is also set. The stderr error message is returned on error.

type TempPDFDir

type TempPDFDir struct {
	// contains filtered or unexported fields
}

TempPDFDir manage PDF Inject process

func NewTempDir

func NewTempDir(dir, prefix string) (*TempPDFDir, error)

NewTempDir Create a temporary directory.

func (*TempPDFDir) CreateFDFFile

func (t *TempPDFDir) CreateFDFFile(form Form) (string, error)

CreateFDFFile Create a temporary fdf file

func (*TempPDFDir) CreateTempOutputFile

func (t *TempPDFDir) CreateTempOutputFile() string

CreateTempOutputFile Create a temporary output file

func (*TempPDFDir) Remove

func (t *TempPDFDir) Remove()

Remove delete temp directory when finish process

type XFDFForm

type XFDFForm map[string]interface{}

Form represents fields from the PDF form. define in key value map.

type XFDFGenerator

type XFDFGenerator struct {
	// contains filtered or unexported fields
}

TempPDFDir manage PDF Inject process

func NewXFDFGenerator

func NewXFDFGenerator(dir, prefix string) (*XFDFGenerator, error)

NewXFDFGenerator Create a XFDF Generator.

func (*XFDFGenerator) CreateTempOutputFile

func (t *XFDFGenerator) CreateTempOutputFile() string

CreateTempOutputFile Create a temporary output file

func (*XFDFGenerator) CreateXFDFFile

func (t *XFDFGenerator) CreateXFDFFile(form Form) (string, error)

CreateXFDFFile Create a temporary fdf file

func (*XFDFGenerator) Remove

func (t *XFDFGenerator) Remove()

Remove all temp file when finish process

Directories

Path Synopsis
pdfinject module

Jump to

Keyboard shortcuts

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