While inserting stamp, how to find the stamp instance name?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
ng80092a
User
Posts: 21
Joined: Thu May 13, 2021 11:50 am

While inserting stamp, how to find the stamp instance name?

Post by ng80092a »

While inserting a pdf stamp I have a script that will retrieve the AP identification of the source stamp.

This is easily done by using event.source.stampName.

But what about the name of the stamp instance that is being inserted? I need to identify him in order to change its properties, and not the dynamic text fields only. Is that a possibility?


There isn't really a list of all the properties on the Javascript API, and I'm not sure if this is a possibility even.

Thank you in advance for helping
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17765
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: While inserting stamp, how to find the stamp instance name?

Post by Tracker Supp-Stefan »

Hello ng80092a,

You will need to recognize which is the latest stamp placed, and then using some simple JS like "annot.name" where "annot" is the annotation in question should give you it's name.

This simple script will go through ALL the stamps in a PDF file, and output their unique names in the JS console:

Code: Select all

annots = this.getAnnots();
for (var i = 0; i < annots.length; i++){
	console.println(annots[i].name);
}
Kind regards,
Stefan
ng80092a
User
Posts: 21
Joined: Thu May 13, 2021 11:50 am

Re: While inserting stamp, how to find the stamp instance name?

Post by ng80092a »

Thanks Stefan, but that doesn't work very well, the idea is to change the size of the stamp being inserted.
I did a function that found the last stamp indeed and changes the position of it to half. but this requires a separate tool to work.

What I'm looking for is to change the properties of the stamp that is actively being inserted, with a custom javascript on one of the text field forms of it.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17765
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: While inserting stamp, how to find the stamp instance name?

Post by Tracker Supp-Stefan »

Hello ng80092a,

Stamps can be dynamically scaled when being placed with the mouse, but I am afraid that controlling that via code might be trickier.
Is the "scale" to which you want to set the size of that stamp relatively 'fixed' ? Maybe it would be easier if you have stamps with different sizes for the respective occasions?

Kind regards,
Stefan
ng80092a
User
Posts: 21
Joined: Thu May 13, 2021 11:50 am

Re: While inserting stamp, how to find the stamp instance name?

Post by ng80092a »

Not really, because it depends on the page size. That would generate a lot of stamps that are the same, and it would be difficult and clumsy at least to choose the right stamp for the paper size.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8371
Joined: Wed Jan 03, 2018 6:52 pm

Re: While inserting stamp, how to find the stamp instance name?

Post by TrackerSupp-Daniel »

Hi, ng80092a

In any case, unfortunately this is not something that could be controlled on placement via Javascript alone. This is because the stamp itself is a separate PDF document, and the JS contained within is generally limited to affecting its own fields and their content, it would not have the ability to dynamically change the document page size and scale the content to a varying degree after checking outside factors like the other currently in use page size.

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Post Reply