Print Page | Close Window

Adding watermark with datestamp via JS

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=976
Printed Date: 15 Oct 2019 at 9:48am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Adding watermark with datestamp via JS
Posted By: pickman
Subject: Adding watermark with datestamp via JS
Date Posted: 19 Sep 2013 at 4:33pm
Hello, I'm a self-professed failure when it comes to JavaScript and I need some help with a script.
 
What I'm wanting to do is add a watermark to every page of a scanned, OCR'd document that says:
 
Deposit
mm-dd-yy
 
in the top right corner, offset by about a half an inch from the edge of the page. mm-dd-yy is the current date. I don't want that field to update when anyone opens the document, just the one time I run the script as part of a batch.
 
I have a saved watermark process to do this, but I have to update the date every time and go through a few steps to get it done. I'd like a script so I can add it as part of the batch process that runs the document through OCR, then deletes blank pages (anything where words == 0). I've got the OCR and deleting pages part of the batch down, it's just this javascript that's keeping me down.
 
If anyone can offer some help with this script, I'd really appreciate it.


-------------
Awake, arise, or be forever fallen!



Replies:
Posted By: pickman
Date Posted: 19 Sep 2013 at 5:12pm
I should note, as it stands I've got:
 
this.addWatermarkFromText({
 cText: "Deposit\r//current date code//",
 nTextAlign:app.constants.align.center,
 cFont: "Arial",
 nFontSize:12,
 aColor: color.black,
 nOpacity: 0.25
 nHorizValue: -14, nVertValue: -14
});
I just don't have any clue how to add the current datestamp where I've got //current date code// in the script.


-------------
Awake, arise, or be forever fallen!


Posted By: gkaiseril
Date Posted: 19 Sep 2013 at 6:34pm
You can access the system's date object and format it as needed.
 
var oDate = new Date(); // get the systems date object
var cDate = util.printd("mm-dd-yy", oDate); // format the date string
var cDepositText = "Deposit\r" + cDate; // build deposit string;
this.addWatermarkFromText({
 cText: cDepositText,
 nTextAlign:app.constants.align.center,
 cFont: "Arial",
 nFontSize:12,
 aColor: color.black,
 nOpacity: 0.25,
 nHorizValue: -14, nVertValue: -14
});



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net