I have worked out a script to take data from a calc file and use that to alter a writer file and export it to a PDF. I need to modify this script to add a text watermark using the Format > Watermark functionality. How can I do that?
Current version of the script follows:
Dim path As String
Dim PTGuideDoc As Object
Dim PTListDoc As Object
Dim PTListSheet as Object
Dim PTLIDCell as Object
Dim PTLNameCell as Object
Dim rg as Object
Dim uR as LongDim args()
Dim PDFargs(0) As New “com.sun.star.beans.PropertyValue”
PDFargs(0).Name = “FilterName”
PDFargs(0).Value = “writer_pdf_Export”path = ConvertToUrl("/home/wrg/Downloads/myDoc.odt") PTGuideDoc = StarDesktop.loadComponentFromURL(path, "default", 0, args()) path = ConvertToUrl("/home/wrg/Downloads/listing.ods") PTListDoc = StarDesktop.loadComponentFromURL(path, "default", 0, args()) PTListSheet = PTListDoc.Sheets(0) PTListRanage = PTListSheet.getCellRangeByName("A2:C251")
uR = PTListRanage.Rows.Count - 1
For r = 1 To uR
PTLIDCell = PTListSheet.getCellByPosition(0,r)
PTLNameCell = PTListSheet.getCellByPosition(1,r)If PTLNameCell.String <> "" Then if PTGuideDoc.getTextFieldMasters.hasByName("com.sun.star.text.fieldmaster.SetExpression.WhoFor") then oVar = PTGuideDoc.getTextFieldMasters.getByName("com.sun.star.text.fieldmaster.SetExpression.WhoFor") oVar.DependentTextFields(0).content = PTLNameCell.String else msgbox "WhoFor not found" end if if PTGuideDoc.getTextFieldMasters.hasByName("com.sun.star.text.fieldmaster.SetExpression.WhoForID") then oVar = PTGuideDoc.getTextFieldMasters.getByName("com.sun.star.text.fieldmaster.SetExpression.WhoForID") oVar.DependentTextFields(0).content = PTLIDCell.String else msgbox "WhoForID not found" end if REM code to alter text watermark in ODT file. path = ConvertToURL("/home/wrg/myPDF_ED_"+PTLIDCell.String+").pdf") PTGuideDoc.storeToURL(path, PDFargs()) End If
Next r
PTListDoc.close(True)
PTGuideDoc.close(True)