This commit is contained in:
蒋海成 2025-03-12 20:56:50 +08:00
parent 1ae5df7386
commit cdf8cdcb08

View File

@ -156,50 +156,51 @@ func InsertSignatureV1(templatePath, outputPath, signImgPath, companyImgPath, co
// 写 buyer info
pdf.SetPage(buyerPage)
pdf.SetX(145)
pdf.SetY(134)
pdf.SetX(149)
pdf.SetY(127)
pdf.Cell(nil, contractNo)
pdf.SetX(145)
pdf.SetY(159)
pdf.SetX(149)
pdf.SetY(152)
pdf.Cell(nil, time.Now().Format("2006-01-02"))
pdf.SetX(180)
pdf.SetY(207)
pdf.SetY(203)
pdf.Cell(nil, buyerName)
pdf.SetX(210)
pdf.SetY(232)
pdf.SetY(229)
pdf.Cell(nil, idNo)
pdf.SetX(200)
pdf.SetY(257)
pdf.SetY(256)
pdf.Cell(nil, telNum)
pdf.SetX(200)
pdf.SetY(283)
pdf.SetY(282)
pdf.Cell(nil, address)
// 填 金额
pdf.SetPage(pricePage)
pdf.SetX(379)
pdf.SetY(639)
pdf.SetX(380)
pdf.SetY(626)
// 保留整数
pdf.Cell(nil, strconv.FormatFloat(float64(price), 'f', 0, 32))
//pdf.Cell(nil, strconv.FormatFloat(float64(price), 'f', 0, 32))
pdf.Cell(nil, strconv.FormatFloat(float64(price/10000.0), 'f', -1, 32))
// 写 有效期
t := time.Now().AddDate(int(contractDuration), 0, 0)
pdf.SetPage(limitTimePage)
pdf.SetX(327)
pdf.SetY(358)
pdf.SetX(317)
pdf.SetY(327)
pdf.Cell(nil, t.Format("2006"))
pdf.SetX(420)
pdf.SetY(358)
pdf.SetX(398)
pdf.SetY(327)
pdf.Cell(nil, t.Format("01"))
pdf.SetX(486)
pdf.SetY(358)
pdf.SetX(456)
pdf.SetY(327)
pdf.Cell(nil, t.Format("02"))
// 只在目标页插入签名
@ -238,14 +239,14 @@ func InsertSignatureV1(templatePath, outputPath, signImgPath, companyImgPath, co
newSignHeight := (newSignWidth / float64(signImgw)) * float64(signImgh)
// buyer sign
err = pdf.ImageByHolder(imgH1, 180, 560, &gopdf.Rect{W: newSignWidth, H: newSignHeight})
err = pdf.ImageByHolder(imgH1, 175, 540, &gopdf.Rect{W: newSignWidth, H: newSignHeight})
if err != nil {
fmt.Printf("插入签名失败: %v\n", err)
return errors.New("error inserting signature")
}
pdf.SetX(320)
pdf.SetY(585)
pdf.SetX(365)
pdf.SetY(560)
pdf.Cell(nil, time.Now().Format("2006-01-02"))
companyImgResp, companyImageErr := http.Get(companyImgPath)
@ -282,14 +283,14 @@ func InsertSignatureV1(templatePath, outputPath, signImgPath, companyImgPath, co
newCompanyHeight := (newCompanyWidth / float64(companyImgw)) * float64(companyImgh)
// seller sign
err = pdf.ImageByHolder(companyImgH1, 180, 610, &gopdf.Rect{W: newCompanyWidth, H: newCompanyHeight})
err = pdf.ImageByHolder(companyImgH1, 175, 590, &gopdf.Rect{W: newCompanyWidth, H: newCompanyHeight})
if err != nil {
fmt.Printf("插入公司章失败: %v\n", err)
return errors.New("error inserting signature")
}
pdf.SetX(320)
pdf.SetY(635)
pdf.SetX(365)
pdf.SetY(607)
pdf.Cell(nil, time.Now().Format("2006-01-02"))
// 生成新的 PDF