How to integrate a print date and time field on every page of a PDF document?

Hello,

I tested your addjs2pdf.exe command line tool because I like to integrate a print date and time field on every page of a document. I found your javascript code example here:

http://www.verypdf.com/wordpress/201408/add-current-date-time-to-pdf-when-printed-40947.html

But it doesn't work for me. (see attached pdf-File and the used Javascript in js.txt). Is this may be because it's a trial software? Thank you!

with best regards
Customer
-------------------------------------------------------

image

You can download "VeryPDF Javascript to PDF Embedder Command Line" from this web page,

http://www.verypdf.com/app/javascript-to-pdf-embedder-cmd/index.html
http://www.verypdf.com/dl2.php/addjs2pdf_win.zip

You can use attached "js-add-datetime.txt" file to insert dynamic date time to PDF pages properly.

In your Javascript code, you need change "bOnScreen" option to TRUE, like below parameters,

var cMyText = "copyright \xa9 " + dateString;
this.addWatermarkFromText({
cText: cMyText,
nFontSize:30,
nHorizAlign:app.constants.align.left,
nHorizValue: 36, // 1/2 inch from left
nVertAlign:app.constants.align.bottom,
nVertValue: 18,
aColor: color.red,
bOnScreen: true, //Please set this option to true in order to show watermark on pages
});

Please see the full Javascript source code at below,

this.addWatermarkFromText({
    cText: "Show ME on Printout",
    nTextAlign:app.constants.align.center,
    cFont: "Helvetica-Bold",
    nFontSize:72,
    aColor: color.blue,
    nStart: this.pageNum,
    nOpacity: 0.5,
    bOnScreen: false,
    nRotation: 45
});

var date = new Date();
var month = (date.getMonth()+1) > 9 ? (date.getMonth()+1) : "0" + (date.getMonth()+1);
var day = (date.getDate()) > 9 ? (date.getDate()) : "0" + (date.getDate());
var hours = (date.getHours()) > 9 ? (date.getHours()) : "0" + (date.getHours());
var minutes = (date.getMinutes()) > 9 ? (date.getMinutes()) : "0" + (date.getMinutes());
var seconds = (date.getSeconds()) > 9 ? (date.getSeconds()) : "0" + (date.getSeconds());

var dateString =
    month + "/" +
    day + "/" +
    date.getFullYear() + " " +
    hours + ":" +
    minutes + ":" +
    seconds;

var cMyText = "copyright \xa9 " + dateString;
this.addWatermarkFromText({
    cText: cMyText,
    nFontSize:30,
    nHorizAlign:app.constants.align.left,
    nHorizValue: 36, // 1/2 inch from left
    nVertAlign:app.constants.align.bottom,
    nVertValue: 18,
    aColor: color.red,
    bOnScreen: true,
});

this.dirty = false;

VeryPDF

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Random Posts

This entry was posted in VeryPDF SDK & COM and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!