jung-kurt / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/jung-kurt/gofpdf
MIT License
4.29k stars 772 forks source link

Setting border color for cells #305

Closed sredxny closed 4 years ago

sredxny commented 4 years ago

Hi, is possible to set a color to the border of the cells without filling the cell by itself?

jung-kurt commented 4 years ago

Use SetDrawColor() to set the border color and false for the fill flag in CellFormat().

package main

import (
  "fmt"

  "github.com/jung-kurt/gofpdf/v2"
)

func main() {
  pdf := gofpdf.New("L", "mm", "A4", "")
  pdf.SetFont("Helvetica", "", 18)
  pdf.AddPage()
  pdf.SetDrawColor(0xff, 0x33, 0x44)
  pdf.CellFormat(50, 30, "Hello, world", "1", 0, "CM", false, 0, "")
  err := pdf.OutputFileAndClose("cell.pdf")
  if err != nil {
    fmt.Print("%s\n", err)
  }
}
sredxny commented 4 years ago

@jung-kurt thank you so much. It works!