Ask Your Question
0

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

asked 2019-01-31 11:59:31 +0200

BinoyCherian gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-01-31 13:00:13 +0200

updated 2019-01-31 13:17:00 +0200

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("com.sun.star.frame.DispatchHelper")

  ' Using arguments skips dialog and allows direct insertion of the watermark '
  Dim args(4) As New com.sun.star.beans.PropertyValue
  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.

edit flag offensive delete link more

Comments

I am accepting this answer because it looks promising :)

BinoyCherian gravatar imageBinoyCherian ( 2019-01-31 13:59:17 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-31 11:59:31 +0200

Seen: 28 times

Last updated: Jan 31