Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-02-02
6
Medium Priority
?
502 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 56

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 earned 2000 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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

927 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