Custom stamps inserted via javascript

The PDF-XChange Viewer for End Users
+++ FREE +++

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

gjblack71
User
Posts: 1
Joined: Thu Jan 01, 1970 12:00 am

Custom stamps inserted via javascript

Post by gjblack71 »

Hello, I am trying to insert custom stamps using javascript and this code from the
JavaScript ™ for Acrobat ® API Reference. I have the PRO version of the reader.

var annot = this.addAnnot({
page: 0,
type: "Stamp",
author: "A. C. Robat",
name: "myStamp",
rect: [400, 400, 550, 500],
contents: "Try it again, this time with order and method!",
AP: "NotApproved" });
app.execMenuItem("Save", this);
this.closeDoc(true);

This code works fine for the built-in stamps, but if I change
the "NotApproved" to the name of my custom stamp I get an empty?? stamp included. (Can select it and see comments etc, but no picture.)

Is this possible with custom stamps? If not, is it possible to replace the built-in ones?

Thanks, Graham
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19930
Joined: Mon Jan 12, 2009 8:07 am

Re: Custom stamps inserted via javascript

Post by Stefan - PDF-XChange »

Hello gjblack71,

I am afraid that you will need to use the name as it is stored in the names dictionary inside the collection of custom stamps.
And those names are generated by the Viewer.

For my custom stamps (located in C:\Documents and Settings\<<username>>\Application Data\Tracker Software\PDF-XChange Viewer\2.0\Stamps) the name dictionary looks like this:

Code: Select all

/Names [
(5147f1bc-3233-49ff-8499861861e343fe=New Stamp) 10 0 R 
(553dedf5-1c15-4030-843ea7ee3bdc8e4c=Stefan_signature) 7 0 R 
(6ec93fec-78ae-4b9a-b61cd936823b7955=test_2) 6 0 R 
(75dc5b36-0f59-4e6a-8a7decb6777cc38b=green_thick) 11 0 R 
(ada7e9b5-8374-4e75-84cdec12c50a7c76=untitled) 9 0 R 
(c2fc3b73-9950-4b5f-918834cc2a06c039=New Stamp) 12 0 R
]
So to place my own signature (the second record in there: Stefan_signature) I need to use this:

Code: Select all

var annot = this.addAnnot({
page: 0,
type: "Stamp",
author: "My Name",
name: "Stefan_Stamp",
rect: [100, 600, 300, 800],
contents: "Try it again, this time with order and method!",
AP: "553dedf5-1c15-4030-843ea7ee3bdc8e4c"
});