Dynamic stamp file 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
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Dynamic stamp file name

Post by Evie »

Hi,

I have a question about dynamic stamps. I have created a dynamic stamp with a text box, like they did in this video;

https://www.youtube.com/watch?v=qOALVMeasKY

I used this code to get the first part of the file name in the text box;
var fileName = this.documentFileName;
var firstPart = fileName.split('_')[0];
event.value = firstPart;
The code works for the file I made it in, but when I use the stamp in a different file it still returns the file name of the file I created the stamp in. Can anyone help me with how I can make the stamp working for all documents?

Best regards,
Evie
User avatar
Dimitar - Tracker Supp
Site Admin
Posts: 1797
Joined: Mon Jan 15, 2018 9:01 am

Re: Dynamic stamp file name

Post by Dimitar - Tracker Supp »

Hi Evie,

Welcome to our forum.

Can you provide us with a copy of the stamp file you created, if possible?

Regards.
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi,

I have now included the file, I hope this is what you requested.

Best regards,
Evie
1805547d-3c03-4a28-b83bf60322b0e4ab.pdf
(2.09 MiB) Downloaded 10 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Dynamic stamp file name

Post by Tracker Supp-Stefan »

Hello Evie,

Please try with
var fileName = event.source.documentFileName;

When you are using "this" - you get the name of the file where that code is located - your stamp collection.
When using the event.source - you get the name of the file in which that event was triggered - your target document

Kind regards,
Stefan
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi Stefan,

So that means the new code is
var fileName = event.source.documentFileName;
var firstPart = fileName.split('_')[0];
event.value = firstPart;
is that correct?
Because when I use that code, I get the following error; \Console:Exec:1: TypeError: event.source is null.
Can you tell me what I did wrong?

Best regards,
Evie
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Dynamic stamp file name

Post by Tracker Supp-Stefan »

Hello Evie,

Can you please share with us the stamp collection that you are creating - not just the file with the stamp already placed on it?
I'd like to take a look at that stamp and the code inside of it and should be able to advise further after that.

Kind regards,
Stefan
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi Stefan,

How do I share that?

Best regards,
Evie
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6903
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Dynamic stamp file name

Post by Paul - Tracker Supp »

Hi, Evie

There are two places the stamps are stored, per machine and per user locations. See here for details: https://www.pdf-xchange.com/knowledgeba ... ers-to-use

You can just copy the PDF n the stamps folder and send it to us:
image.png
Kind regards,
Paul - Tracker Supp
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi,

This is the file I made for the stamp, but this is the same one I shared earlier. So I might have done it wrong.

Best regards,
Evie
1805547d-3c03-4a28-b83bf60322b0e4ab.pdf
(2.09 MiB) Downloaded 2 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Dynamic stamp file name

Post by Tracker Supp-Stefan »

Hello Evie,

Apologies - I saw the file with the background and I thought that this was a file where you've already placed the stamps.
Turns out you would actually need event.source.source.documentFileName.
Please check the attached updated copy of your file (place it in your %Appdata%\Tracker Software\PDFXEditor\3.0\Stamps folder).
The first field would now correctly display the name of the target file when you use that stamp over another document opened in the Editor.

Kind regards,
Stefan
Attachments
sample.pdf
(2.09 MiB) Downloaded 4 times
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi Stefan,

No worries. I have copied the file you send to the right place, but when I place the stamp on another document it still returns the name of the stamp document.
I also have another question about the stamp. I have now made de stamp om the picture, but I would like the stamp to be only the text box. Is that possible? I did see the option to make a stamp out of the part you selected, is that the right way?

Best regards,
Evie
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Dynamic stamp file name

Post by Tracker Supp-Stefan »

Hello Evie,

Yes - you can customize your stamp and remove anything but the form field if that is all you want!
Please find attached a new sample of your stamp.

Please place that in
%Appdata%\Tracker Software\PDFXEditor\3.0\Stamps
Then restart the Editor and after that try to actually use the stamp in a document.

The initial preview would indeed show you the long string text, however once you place that on the document's page - it should display the correct document name!

This is the preview for me:
image.png
And this is the result once the stamp is actually placed on the page:
image(1).png


Kind regards,
Stefan
Attachments
sample.pdf
(5.16 KiB) Downloaded 4 times
Evie
User
Posts: 15
Joined: Mon Mar 18, 2024 3:25 pm

Re: Dynamic stamp file name

Post by Evie »

Hi Stefan,

It works now, thank you so much for your help!

Best regards,
Evie
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Dynamic stamp file name

Post by Tracker Supp-Stefan »

:)
Post Reply