github.com/signintech/pdft@v0.5.0/minigopdf/cache_contact_color.go (about) 1 package gopdf 2 3 import ( 4 "bytes" 5 "fmt" 6 ) 7 8 const colorTypeStroke = "RG" 9 10 const colorTypeFill = "rg" 11 12 type cacheContentColor struct { 13 colorType string 14 r, g, b uint8 15 } 16 17 func (c *cacheContentColor) toStream(protection *PDFProtection) (*bytes.Buffer, error) { 18 var buff bytes.Buffer 19 rFloat := float64(c.r) * 0.00392156862745 20 gFloat := float64(c.g) * 0.00392156862745 21 bFloat := float64(c.b) * 0.00392156862745 22 buff.WriteString(fmt.Sprintf("%.2f %.2f %.2f %s\n", rFloat, gFloat, bFloat, c.colorType)) 23 return &buff, nil 24 }