models

package
v0.0.0-...-04ab0c9 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DIN dimensions
	PageSizeKeyA0 = "a0"
	PageSizeKeyA1 = "a1"
	PageSizeKeyA2 = "a2"
	PageSizeKeyA3 = "a3"
	PageSizeKeyA4 = "a4"
	PageSizeKeyA5 = "a5"
	PageSizeKeyA6 = "a6"

	// US dimensions
	PageSizeKeyLetter = "letter"
	PageSizeKeyLegal  = "legal"
)

Variables

View Source
var PageSizesMap = map[string]PageSize{

	PageSizeKeyA0: {Width: 841, Height: 1189},
	PageSizeKeyA1: {Width: 594, Height: 841},
	PageSizeKeyA2: {Width: 420, Height: 594},
	PageSizeKeyA3: {Width: 297, Height: 420},
	PageSizeKeyA4: {Width: 210, Height: 297},
	PageSizeKeyA5: {Width: 148, Height: 210},
	PageSizeKeyA6: {Width: 105, Height: 148},

	PageSizeKeyLetter: {Width: 216, Height: 297},
	PageSizeKeyLegal:  {Width: 216, Height: 279},
}

Functions

This section is empty.

Types

type Job

type Job struct {
	RequestCtx   context.Context
	RenderData   *RenderData
	CallbackChan chan io.Reader
}

func NewJob

func NewJob(requestCtx context.Context, renderData *RenderData) *Job

type PageSize

type PageSize struct {
	// in mm
	Width int `json:"width" example:"210"`
	// in mm
	Height int `json:"height" example:"297"`

} // @name PageSize

type RenderData

type RenderData struct {
	Html       *string `json:"html" example:"<b>Hello World</b>"`
	HeaderHtml string  `json:"headerHtml,omitempty" example:"<h1>Heading</h1>"` // Optional html for header. If empty, the header html will be parsed from main html (<PdfHeader></PdfHeader>).
	FooterHtml string  ``                                                       // Optional html for footer. If empty, the footer html will be parsed from main html (<PdfFooter></PdfFooter>).
	/* 157-byte string literal not displayed */

	RenderOptions RenderOptions `json:"options,omitempty"`

} // @name RenderData

func (*RenderData) GetFooterHtml

func (d *RenderData) GetFooterHtml() string

func (*RenderData) GetHeaderHtml

func (d *RenderData) GetHeaderHtml() string

func (*RenderData) HasHeaderOrFooterHtml

func (d *RenderData) HasHeaderOrFooterHtml() bool

func (*RenderData) SetDefaults

func (d *RenderData) SetDefaults()

func (*RenderData) SetFooterHtml

func (d *RenderData) SetFooterHtml(html string)

func (*RenderData) SetHeaderHtml

func (d *RenderData) SetHeaderHtml(html string)

type RenderOptions

type RenderOptions struct {
	Landscape            bool `json:"landscape,omitempty" default:"false"`
	ExcludeBuiltinStyles bool `json:"excludeBuiltinStyles,omitempty" default:"false"`

	// page size in mm; overrides page format
	PageSize   PageSize `json:"pageSize,omitempty"`
	PageFormat string   `json:"pageFormat,omitempty" default:"A4" enums:"A0,A1,A2,A3,A4,A5,A6,Letter,Legal"`

	// margins in mm; fallback to default if null
	Margins *RenderOptionsMargins `json:"margins,omitempty"`

	// true if options was parsed from bundle
	IsBundle bool `json:"-"`
	// base path is required for accessing bundle assets from loopback
	BasePath string `json:"-"`

} // @name RenderOptions

func (*RenderOptions) SetDefaults

func (ro *RenderOptions) SetDefaults()

type RenderOptionsMargins

type RenderOptionsMargins struct {
	// margin top in mm
	Top int `json:"top,omitempty" default:"25"`
	// margin right in mm
	Right int `json:"right,omitempty" default:"25"`
	// margin bottom in mm
	Bottom int `json:"bottom,omitempty" default:"20"`
	// margin left in mm
	Left int `json:"left,omitempty" default:"25"`

} // @name RenderOptionsMargins

type RenderTemplateData

type RenderTemplateData struct {
	HtmlTemplate *string `json:"htmlTemplate"`
	// Optional template for header. If empty, the header template will be parsed from main template (<PdfHeader></PdfHeader>).
	HeaderHtmlTemplate string `json:"headerHtmlTemplate,omitempty"`
	// Optional template for footer. If empty, the footer template will be parsed from main template (<PdfFooter></PdfFooter>).
	FooterHtmlTemplate string `json:"footerHtmlTemplate,omitempty"`

	// Model with your data matching to the templates
	Model any `json:"model,omitempty" swaggertype:"object"`

	TemplateEngine string `json:"templateEngine,omitempty" default:"golang" enums:"golang,handlebars,django"`

	RenderOptions RenderOptions `json:"options,omitempty"`

} // @name RenderTemplateData

func (*RenderTemplateData) GetFooterHtml

func (d *RenderTemplateData) GetFooterHtml() string

func (*RenderTemplateData) GetHeaderHtml

func (d *RenderTemplateData) GetHeaderHtml() string

func (*RenderTemplateData) HasHeaderOrFooterHtml

func (d *RenderTemplateData) HasHeaderOrFooterHtml() bool

func (*RenderTemplateData) ParseJsonModelDataFromDoubleEncodedString

func (d *RenderTemplateData) ParseJsonModelDataFromDoubleEncodedString()

func (*RenderTemplateData) SetFooterHtml

func (d *RenderTemplateData) SetFooterHtml(html string)

func (*RenderTemplateData) SetHeaderHtml

func (d *RenderTemplateData) SetHeaderHtml(html string)

type WithDefaults

type WithDefaults interface {
	SetDefaults()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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