vbapdffontscolors

pdf page number font color using addwatermarkfromtext


I have a question regarding inserting page numbers in a pdf file using addwatermarkfromtext but at the same time change the font color of the page number. I am using the following code to insert the page number and that is working very well. Searching the internet I should be able to insert a line with "aColor:=color.red" but that is not working and the code will return an error. Does anyone know how to change the standard font color (black) to another color??

for i=1 to 10
jso.addWatermarkFromText _
            cText:=Str(i) , _
            cFont:="Arial", _
            nFontSize:=9, _
            nTextAlign:=1, _
            nHorizAlign:=2, _
            nVertAlign:=4, _
            nVertValue:=24, _
            nHorizValue:=-48, _
            nStart:=i - 1, _
            nEnd:=i - 1
next i

Thanks!


Solution

  • According to the docs the format for color information is more complex than you suggest. It needs a color type then value. Quote:

    For example, the color red can be represented as ["RGB", 1, 0, 0]

    So I guess you want something more like

    aColor:=["RGB", 1, 0, 0]
    

    But that may be for JavaScript. The equivalent in VBA would be something like:

    dim color(0 to 3) as Variant 
    color(0) = "RGB"
    color(1) = 1#
    color(2) = 0#
    color(3) = 0#
    

    then

    aColor=color