How can i get a watermark in my pdf's using LO commandline

I am generating Pdf’s from office files, but I would also like to see if I could configure a watermark and if how how could I passed these parameters to my input file and the LO exe.

Thank you for your support as always.

Version of libreoffice currently being used: 6.0.6 but I might switch to the latest version soon.

Here is a simple code to insert a watermark to current document:

Sub SetWatermark
  Dim document As Object
  Dim dispatcher As Object
  document = ThisComponent.CurrentController.Frame
  dispatcher = createUnoService("")

  ' Using arguments skips dialog and allows direct insertion of the watermark '
  Dim args(4) As New
  args(0).Name = "Text"
  args(0).Value = "Watermark" ' Which text will be shown as the watermark '
  args(1).Name = "Font"
  args(1).Value = "Arial"
  args(2).Name = "Angle"
  args(2).Value = 45 ' Degrees, int '
  args(3).Name = "Transparency"
  args(3).Value = 50 ' Percent, int '
  args(4).Name = "Color"
  args(4).Value = 16711680 ' FF0000 = Red; number only '

  dispatcher.executeDispatch(document, ".uno:Watermark", "", 0, args())
End Sub

Using this macro, and your previous questions to run the macro in a batch, you may try to implement something like that, … but there is a but, even two:

  1. The function is Writer-only, so you can’t use it for other documents;
  2. Setting a watermark adds a header, which may change documents’ layout.

So possibly better use some external post-processing of your PDFs, e.g. like suggested here with pdftk.

I am accepting this answer because it looks promising :slight_smile: