• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic Stamp - Setting Dialog Box Defaults

Guest
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

I found how to set the defaults in a stamp dialog box for text boxes, dropdown boxes, and check boxes, but I cannot find out how to set a default for a radio box.

 

For instance, in the code block below, it's easy to see how the textboxes and dropdown list will have their defaults set. But I have no idea how to do it for the radio boxes. Does anybody know the syntax for this?

var builder = {
    // These map to Text Fields in the Stamp
    textBoxes: [
        { field: "Name", description: "Name:", default: function() { return ""; } },
        { field: "Company Name", description: "Company Name:", default: function() { return ""; } },
    ],
    // This maps to a Popup Group in the PDF named 'Project'
    popupGroup: "Plan Section",
    listItems: [{
        popupItems: {
            //list of items of Popup menu, positive number indicates default selection
            "Civil": +1,
            "Struct": -1,
            "Arch": -1,
            "MEP": -1
        }
    }],
    // This maps to a Radio Group in the PDF named 'Status'
    radioGroup: "Type of Plans",
    radioButtons: [
        // value maps to the 'Choice' of each radio button in the group, description will show on the dialog
        { value: "", description: "Original Plans" },
        { value: "Revised Plans", description: "Revised Plans" },
        { value: "As-Built Plans", description: "As-Built Plans" }
    ],
    radioErrorMsg: "Please select a status"
}

  

TOPICS
Acrobat SDK and JavaScript , Windows

Views

283

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

This isn't dialog box code.  It's a data structure someone designed for a tool that creates the actual dialog box code. To find out how this structure is used to set a radio button default, you need to ask whoever developed the tool.  Where did you get it?

 

A better tool for generating dialog boxes is AcroDialogs:

https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

These forums. Any time anyone is asked where they got it, they say they found it somewhere else in the forums as an example.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

And I understand this isn't the dialog box itself, but rather the code that links the dialog box to the form fields to populate the stamp.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

So then, you also have the tool that converts this data structure into dialog code?  If so then you already have your answer. Look through the tool code to find were and how it sets up the defaults.   

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

This still isn't what I'm asking for.

 

To set the textbox default you add:

default: function() { return ""; }

 

The dropdown list uses a + to set the default, - for non-default.

 

I'm looking for the syntax on how to do it for the radio buttons in this context. There is no documentation that I can find, so someone out there might know based on their experience. If that's not you, please move along.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

You want us to help you use code that you don't share? Maybe you found it in the forums, but you could try being more specific, there are tens of thousands of posts.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

I shared the code. I explained that both the textboxes and dropdowns have methods to set defaults. I showed what part of the code set those defaults. I'm looking for the syntax that allows me to do it for a radio button because there's no documentation (that I can find) for this.

 

Since there's radioGroupradioErrorMsg, and radioButtons, I'm assuming there's something like radioDefault, but I have no way of knowing without either finding documentation or someone who's seen it before. The remainder of the code is irrelevant.

Here are multiple posts that use this:

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2022 Oct 16, 2022

Copy link to clipboard

Copied

LATEST

Well you didn't actually share the important code. You showed the code that specifies the dialog parameters.  The important script for finding out what you want is the script that translates the dialog parameters into the actual dialog code. 

Which was in the second post you linked above. The CreateDialog() function.

 

This  function does not provide an initial value for the radio buttons.  Look at how it defines the initialize() function.  Only text fields and popups have an initial value. 

You could certainly modify this code to include radio buttons. But the whole technique is clunky.  You would be better served by using AcroDialogs to build the dialog code. 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines