Improve signature annotation rectangle drawing

This commit is contained in:
Adrian-George Bostan 2019-02-19 22:03:42 +02:00
parent 3f049d474e
commit 85e62c3c30

View File

@ -366,19 +366,26 @@ func genFieldSignatureAppearance(fields []*SignatureLine, opts *SignatureFieldOp
offsetY += (rectHeight - float64(len(lines))*lineHeight) / 2
}
// Draw signature.
// Draw annotation rectangle.
cc := contentstream.NewContentCreator()
if opts.BorderSize > 0 {
cc.Add_q().
Add_re(rect[0], rect[1], rectWidth, rectHeight).
Add_w(opts.BorderSize).
SetStrokingColor(opts.BorderColor).
SetNonStrokingColor(opts.FillColor).
Add_B().
Add_Q()
if opts.BorderSize <= 0 {
opts.BorderSize = 0
opts.BorderColor = model.NewPdfColorDeviceGray(1)
}
if opts.BorderColor == nil {
opts.FillColor = model.NewPdfColorDeviceGray(1)
}
if opts.FillColor == nil {
opts.FillColor = model.NewPdfColorDeviceGray(1)
}
cc.Add_q().Add_re(rect[0], rect[1], rectWidth, rectHeight).
Add_w(opts.BorderSize).SetStrokingColor(opts.BorderColor).
SetNonStrokingColor(opts.FillColor).
Add_B().Add_Q()
// Draw signature.
cc.Add_q()
cc.Translate(rect[0], rect[3]-lineHeight-offsetY)
cc.Add_BT()