github.com/signintech/pdft@v0.5.0/minigopdf/cache_contnent_curve.go (about)

     1  package gopdf
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  )
     7  
     8  type cacheContentCurve struct {
     9  	pageHeight float64
    10  	x0         float64
    11  	y0         float64
    12  	x1         float64
    13  	y1         float64
    14  	x2         float64
    15  	y2         float64
    16  	x3         float64
    17  	y3         float64
    18  	style      string
    19  }
    20  
    21  func (c *cacheContentCurve) toStream(protection *PDFProtection) (*bytes.Buffer, error) {
    22  
    23  	h := c.pageHeight
    24  	x0 := c.x0
    25  	y0 := c.y0
    26  	x1 := c.x1
    27  	y1 := c.y1
    28  	x2 := c.x2
    29  	y2 := c.y2
    30  	x3 := c.x3
    31  	y3 := c.y3
    32  	style := c.style
    33  
    34  	var buff bytes.Buffer
    35  	//cp := 0.55228
    36  	buff.WriteString(fmt.Sprintf("%0.2f %0.2f m\n", x0, h-y0))
    37  	buff.WriteString(fmt.Sprintf(
    38  		"%0.2f %0.2f %0.2f %0.2f %0.2f %0.2f c",
    39  		x1, h-y1, x2, h-y2, x3, h-y3,
    40  	))
    41  	op := "S"
    42  	if style == "F" {
    43  		op = "f"
    44  	} else if style == "FD" || style == "DF" {
    45  		op = "B"
    46  	}
    47  	buff.WriteString(fmt.Sprintf(" %s\n", op))
    48  	return &buff, nil
    49  }