Documentation ¶
Index ¶
- type JustPdf
- type PdfJustPdf
- func (s *PdfJustPdf) Barcode(code string, prop ...props.Barcode) (err error)
- func (s *PdfJustPdf) Base64Image(base64 string, extension consts.Extension, prop ...props.Rect) error
- func (s *PdfJustPdf) Col(closure func())
- func (s *PdfJustPdf) ColSpace()
- func (s *PdfJustPdf) ColSpaces(qtd int)
- func (s *PdfJustPdf) FileImage(filePathName string, prop ...props.Rect) error
- func (s *PdfJustPdf) GetBorder() bool
- func (s *PdfJustPdf) GetCurrentOffset() float64
- func (s *PdfJustPdf) GetCurrentPage() int
- func (s *PdfJustPdf) GetPageMargins() (left float64, top float64, right float64, bottom float64)
- func (s *PdfJustPdf) GetPageSize() (float64, float64)
- func (s *PdfJustPdf) Line(spaceHeight float64)
- func (s *PdfJustPdf) Output() (bytes.Buffer, error)
- func (s *PdfJustPdf) OutputFileAndClose(filePathName string) (err error)
- func (s *PdfJustPdf) QrCode(code string, prop ...props.Rect)
- func (s *PdfJustPdf) RegisterFooter(closure func())
- func (s *PdfJustPdf) RegisterHeader(closure func())
- func (s *PdfJustPdf) Row(height float64, closure func())
- func (s *PdfJustPdf) SetBackgroundColor(color color.Color)
- func (s *PdfJustPdf) SetBorder(on bool)
- func (s *PdfJustPdf) SetLRMargins(left, right float64)
- func (s *PdfJustPdf) SetPageMargins(left, top, right, bottom float64)
- func (s *PdfJustPdf) SetTextColor(color color.Color)
- func (s *PdfJustPdf) Signature(label string, prop ...props.Font)
- func (s *PdfJustPdf) TableList(header []string, contents [][]string, prop ...props.TableList)
- func (s *PdfJustPdf) Text(text string, prop ...props.Text)
- func (s *PdfJustPdf) VLine(spaceWidth, spaceHeight float64, color color.Color)
Examples ¶
- NewJustPdf
- PdfJustPdf.Barcode
- PdfJustPdf.Base64Image
- PdfJustPdf.Col
- PdfJustPdf.ColSpace
- PdfJustPdf.ColSpaces
- PdfJustPdf.FileImage
- PdfJustPdf.GetBorder
- PdfJustPdf.GetCurrentOffset
- PdfJustPdf.GetCurrentPage
- PdfJustPdf.GetPageMargins
- PdfJustPdf.GetPageSize
- PdfJustPdf.Line
- PdfJustPdf.Output
- PdfJustPdf.OutputFileAndClose
- PdfJustPdf.QrCode
- PdfJustPdf.RegisterFooter
- PdfJustPdf.RegisterHeader
- PdfJustPdf.Row
- PdfJustPdf.SetBackgroundColor
- PdfJustPdf.SetBorder
- PdfJustPdf.SetPageMargins
- PdfJustPdf.Signature
- PdfJustPdf.TableList
- PdfJustPdf.Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JustPdf ¶
type JustPdf interface { // Grid System Row(height float64, closure func()) Col(closure func()) ColSpace() ColSpaces(qtd int) // Registers RegisterHeader(closure func()) // Helpers SetBorder(on bool) SetBackgroundColor(color color.Color) SetTextColor(color color.Color) GetBorder() bool GetPageSize() (float64, float64) GetCurrentPage() int GetCurrentOffset() float64 SetPageMargins(left, top, right, bottom float64) SetLRMargins(left, right float64) GetPageMargins() (float64, float64, float64, float64) // Outside Col/Row Components TableList(header []string, contents [][]string, prop ...props.TableList) Line(spaceHeight float64) VLine(spaceWidht, spaceHeight float64, color color.Color) // Inside Col/Row Components Text(text string, prop ...props.Text) FileImage(filePathName string, prop ...props.Rect) (err error) Base64Image(base64 string, extension consts.Extension, prop ...props.Rect) (err error) Barcode(code string, prop ...props.Barcode) error QrCode(code string, prop ...props.Rect) Signature(label string, prop ...props.Font) // File System OutputFileAndClose(filePathName string) error Output() (bytes.Buffer, error) }
JustPdf is the principal abstraction to create a PDF document.
func NewJustPdf ¶
func NewJustPdf(orientation consts.Orientation, pageSize consts.PageSize) JustPdf
NewJustPdf create a JustPdf instance returning a pointer to PdfJustPdf Receive an Orientation and a PageSize.
Example ¶
ExampleNewJustPdf demonstratos how to create just_pdf
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Do things m.GetPageMargins() // Do more things and save... }
Output:
type PdfJustPdf ¶
type PdfJustPdf struct { Pdf gofpdf.Pdf Math internal.Math Font internal.Font TextHelper internal.Text SignHelper internal.Signature Image internal.Image Code internal.Code TableListHelper internal.TableList // contains filtered or unexported fields }
PdfJustPdf is the principal structure which implements JustPdf abstraction
func (*PdfJustPdf) Barcode ¶
func (s *PdfJustPdf) Barcode(code string, prop ...props.Barcode) (err error)
Barcode create an barcode inside a cell.
Example ¶
ExamplePdfJustPdf_Barcode demonstrates how to place a barcode inside a Col. Passing nil on barcode props parameter implies the Barcode fills it's context cell depending on it's size. It's possible to define the barcode positioning through the top and left parameters unless center parameter is true. In brief, when center parameter equals true, left and top parameters has no effect. Percent parameter represents the Barcode's width/height inside the cell. i.e. Percent: 75 means that the Barcode will take up 75% of Col's width There is a constraint in the proportion defined, height cannot be greater than 20% of the width, and height cannot be smaller than 10% of the width.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Do a lot of things on rows and columns... m.Col(func() { _ = m.Barcode("https://github.com/muhammadmuhlas/just_pdf", props.Barcode{ Percent: 75, Proportion: props.Proportion{Width: 50, Height: 10}, Center: true, }) }) // do more things... }
Output:
func (*PdfJustPdf) Base64Image ¶
func (s *PdfJustPdf) Base64Image(base64 string, extension consts.Extension, prop ...props.Rect) error
Base64Image add an Image reading byte slices inside a cell. Defining Image properties.
Example ¶
ExamplePdfJustPdf_Base64Image demonstrates how to add an Image from a base64 string. When rect properties is nil, the method makes the Image fulfill the context cell, based on width and height from Image and cell. When center is true, left and top has no effect. Percent represents the width/height of the Image inside the cell: Ex: 85, means that Image will have width of 85% of column width. When center is false, is possible to manually positioning the Image with left and top.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 base64String := "y7seWGHE923Sdgs..." m.Row(rowHeight, func() { m.Col(func() { _ = m.Base64Image(base64String, consts.Png, props.Rect{ Left: 5, Top: 5, Center: true, Percent: 85, }) }) }) // Do more things and save... }
Output:
func (*PdfJustPdf) Col ¶
func (s *PdfJustPdf) Col(closure func())
Col create a column inside a row and enable to add components inside.
Example ¶
ExamplePdfJustPdf_Col demonstrates how to add an useful column
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.Col(func() { // Add Image, Text, Signature, QrCode or Barcode... }) }) // Do more things and save... }
Output:
func (*PdfJustPdf) ColSpace ¶
func (s *PdfJustPdf) ColSpace()
ColSpace create an empty column inside a row.
Example ¶
ExamplePdfJustPdf_ColSpace demonstrates how to add an empty column inside a row.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.ColSpace() }) // Do more things and save... }
Output:
func (*PdfJustPdf) ColSpaces ¶
func (s *PdfJustPdf) ColSpaces(qtd int)
ColSpaces create some empty columns inside a row.
Example ¶
ExamplePdfJustPdf_ColSpaces demonstrates how to add some empty columns inside a row.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.ColSpaces(2) }) // Do more things and save... }
Output:
func (*PdfJustPdf) FileImage ¶
func (s *PdfJustPdf) FileImage(filePathName string, prop ...props.Rect) error
FileImage add an Image reading from disk inside a cell. Defining Image properties.
Example ¶
ExamplePdfJustPdf_FileImage demonstrates how add an Image reading from disk. When props.Rect is nil, method make Image fulfill the context cell, based on width and cell from Image and cell. When center is true, left and top has no effect. Percent represents the width/height of the Image inside the cell: Ex: 85, means that Image will have width of 85% of column width. When center is false, is possible to manually positioning the Image with left and top.AddFromBase64(string, float64, float64, float64, float64, float64, consts.Extension)
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.Col(func() { _ = m.FileImage("path/Image.jpg", props.Rect{ Left: 5, Top: 5, Center: true, Percent: 85, }) }) }) // Do more things and save... }
Output:
func (*PdfJustPdf) GetBorder ¶
func (s *PdfJustPdf) GetBorder() bool
GetBorder return the actual border value.
Example ¶
ExamplePdfJustPdf_GetBorder demonstrates how to obtain the actual borders status
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // false m.GetBorder() m.SetBorder(true) // true m.GetBorder() // Do more things and save... }
Output:
func (*PdfJustPdf) GetCurrentOffset ¶
func (s *PdfJustPdf) GetCurrentOffset() float64
GetCurrentOffset obtain the current offset in y axis
Example ¶
ExamplePdfJustPdf_GetCurrentOffset demonstrates how to obtain the current write offset i.e the height of cursor adding content in the pdf
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Offset here will be 0 _ = m.GetCurrentOffset() // Add Rows, Cols and Components until just_pdf add a new page // Offset here will not be 0 _ = m.GetCurrentOffset() // Add Rows, Cols and Components to just_pdf add a new page // Offset here will be 0 _ = m.GetCurrentOffset() // Do more things and save... }
Output:
func (*PdfJustPdf) GetCurrentPage ¶
func (s *PdfJustPdf) GetCurrentPage() int
GetCurrentPage obtain the current page index this can be used inside a RegisterFooter/RegisterHeader to draw the current page, or to another purposes
Example ¶
ExamplePdfJustPdf_GetCurrentPage demonstrates how to obtain the current page index
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Index here will be 0 _ = m.GetCurrentPage() // Add Rows, Cols and Components // Index here will not be 0 _ = m.GetCurrentPage() // Do more things and save... }
Output:
func (*PdfJustPdf) GetPageMargins ¶
func (s *PdfJustPdf) GetPageMargins() (left float64, top float64, right float64, bottom float64)
GetPageMargins returns the set page margins. Comes in order of Left, Top, Right, Bottom Default page margins is left: 10, top: 10, right: 10
Example ¶
ExamplePdfJustPdf_GetPageMargins demonstrates how to obtain the current page margins
package main import ( "fmt" "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Get left, top, right, bottom := m.GetPageMargins() fmt.Println(left) fmt.Println(top) fmt.Println(right) fmt.Println(bottom) // Do more things and save... }
Output:
func (*PdfJustPdf) GetPageSize ¶
func (s *PdfJustPdf) GetPageSize() (float64, float64)
GetPageSize return the actual page size
Example ¶
ExamplePdfJustPdf_GetPageSize demonstrates how to obtain the current page size (width and height)
package main import ( "fmt" "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Get width, height := m.GetPageSize() fmt.Println(width) fmt.Println(height) // Do more things and save... }
Output:
func (*PdfJustPdf) Line ¶
func (s *PdfJustPdf) Line(spaceHeight float64)
Line draw a line from margin left to margin right in the currently row.
Example ¶
ExamplePdfJustPdf_Line demonstrates how to draw a line separator.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) m.Line(1.0) // Do more things and save... }
Output:
func (*PdfJustPdf) Output ¶
func (s *PdfJustPdf) Output() (bytes.Buffer, error)
Output extract PDF in byte slices
Example ¶
ExamplePdfJustPdf_Output demonstrates how to get a base64 string from PDF
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Do a lot of things on rows and columns... _, err := m.Output() if err != nil { return } }
Output:
func (*PdfJustPdf) OutputFileAndClose ¶
func (s *PdfJustPdf) OutputFileAndClose(filePathName string) (err error)
OutputFileAndClose save pdf in disk.
Example ¶
ExamplePdfJustPdf_OutputFileAndClose demonstrates how to save a PDF object into disk.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) // Do a lot of things on rows and columns... err := m.OutputFileAndClose("path/file.pdf") if err != nil { return } }
Output:
func (*PdfJustPdf) QrCode ¶
func (s *PdfJustPdf) QrCode(code string, prop ...props.Rect)
QrCode create a qrcode inside a cell.
Example ¶
ExamplePdfJustPdf_QrCode demonstrates how to add a QR Code inside a Col. Passing nil on rectProps makes the QR Code fills the context cell depending on width and height of the QR Code and the cell. When center is true, left and top has no effect. Percent represents the width/height of the QR Code inside the cell. i.e. 80 means that the QR Code will take up 80% of Col's width When center is false, positioning of the QR Code can be done through left and top.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.Col(func() { m.QrCode("https://godoc.org/github.com/muhammadmuhlas/just_pdf", props.Rect{ Left: 5, Top: 5, Center: false, Percent: 80, }) }) }) }
Output:
func (*PdfJustPdf) RegisterFooter ¶
func (s *PdfJustPdf) RegisterFooter(closure func())
RegisterFooter define a sequence of Rows, Lines ou TableLists which will be added in every new page
func (*PdfJustPdf) RegisterHeader ¶
func (s *PdfJustPdf) RegisterHeader(closure func())
RegisterHeader define a sequence of Rows, Lines ou TableLists which will be added in every new page
Example ¶
ExamplePdfJustPdf_RegisterHeader demonstrates how to register header. For register header in JustPdf you need to call method RegisterHeader that receives a closure. In this closure you are free to set any components you want to compose your header. In this example there is a two texts with different props and one image. It is important to remember that it is recommended to create Row's and Col's if necessary. A tip is to register the header immediately after the JustPdf instantiation to make the code easier to read.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" "time" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) m.RegisterHeader(func() { m.Row(10, func() { m.Col(func() { m.Text("lorem ipsum dolor", props.Text{Align: consts.Left}) }) m.Col(func() { _ = m.FileImage("internal/assets/images/frontpage.png") }) m.Col(func() { m.Text(time.Now().Format("02-January-2006"), props.Text{Align: consts.Right}) }) }) }) // Do more things or not and save... }
Output:
func (*PdfJustPdf) Row ¶
func (s *PdfJustPdf) Row(height float64, closure func())
Row define a row and enable add columns inside the row.
Example ¶
ExamplePdfJustPdf_Row demonstrates how to define a row.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { // ... Add some columns }) // Do more things and save... }
Output:
func (*PdfJustPdf) SetBackgroundColor ¶
func (s *PdfJustPdf) SetBackgroundColor(color color.Color)
SetBackgroundColor define the background color of the PDF. This method can be used to toggle background from rows
Example ¶
ExamplePdfJustPdf_SetBackgroundColor demonstrates how to use the SetBackgroundColor method.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/color" "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) m.SetBackgroundColor(color.Color{ Red: 100, Green: 20, Blue: 30, }) // This Row will be filled with the color m.Row(20, func() { m.Col(func() { // Add components }) }) m.SetBackgroundColor(color.NewWhite()) // This Row will not be filled with the color m.Row(20, func() { m.Col(func() { // Add components }) }) // Do more things and save... }
Output:
func (*PdfJustPdf) SetBorder ¶
func (s *PdfJustPdf) SetBorder(on bool)
SetBorder enable the draw of lines in every cell. Draw borders in all columns created.
Example ¶
ExamplePdfJustPdf_SetBorder demonstrates how to enable the line drawing in every cell
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) m.SetBorder(true) // Add some Rows, Cols, Lines and etc... // Here will be drawn borders in every cell m.SetBorder(false) // Add some Rows, Cols, Lines and etc... // Here will not be drawn borders // Do more things and save... }
Output:
func (*PdfJustPdf) SetLRMargins ¶
func (s *PdfJustPdf) SetLRMargins(left, right float64)
SetLRMargins only affect left and right margin
func (*PdfJustPdf) SetPageMargins ¶
func (s *PdfJustPdf) SetPageMargins(left, top, right, bottom float64)
SetPageMargins overrides default margins (10,10,10,2(cm)) the new page margin will affect all PDF pages
Example ¶
ExamplePdfJustPdf_SetPageMargins demonstrates how to set custom page margins.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) m.SetPageMargins(10, 60, 10, 10) // Do more things or not and save... }
Output:
func (*PdfJustPdf) SetTextColor ¶
func (s *PdfJustPdf) SetTextColor(color color.Color)
SetTextColor define the color of the Text.
func (*PdfJustPdf) Signature ¶
func (s *PdfJustPdf) Signature(label string, prop ...props.Font)
Signature add a space for a signature inside a cell, the space will have a line and a text below
Example ¶
ExamplePdfJustPdf_Signature demonstrates how to add a Signature space inside a col. Passing nil on signatureProp make the method use: arial Font, normal style and size 10.0. Not passing family, make method use arial. Not passing style, make method use normal. Not passing size, make method use 10.0.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.Col(func() { m.Signature("LabelForSignature", props.Font{ Size: 12.0, Style: consts.BoldItalic, Family: consts.Courier, }) }) }) // Do more things and save... }
Output:
func (*PdfJustPdf) TableList ¶
func (s *PdfJustPdf) TableList(header []string, contents [][]string, prop ...props.TableList)
TableList create a table with multiple rows and columns. Headers define the amount of columns from each row. Headers have bold style, and localized at the top of table. Contents are array of arrays. Each array is one line.
Example ¶
ExamplePdfJustPdf_TableList demonstrates how to add a table with multiple rows and columns
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/color" "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) headers := []string{"Header1", "Header2"} contents := [][]string{ {"Content1", "Content2"}, {"Content3", "Content3"}, } // 1 Row of header // 2 Rows of contents // Each row have 2 columns m.TableList(headers, contents, props.TableList{ HeaderProp: props.Font{ Family: consts.Arial, Style: consts.Bold, Size: 11.0, }, ContentProp: props.Font{ Family: consts.Courier, Style: consts.Normal, Size: 10.0, }, Align: consts.Center, AlternatedBackground: &color.Color{ Red: 100, Green: 20, Blue: 255, }, HeaderContentSpace: 10.0, Line: false, }) // Do more things and save... }
Output:
func (*PdfJustPdf) Text ¶
func (s *PdfJustPdf) Text(text string, prop ...props.Text)
Text create a text inside a cell.
Example ¶
ExamplePdfJustPdf_Text demonstrates how to add a Text inside a col. Passing nil on fontProp makes the method use: arial Font, normal style, size 10.0 and align left. Not passing family, makes the method use arial. Not passing style, makes the method use normal. Not passing size, makes the method use 10.0. Not passing align, makes the method use left.
package main import ( "github.com/muhammadmuhlas/just_pdf/pkg/consts" "github.com/muhammadmuhlas/just_pdf/pkg/pdf" "github.com/muhammadmuhlas/just_pdf/pkg/props" ) func main() { m := pdf.NewJustPdf(consts.Portrait, consts.A4) rowHeight := 5.0 m.Row(rowHeight, func() { m.Col(func() { m.Text("TextContent", props.Text{ Size: 12.0, Style: consts.BoldItalic, Family: consts.Courier, Align: consts.Center, Top: 1.0, Extrapolate: false, VerticalPadding: 1.0, }) }) }) // Do more things and save... }
Output: