pdfinject

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 12 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 FDFGenerator added in v1.0.1

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

TempPDFDir manage PDF Inject process

func NewFDFGenerator added in v1.0.1

func NewFDFGenerator(dir, prefix string) (*FDFGenerator, error)

NewFDFGenerator Create a FDF Generator.

func (*FDFGenerator) CreateFDFFile added in v1.0.1

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

CreateFDFFile Create a temporary fdf file

func (*FDFGenerator) GetTempOutputFile added in v1.0.1

func (t *FDFGenerator) GetTempOutputFile() string

GetTempOutputFile get temp output file for pdf

func (*FDFGenerator) Remove added in v1.0.1

func (t *FDFGenerator) Remove()

Remove delete temp directory when finish process

type Form

type Form map[string]interface{}

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

type InputType added in v1.0.1

type InputType int
const (
	XFDF InputType = 0
	FDF            = 1
)

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) (*string, error)

func (PDFInject) FillModel added in v1.0.1

func (pdf PDFInject) FillModel(model interface{}, formPDFFile string) (*string, error)

func (PDFInject) FillModelWithDestFile added in v1.0.1

func (pdf PDFInject) FillModelWithDestFile(model interface{}, formPDFFile string, destPDFFile string) (*string, error)

func (PDFInject) FillWithDestFile

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

func (PDFInject) SetInputType added in v1.0.1

func (pdf PDFInject) SetInputType(in InputType)

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 TempFile added in v1.0.1

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

func NewTempFile added in v1.0.1

func NewTempFile(dir, prefix string) (*TempFile, error)

NewTempFile Create a FDF Generator.

func (*TempFile) GetTempOutputFilePath added in v1.0.1

func (t *TempFile) GetTempOutputFilePath() string

GetTempOutputFilePath Get a temporary output file path

func (*TempFile) Remove added in v1.0.1

func (t *TempFile) Remove()

Remove delete temp directory when finish process

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) CreateXFDFFile

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

CreateXFDFFile Create a temporary fdf file

func (*XFDFGenerator) GetTempOutputFile added in v1.0.1

func (t *XFDFGenerator) GetTempOutputFile() string

GetTempOutputFile get temp output file for pdf

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