Dynamic Stamp with Dialog Not Working

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

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

justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Dynamic Stamp with Dialog Not Working

Post by justhumm »

I have an existing dynamic stamp in Bluebeam that is working the way I expect it to.

form1.png
form2.png
I tried recreating the same stamp (static lines and text), adding in the appropriate form fields, and inserting the same javascript in PDF-XChange, but am not getting any dialog box to popup or any dynamic text/button showing up once the stamp is placed, like I am in Bluebeam.

form3.png
form5.png

Code: Select all

// copied from BLUEBEAM Stamp Code
var builder = 
{
	// These map to Text Fields (Forms) in the Stamp
	textBoxes :
	[
		{ field:"CheckedBy", description:"Checked by:", default:function() { return Collab.user; } },		
		{ field:"Date", description:"Date:", default:function() 
			{  
				var curDate = new Date();
				return (curDate.getMonth() + 1) + "/" + curDate.getDate() + "/" + curDate.getFullYear();
			} 
		}		
	],
	// This maps to a Radio Group in the PDF named 'Status'
	radioGroup : "Status",	
	radioButtons :
	[
		// value maps to the 'Choice' of each radio button in the group, description will show on the dialog
		{ value:"rd1Acc", description:"Accepted" },
		{ value:"rd2Not", description:"Accepted As Noted" },
		{ value:"rd3Rev", description:"Rejected, Revise and Resubmit" },
		{ value:"rd4Rej", description:"Rejected, Unacceptable" },
	],
	radioErrorMsg : "Please select a status"
}
I am using PDF-XChange Editor Plus ( Version 8 ).

Can anyone point out what I'm doing wrong? Thanks!
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11010
Joined: Wed Jan 03, 2018 6:52 pm

Re: Dynamic Stamp with Dialog Not Working

Post by Daniel - PDF-XChange »

Hello, justhumm

It is nothing you are doing wrong, but something Bluebeam is doing wrong. According to the PDF Specification, Stamps MUST be flattened, and cannot remain dynamic after placement. This means that as you place it, when you see the dialog, is the only time you should be able to edit that content. After that point, the dynamic content is lost, and the visual output on the page should be left as is until the stamp is converted to base content.

I am afraid that if you want to change the stamp after placement, you would need to delete the stamp from the page, and reapply the stamp anew to make those changes with the new placement of it.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Re: Dynamic Stamp with Dialog Not Working

Post by justhumm »

Hi, Dan. Perhaps I misspoke.

In Bluebeam, I have a stamp, which I was referring to as dynamic, with predefined form fields:
- (1) group of radio buttons
- (2) text boxes

In Bluebeam, that same stamp also has javascript:

Code: Select all

[pseudocode]
user selects location to place stamp
open a dialog box for user input
---> (1) group of radio buttons
---> (2) text boxes 
when user hits "ok", insert those values into the corresponding for fields
place & flatten the stamp at the specified location
That procedure is working fine in Bluebeam.

I tried the same method in PDF X-Change and I am am not getting a dialog box to select/enter the user values...X-Change is just inserting the blank stamp.

How can I initiate a dialog box and user input for a stamp in PDF X-Change?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19851
Joined: Mon Jan 12, 2009 8:07 am

Re: Dynamic Stamp with Dialog Not Working

Post by Stefan - PDF-XChange »

Hello justhumm,

Looking at your screenshots in the initial post in this topic - the stamp you have should be behaving similarly inside the Editor as well.
You can take a look at this KB article on how you can create new dynamic stamps from scratch:
https://www.pdf-xchange.com/knowledgeba ... nge-Editor

However as you seem to already have the stamp - can you please check whether bluebeam has a folder similar to our
%Appdata%\Tracker Software\PDFXEditor\3.0\Stamps
In that folder you can find any custom stamp collections you have created. And usually it is sufficient for you to just copy the stamp collection and it should work in the Editor as well. I know for sure that Adobe created stamps work perfectly fine with the Editor and vice versa.

If you can send us the whole stamp collection where your BlueBeam stamp resides - we will be happy to check it out for you.

Kind regards,
Stefan
lev
User
Posts: 280
Joined: Fri Apr 11, 2014 1:18 am

Re: Dynamic Stamp with Dialog Not Working

Post by lev »

Hello justhumm ,

