浏览代码

添加pdf水印

xyxie 4 月之前
父节点
当前提交
11c41b1f44
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      services/file.go

+ 4 - 4
services/file.go

@@ -190,7 +190,7 @@ func GetResourceUrlBySvgImg(imgData string) (resourceUrl string, err error, errM
 func GeneralWaterMarkPdf(pdfPath, waterMarkStr string) (f2 *bytes.Buffer, err error) {
 	onTop := true
 	update := false
-	desc := "fo:SimHei, points:24, col: 0.75 0.75 0.75, scale:1 abs, opacity:0.3"
+	desc := "fo:SimHei, points:38, rot:30, col: 0.75 0.75 0.75, scale:1 abs, opacity:0.3"
 	//fontDir := `C:\Users\123\go\src\eta\eta_api\static`
 	fontDir := `static`
 	font.UserFontDir = fontDir
@@ -256,8 +256,8 @@ func GeneralWaterMarkPdf(pdfPath, waterMarkStr string) (f2 *bytes.Buffer, err er
 
 	fmt.Println("dm.Width", dm.Width, " dm.Height", dm.Height)
 	var sb2 strings.Builder
-	lineSpace := "\n \n \n \n \n \n"
-	rows := 6
+	lineSpace := "\n \n \n"
+	rows := 8
 	for i := 0; i < rows; i++ {
 		sb2.WriteString(targetText)
 		if i < rows-1 {
@@ -266,7 +266,7 @@ func GeneralWaterMarkPdf(pdfPath, waterMarkStr string) (f2 *bytes.Buffer, err er
 	}
 	fmt.Println(sb2.String())
 	wmList := make([]*model.Watermark, 0)
-	wm, tmpErr = api.TextWatermark(sb2.String(), "fo:SimHei, points:38, col: 0.75 0.75 0.75, scale:1 abs, opacity:0.3", onTop, update, types.POINTS)
+	wm, tmpErr = api.TextWatermark(sb2.String(), desc, onTop, update, types.POINTS)
 	if tmpErr != nil {
 		fmt.Println("TextWatermark err:", tmpErr)
 		return