PDF-ShellTools > General

Want To Create Custom Field When Stamping

(1/2) > >>

Amazed:
What great software. This is gonna get the job done. I can feel it. Last part.
When I stamp a document, I want to also create a custom field in that document(if it doesn't already exist) and populate that field with specific data that I determine at the time I apply the stamp.

Also, I want to able to prevent duplicate attempts to apply the same stamp on documents.

If that all makes sense? Could somebody please point me in the right direction?

Thanks.

RTT:
Without more details, I suppose a My Script is the right way to execute this workflow.
Use the stamp tool to create and save the stamp template you want to apply on these files. The script will apply the stamp and populate the custom field, using also a custom field to check if the PDFs are already stamped or not. This custom field may be the same (if the field exists them it was already stamped) you will use to store that specific data you talk about.

Here is a generic sample script around this idea:

--- Code: ---var StampTemplate = "C:\\PDFStampTemplates\\Template1.stp";

var shell = pdfe.CreateObject("WScript.Shell");
var ProgressBar = pdfe.ProgressBar;

ProgressBar.max = pdfe.SelectedFiles.Count;
for (var i = 0; i < pdfe.SelectedFiles.count; i++) {
    ProgressBar.position = i + 1;
    var doc = pdfe.SelectedFiles(i);
    var filename = doc.filename;
    if (!doc.metadata['StampData']) {
        pdfe.echo('Processing ' + filename);
        shell.Run('"' + shell.ExpandEnvironmentStrings("%PROGRAMFILES%") + '\\PDF-ShellTools\\PDFShellTools.exe" stamp -s Template="' + StampTemplate + '" "' + filename + '""', 0, true);
        doc.metadata['StampData'] = 'Your specific data';
        doc.metadata.commitchanges();
        pdfe.echo(' : done', 0, true);
    } else {
        pdfe.echo(filename + ' : already stamped');
    }
}
pdfe.echo('all done');

--- End code ---
This script expects a stamp template at C:\PDFStampTemplates\Template1.stp, and a custom field named "StampData" defined in the list of custom fields.
In this example the stamp is using static data. If your intention is to stamp dynamic data, check this other example.

If you need further help, please give me more details.

Amazed:
^^ Looks like the idea. Thanks. Let me work through that.

Amazed:
Any way to get the current date into the script somehow so i can stuff it in the custom field?

Thanks.

Ignore. Got it, thanks.

Amazed:
How does one hide script output window when script is running please?
Thanks.

Navigation

[0] Message Index

[#] Next page

Go to full version