Attached is a dynamic stamp you can modify to fit your format. You'll have to import it into your stamp collection. When you import it the check boxes will get stripped out, so you'll have to copy them "by hand". The script lives in the Text3 field (the date). Open the Javascript window and when you place the stamp it'll generate a code. That code will have to replace the code in the script.
My guess is that it'll take a little back and forth to get it to work, so ask questions when they arise.
image.png
Shop Drawing.pdf
You do not have the required permissions to view the files attached to this post.
justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Re: Dynamic Stamp with Dialog Not Working

Post by justhumm »

Hi, Stefan. I imported the bluebeam stamp (pdf) into the xchange using the "Add New ---> Add New Stamp From File..." command on the Stamps Palette.

No joy...no dialog pop-up. No values inserted into the form fields.

I'm attaching the bluebeam stamp file. And also the post-import xchange stamp file.

It would be great if you could point out why the dialog box and form fields are not working in xchange.

DK Shop Dwg Rev-testing - Copy.pdf
af74f9be-c65c-4a54-8a540c269396682c.pdf
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11010
Joined: Wed Jan 03, 2018 6:52 pm

Re: Dynamic Stamp with Dialog Not Working

Post by Daniel - PDF-XChange »

Hello, justhumm

It seems that your stamp is working as intended here, however, you have used the incorrect method for import.
To bring this stamp into our Editor, please close the Editor, then open the windows file explorer, and place the file into one of the two following location (Note that if these are not present, you will need to create the "Stamps" folder at the end of these paths:

Code: Select all

C:\Program Files\Tracker Software\PDF Editor\Stamps
~~ or ~~
%appdata%\Tracker Software\PDFXEditor\3.0\Stamps
Simply place the DK shop pdf file you pulled from bluebeam into one (not both) of these locations, and then restart the editor:
image.png
The stamp will immedaitely appear the stamps dropdown, and should be fully usable:
image(1).png
Kind regards,
You do not have the required permissions to view the files attached to this post.
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Re: Dynamic Stamp with Dialog Not Working

Post by justhumm »

Hi, Dan. I'm still experiencing issues.

I followed the procedure that you noted. And the new stamp was available was available in the pallette.

When I clicked on a page to place the stamp, the javascript console popped up with "ReferenceError: builder is not defined".

And stamp placement window is frozen...I can repeat placing the stamp (which causes another error), but I can not "ESC" out of it.

Any more insights into what I'm doing wrong?

stamperror.png
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11010
Joined: Wed Jan 03, 2018 6:52 pm

Re: Dynamic Stamp with Dialog Not Working

Post by Daniel - PDF-XChange »

Hello, justhumm

It may be that some of the JS in use is not supported back in V8. That version is a few years out of date now, and we have expanded our Js support in recent versions, which would explain why I see not issues here in V10 with this stamp.
I will need to suggest that your update the software (the stamps will remain in the same folder/location when you do so, no need to worry about that).

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Re: Dynamic Stamp with Dialog Not Working

Post by justhumm »

Thanks for the reference, lev!

Question time...

I am new to javascript and would like to place user input text boxes (for a custom name or custom date) into the dialog window.

moron1.png
Can you point me to a good reference for that?

And do you happen to know what version of javascript () this conforms to?

...is it closer to ECMAScript than the latest javascript?

Cheers!

Code: Select all

console.println("Shop Drawing Stamp:" + event.source.stampName);


// ========== DEFINE RADIO BUTTONS IN DIALOG BOX ==========
var DiaBox = {
	result: "cancel",
	DoDialog: function() {
		return app.execDialog(this);
	},
    
	bChk1: false,
	bChk2: false,
	bChk3: false,
	bChk4: false,
	stredt1: "",
	
	initialize: function(dialog) {
		var dlgInit = {
			"Opt1": this.bChk10,
			"Opt2": this.bChk11,
			"Opt3": this.bChk12,
			"Opt4": this.bChk13,
			};
		
		dialog.load(dlgInit);
		},

	commit: function(dialog) {
		var oRslt = dialog.store();
		this.bChk1 = oRslt["Opt1"];
		this.bChk2 = oRslt["Opt2"];
		this.bChk3 = oRslt["Opt3"];
		this.bChk4 = oRslt["Opt4"];
		},

	description: {
		name: "Shop Drawing Stamp",
		elements: [{
			type: "view",
			elements: [{
				type: "view",
				char_height: 10,
				elements: [{
					type: "static_text",
					item_id: "stat",
					name: "Select Review Status:",
					width: 152,
					height: 23,
					char_width: 15,
					alignment: "align_fill",
					font: "dialog",
					},
					{
						type: "radio",
						item_id: "Opt1",
						group_id: "grpStatus",
						name: "Accepted",
						},
					{
						type: "radio",
						item_id: "Opt2",
						group_id: "grpStatus",
						name: "Accepted As Noted",
						},
					{
						type: "radio",
						item_id: "Opt3",
						group_id: "grpStatus",
						name: "Rejected, Revise & Resubmit",
						},
					{
						type: "radio",
						item_id: "Opt4",
						group_id: "grpStatus",
						name: "Not Accepted",
						},
					]
					},
					{
						type: "gap", //Add a small vertical gap between
						height: 10 //..radio buttons and text boxes
						},
					{
						type: "gap", //Add a small vertical gap between
						height: 10 //..text boxes and OK-button
						},
					{
						type: "ok_cancel",
						},
					]
			}, ]
		}
	};
	
// ========== END RADIO BUTTONS IN DIALOG BOX ==========	

// if (event.source.forReal && (event.source.stampName == "stmpReview")) {
if (event.source.forReal && (event.source.stampName == "zAE5xDHAZ4wenFX3zDi8h0")) {
    if ("ok" == app.execDialog(DiaBox)) {
        
		
		// ---------------------------------------------------
		// insert checkbox states into form/radio buttons
		// ---------------------------------------------------
		this.getField("fmBx10").checkThisBox(0, DiaBox.bChk1);
		this.getField("fmBx11").checkThisBox(0, DiaBox.bChk2);
		this.getField("fmBx12").checkThisBox(0, DiaBox.bChk3);
		this.getField("fmBx13").checkThisBox(0, DiaBox.bChk4);

		// ---------------------------------------------------
		// Default textbox values
		// ---------------------------------------------------
		strReviewer = "Some Moron";
		strDate = "Now, damnit!";

		// ---------------------------------------------------
		// insert default text strings into form fields
		// ---------------------------------------------------
		this.getField("fmTxBy").value = strReviewer;

		console.println("Success1");
		// ---------------------------------------------------
		// insert date into form field
		// ---------------------------------------------------
		// cMsg = util.printd("dd mmm yyyy", new Date());
		event.value = strDate;
		event.source.source.info.exhibit = strDate;

		}

}
You do not have the required permissions to view the files attached to this post.
lev
User
Posts: 280
Joined: Fri Apr 11, 2014 1:18 am

Re: Dynamic Stamp with Dialog Not Working

Post by lev »

justhumm,

My knowledge of JavaScript is pretty much non-existent. I cobbled the stamp together a few years ago by gleaning what I could from the Internet.
For an input box take a look at a script provided by Matthew:
viewtopic.php?p=172526&hilit=tool#p172526
The version of JavaScript is a question for the moderators.

Best of luck!
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11010
Joined: Wed Jan 03, 2018 6:52 pm

Re: Dynamic Stamp with Dialog Not Working

Post by Daniel - PDF-XChange »

Hello,

Most of us on the support team are in a similar spot, the only ones fully equipped to write JS from scratch would be our Dev team, and they generally do not have the time to do so. As such we typically can only offer help troubleshooting a script which should work, but has some small out of place error happening.

We make use of the JS standards for PDF put out by Adobe, so you can find documentation about its implementation here: https://opensource.adobe.com/dc-acrobat ... croJS.html

If you have any specific questions, you can ask here, but there may be a delay in reply as we will often need one of the Dev team members assistance.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
justhumm
User
Posts: 7
Joined: Wed Mar 13, 2024 5:39 pm

Re: Dynamic Stamp with Dialog Not Working

Post by justhumm »

Thanks, lev.

The thread that you posted would be a neat thing to have, but it was giving me errors when I tried to use it...probably owing to a different javascript version (I have). So, when I had time, I might putz around with it to see if I can get it running on my machine.

HOWEVER...

I did try stealing a text box definition from the add-on code and that worked. So I have to see how to implement that to get the functionality that I'd want to have. :-)

dialog.png

Code: Select all

console.println("Shop Drawing Stamp:" + event.source.stampName);


// ========== DEFINE RADIO BUTTONS IN DIALOG BOX ==========
var DiaBox = {
	result: "cancel",
	DoDialog: function() {
		return app.execDialog(this);
	},
    
	bChk1: false,
	bChk2: false,
	bChk3: false,
	bChk4: false,
	stredt1: "",
	
	initialize: function(dialog) {
		var dlgInit = {
			"Opt1": this.bChk10,
			"Opt2": this.bChk11,
			"Opt3": this.bChk12,
			"Opt4": this.bChk13,
			};
		
		dialog.load(dlgInit);
		},

	commit: function(dialog) {
		var oRslt = dialog.store();
		this.bChk1 = oRslt["Opt1"];
		this.bChk2 = oRslt["Opt2"];
		this.bChk3 = oRslt["Opt3"];
		this.bChk4 = oRslt["Opt4"];
		},

	description: {
		name: "Shop Drawing Stamp",
		elements: [{
			type: "view",
			elements: [{
				type: "view",
				char_height: 10,
				elements: [{
					type: "static_text",
					item_id: "stat",
					name: "Select Review Status:",
					width: 152,
					height: 23,
					char_width: 15,
					alignment: "align_fill",
					font: "dialog",
					},
					{
						type: "radio",
						item_id: "Opt1",
						group_id: "grpStatus",
						name: "Accepted",
						},
					{
						type: "radio",
						item_id: "Opt2",
						group_id: "grpStatus",
						name: "Accepted As Noted",
						},
					{
						type: "radio",
						item_id: "Opt3",
						group_id: "grpStatus",
						name: "Rejected, Revise & Resubmit",
						},
					{
						type: "radio",
						item_id: "Opt4",
						group_id: "grpStatus",
						name: "Not Accepted",
						},
					]
					},
					{
						type: "gap", //Add a small vertical gap between
						height: 10 //..radio buttons and text boxes
						},
					{
						// Text box for user input
						type: "edit_text",
						item_id: "txBy",
						alignment: "align_fill",
						width: 300,
						//height: 20
						},
					{
						type: "gap", //Add a small vertical gap between
						height: 10 //..text boxes and OK-button
						},
					{
						type: "ok_cancel",
						},
					]
			}, ]
		}
	};
	
// ========== END RADIO BUTTONS IN DIALOG BOX ==========	

// if (event.source.forReal && (event.source.stampName == "stmpReview")) {
if (event.source.forReal && (event.source.stampName == "zAE5xDHAZ4wenFX3zDi8h0")) {
    if ("ok" == app.execDialog(DiaBox)) {
        
		
		// ---------------------------------------------------
		// insert checkbox states into form/radio buttons
		// ---------------------------------------------------
		this.getField("fmBx10").checkThisBox(0, DiaBox.bChk1);
		this.getField("fmBx11").checkThisBox(0, DiaBox.bChk2);
		this.getField("fmBx12").checkThisBox(0, DiaBox.bChk3);
		this.getField("fmBx13").checkThisBox(0, DiaBox.bChk4);

		// ---------------------------------------------------
		// Default textbox values
		// ---------------------------------------------------
		strReviewer = "Some Moron";
		strDate = "Now, damnit!";

		// ---------------------------------------------------
		// insert default text strings into form fields
		// ---------------------------------------------------
		this.getField("fmTxBy").value = strReviewer;

		console.println("Success1");
		// ---------------------------------------------------
		// insert date into form field
		// ---------------------------------------------------
		// cMsg = util.printd("dd mmm yyyy", new Date());
		event.value = strDate;
		event.source.source.info.exhibit = strDate;

		}

}
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19851
Joined: Mon Jan 12, 2009 8:07 am

Re: Dynamic Stamp with Dialog Not Working

Post by Stefan - PDF-XChange »

Hello justhumm,

Glad to hear that the code you've borrowed works for you!
To be able to confirm it is the version of the Editor causing issues - you can try to download a portable copy of the Editor (latest version) and test with that on your machine. That way everything else will be equal and only the Editor version will not be the same, and if you then have issues with your stamp in the installed Editor but not in the portable one - you will know the issue is not in the script itself.

When downloading the portable you would need to put a copy of your
%Appdata%\Tracker Software\PDFXEditor\3.0\Stamps folder in the main directory where the portable .exe is located.

Kind regards,
Stefan