"Printing" text output to PDF with watermark in batch mode: is this possible?


New here, so forgive me if this has been covered with completely different keywords :slight_smile:
I did search for it and found nothing quite matching.

I have a requirement to “print” invoices from a system, overlaying text lines onto a standard “stationery” file (perhaps as a watermark).  

Is this possible with PDFForge, either as command-line or via COM?

If so, what format does the background need to be: PDF?  Image?  PS?




I do the exact same thing for my invoices printed from MS Word along with all my formal letters on letterhead. I use a PDF of my letterhead but the same can be achieved with an image too.

OK, but how do you do it?

I can’t figure it out from the docs… how can you specify this on command-line or in COM?

I use the “Action after saving” to run a script when printing to PDFCreator. Can you run a script by command-line or via COM? I don’t have experience with running PDFCreator this way, sorry.


you can use the AddWatermarkToPDF.vbs script (the watermark needs to be a PDF file) in “Actions after saving”. You will need PDFTK and to tell the script where you installed it and where your PDF file for the watermark is. This will cause PDFCreator to add this watermark to any PDF as long as the option is selected. This can not be setup in the command-line, but will apply to ducuments printed via command line or COM.
You can set the action after saving via COM but the easiest way is configuring it once in the options.
(Public RunProgramAfterSaving As Long
Public RunProgramAfterSavingProgramParameters As String
Public RunProgramAfterSavingProgramname As String
Public RunProgramAfterSavingWaitUntilReady As Long
Public RunProgramAfterSavingWindowstyle As Long)



Here is my script for doing this without PDFTK

Option Explicit

Const Watermark = "\\Server\AppData\DFKRH Letterhead.pdf"

Dim objArgs, fname, tfname, fso, pdf

Set objArgs = WScript.Arguments

fname = objArgs(0)

Set fso = CreateObject(“Scripting.FileSystemObject”)

tfname = fso.GetTempName

Set pdf = WScript.CreateObject(“pdfforge.pdf.pdf”)

pdf.StampPDFFileWithPDFFile fname, tfname, Watermark, 1, 1, false, 1, 10

If fso.FileExists(tfname) Then
fso.MoveFile tfname, fname
MsgBox “There was an error adding the Watermark!”, vbCritical, AppTitle
End If

Set pdf = Nothing
Set fso = Nothing
Set objArgs = Nothing