|
楼主 |
发表于 2024-7-8 20:14
来自手机
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lss001 于 2024-7-9 12:50 编辑
Sub 添加文本水印() ' 支持中文水印
Set AcroApp = CreateObject("Acroexch.app")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
Set AForm = CreateObject("AFormAut.App")
' '中文水印
' arr = Evaluate("Mid(""您好,世界!"",ROW(A1:A6),1)")
' w = ""
' For i = 1 To UBound(arr)
' w = w & "\u" & Hex(AscW(arr(i, 1)))
' Next
' ’英文水印
w = "hello world!"
AcroApp.CloseAllDocs
If AcroAVDoc.Open(ThisWorkbook.Path & "\num.pdf", "") Then
Set AcroPDDoc = AcroAVDoc.GetPDDoc
AForm.Fields.ExecuteThisJavascript _
"this.addWatermarkFromText(""" & w & """, 0, ""SimSun"", 24, color.red, 0, 0);"
End If
AcroPDDoc.Save 1, ThisWorkbook.Path & "\newnum.pdf"
Set AForm = Nothing
Set AcroPDDoc = Nothing
Set AcroAVDoc = Nothing
Set AcroApp = Nothing
End Sub |
|