qpdf

package
v0.0.0-...-556d222 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

*

  • library qpdf
  • is an extention to github.com/johnfercher/maroto *
  • maroto use grid system to handle table form, but due to it is still complexity to general usage
  • therefore, the objective to opdf is to provide a simple solution for table list pdf documet generator *
  • this library defines below strcuture for generating pdf forms *
  • - AbstractTable
  • a half page width table, as an abstraction table use case *
  • - TableForm
  • for data listing table usecase, *
  • detail information could see libs/qpdf/props.go *
  • how to use this library, you can see libs/qpdf/example/example.go *

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLackOfInit means lack of pdf file initial
	ErrLackOfInit = errors.New("please initial a pdf, by Initial")

	// ErrLoadImageByURL means read image by url has error
	ErrLoadImageByURL = errors.New("load image by given url failed")

	// ErrImageRead means image decode process has error
	ErrImageRead = errors.New("image read from url error")

	// ErrImageWrite means ioutil write image has error
	ErrImageWrite = errors.New("ioutil write image has error")

	// ErrExportByte means export pdf []byte failure
	ErrExportByte = errors.New("export pdf in byte array failed")
)

Functions

This section is empty.

Types

type AbstractRow

type AbstractRow struct {
	Title   string
	Content string
}

AbstractRow is

type AbstractTable

type AbstractTable struct {
	Height float64
	Width  float64
	Rows   []*AbstractRow
}

AbstractTable is special table for describe page, or document's abstraction format *

  • Abstract Table
  • ---------------------------
  • title | content | <-- AbstractRow
  • ---------------------------
  • title2 | content |
  • ---------------------------
  • title2 | content |
  • ---------------------------

func (*AbstractTable) LongestStr

func (at *AbstractTable) LongestStr() (titleLen float64, contentLen float64)

type Align

type Align string

Align defines text align

const (
	Left   Align = "L"
	Right  Align = "R"
	Center Align = "C"
	Top    Align = "T"
	Bottom Align = "B"
	Middle Align = "M"
)

type FooterTable

type FooterTable struct {
	Texts []string
}

type HeaderTable

type HeaderTable struct {
	LogoURL string
	Texts   []string
}

HeaderTable decsribe header format

type Orientation

type Orientation string

Orientation describe pdf file layout orientation

const (
	Portrait  Orientation = "P"
	Landscape Orientation = "L"
)

type PDF

type PDF interface {
	// Initial to Initial a pdf
	Initial(ctx ctx.CTX, orientation Orientation, pageSize PageSize) (err error)
	// SetHeader to set document header
	SetHeader(ctx ctx.CTX, header *HeaderTable) (err error)
	// SetFooter to set document footer
	SetFooter(ctx ctx.CTX, footer *FooterTable) (err error)
	// AppendAbstractTable to append an abstrct table on current page
	AppendAbstractTable(ctx ctx.CTX, table *AbstractTable) (err error)
	// AppendTable to append a table collection on current page
	AppendTable(ctx ctx.CTX, table *TableForm) (err error)
	// AddPage to add a new page in PDF
	AddPage(ctx ctx.CTX) (err error)
	// GetPDFbyte to get pdf content (byte)
	GetPDFbyte(ctx ctx.CTX) (pdfContent []byte, err error)
	// Save to close pdf file, and save in temp location
	Save(ctx ctx.CTX, filename string) (tempPath string, err error)
}

func New

func New() PDF

type PageSize

type PageSize string

PageSize to define document page size

const (
	A4 PageSize = "A4"
)

type TableCell

type TableCell struct {
	FontBold  bool
	UnderLine bool
	Width     uint
	Align     Align
	Content   string
}

type TableForm

type TableForm struct {
	Rows []*TableRow
}

TableForm represents table for information table

type TableRow

type TableRow struct {
	IsHeader bool
	Cells    []*TableCell
}

func (*TableRow) GetRowHeight

func (tr *TableRow) GetRowHeight() (height float64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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