Solved

Is there any standalone comand-line tool to put a watermark on a pdf file ?

Posted on 2015-02-02
6
343 Views
Last Modified: 2015-02-02
Hi.

I'm looking for a command-line tool on Windows that I can call from my program that put a customized watermark (from an image I pass it by parameter) to a PDF file (that I would pass also by parameter). Does this exist ?

If not, is there a dll or something like this that I can call it from my PowerBuilder program for doing this?

Thank you.
0
Comment
Question by:gplana
  • 3
  • 2
6 Comments
 
LVL 37

Expert Comment

by:bbao
ID: 40583768
FYI - 5 Tools to Add Watermark or Logo to PDF Files
http://www.aboutonlinetips.com/how-to-add-watermark-to-pdf/

i guess the open source one (http://sourceforge.net/projects/jpdftweak) give you some hints if the source code can be legally accessed and used.
0
 
LVL 37

Expert Comment

by:bbao
ID: 40583769
FYI - 5 Tools to Add Watermark or Logo to PDF Files
http://www.aboutonlinetips.com/how-to-add-watermark-to-pdf/

i guess the open source one (http://sourceforge.net/projects/jpdftweak) may give you some hints if the source code can be legally accessed and used.
0
 
LVL 37

Expert Comment

by:bbao
ID: 40583771
sorry for the repeated post (though a typo fixed).
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 53

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
ID: 40584322
The PDF Toolkit (PDFtk) is an excellent (free!) product that can do it. It comes in both command line and GUI versions. The command line version is called PDFtk Server and may be downloaded here:
http://www.pdflabs.com/tools/pdftk-server/

Don't be misled by "Server" in the name. I don't know why they called it that, but it's just an executable (pdftk.exe, with a supporting DLL, libiconv2.dll) that runs on XP, Vista, W7, and W8 (i.e., it does not have to run on a "server" OS). I don't know PowerBuilder, but as long as it can make a command line call to an EXE, you'll be fine. Here's an EE article showing a call to it in from another programming language (AutoHotkey):
http://www.experts-exchange.com/Web_Development/Document_Imaging/A_11211-How-To-Split-Rename-Move-a-Batch-of-PDF-Files-Based-on-Contents-of-the-Files.html

Look at the Man Page in the <doc> folder and you'll see the background parameter, as follows:
background < background PDF filename | - | PROMPT >

Applies a PDF watermark to the background of a single input PDF. Pass the background PDF’s filename after background like so:

pdftk in.pdf background back.pdf output out.pdf

Pdftk uses only the first page from the background PDF and applies it to every page of the input PDF. This page is scaled and rotated as needed to fit the input page. You can use - to pass a background PDF into pdftk via stdin.

If the input PDF does not have a transparent background (such as a PDF created from page scans) then the resulting background won’t be visible — use the stamp operation instead.
Note the reference to the stamp param — and there's also a multistamp param:
stamp < stamp PDF filename | - | PROMPT >

This behaves just like the background operation except it overlays the stamp PDF page on top of the input PDF document’s pages. This works best if the stamp PDF page has a transparent background.

multistamp < multistamp PDF filename | - | PROMPT >

Same as the stamp operation, but applies each page of the stamp PDF to the corresponding page of the input PDF. If the input PDF has more pages than the stamp PDF, then the final stamp page is repeated across these remaining pages in the input PDF.
Regards, Joe
0
 
LVL 15

Author Closing Comment

by:gplana
ID: 40584338
Excellent. This is exactly what I needed. So on the machine where I have to run this, I have just to copy pdftk.exe and libiconv2.dll inside my application folder? I mean, I don't need to execute the installer that I have downloaded on the link you provided to me?

Thanks.
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40584357
Yes, exactly! Simply put the EXE and the DLL in the folder with your app — no need to run the installer on the target machine. But make sure you're in license compliance:
https://www.pdflabs.com/docs/pdftk-license/

Good luck with your program! Regards, Joe
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question