[tool] Auto-Complete on text form fields

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

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

Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

[tool] Auto-Complete on text form fields

Post by Mathew »

This tool adds a dropdown suggestion list for text fields, similar in concept to what shows for many web forms. Please post a reply if you have suggestions or find bugs. There's a feature request for a built-in autocomplete viewtopic.php?p=196719#p196719 but until then...


Installation
Download the zip file, extract and copy to the Javascripts folder, and restart PDF Change. See viewtopic.php?p=196006#p196006 for more detailed instructions.
autocompleteDD v1.3.zip


Features
  • When enabled, it will remember anything typed into text fields, and offer that in future suggestions.
  • Document specific autocompletes: If there is a list of possible autocompletes that are specific to a document, those can be saved with that document.
  • Default autocompletes: A list of default autocomplete values can be saved either in the application folder, or in the user settings folder.
  • The tool can be switched off generally and enabled on a document as needed.
Usage
The tool adds three items to the Forms ribbon or menu:
image.png
When one starts typing in a form text field, it will offer a list of past form field entries that include the text typed so far. Click on one of the suggestions to fill that into the form field:

Using a popup menu: (default setting - shows wherever the mouse pointer is)
image(3).png
Using a form listbox: (shows immediately below the form field)
image(2).png
When the tool is first installed, unless a list of default autocompletes has also been installed, there won't be any saved values; either edit the saved values list, or use the tool entering data into form fields.

Autocomplete Settings
image(1).png
  • Start autocomplete when application starts starts a background interval that checks any open documents for text fields every half second. If it finds text fields, it adds a Keypress action to offer text suggestions as you type in the field. Turn this off to stop the tool from running automatically.

    Max autocomplete rows limits the number of rows of suggestions to offer

    Use a Form Listbox if checked it will temporarily add a dropdown form element below the active text field. Watch out: If you don't have a registered copy of PXCE Plus, you may get watermarks on the document if you use this option! By default, it's unchecked, and you'll get a popup menu wherever the mouse pointer currently is.

    Form Appearance This is the appearance of the form dropdown.
    • Color… opens a separate dialog to edit the colors used in the form.

      Timeout is the amount of time the dropdown stays visible while there's no typing in the text field.
    Save Autocomplete Values If you enter something in a field that's not already in the autocomplete options, it will save the new text to the list of saved autocomplete values.

    Edit Saved Autocomplete Values This opens a separate dialog where you can edit the saved autocomplete values or document specific autocomplete values.
    • image(5).png
      Document Specific Autocomplete
      The popup menu at the top allows you to select document specific autocomplete values (ie these will be saved with, and show up only for, the one document).
      image(6).png
      Start on Load If document specific list is showing, there's a button to add a script to start autocomplete on the current document when it loads, even if the tool is set to not load automatically. It adds the following startup script to the Document Properties > JavaScript:

      Code: Select all

      "object"===typeof autocompleteDD && autocompleteDD.addKeystrokeAction(this);
    Default Autocomplete File It's possible to create a list of default autocomplete values. This could be useful if there are values that you want to transfer to a different machine, or always have available. It's a plain text file with each autocomplete value on a separate line, saved to the JavaScripts folder (%APPDATA\Tracker Software\PDFXEditor\3.0\Javascripts or %PROGRAMFILES%\Tracker Software\PDF Editor\Javascripts ) with the name autocompleteDD.defaults.txt
Autocomplete this PDF
  • If the background process is switched off, you can still use autocomplete by picking this menu item. It will add the Keypress actions to the current pdf. When you save the document it will try to clear the actions.
    If the document is locked, you need to manually remove the actions (it will show a reminder in the lower right corner for locked pdfs).
    image(4).png
Clear Keystroke Actions
  • When the script adds the Keypress actions to the document, it also adds a "WillSave" action that tries to clean up all the actions when the document is closed. However, it can get tripped up or be prevented from adding the WillSave action on locked pdfs, so this menu item clears everything manually.

Limitations
  • The script adds "Keypress" actions to text fields, and a "WillSave" action to the document. Because javascript has no way of knowing if a script was already applied, it will overwrite "clobber" any script on those actions.
  • There's no way (as far as I know) for a javascript to know what the contents of a field is while a user is typing in it, without adding keypress actions directly to the fields in the document. Hence all the rigmarole trying to remove them afterwards: I use the 'WillSave' action to remove all the Keypress actions added to form fields immediately before the file is saved. Hopefully this results in the saved file never having Keypress actions saved with it. It sets a timeout to re-add them after the save.
  • If the document is locked for editing, the script cannot add Close or Save actions to it. It will pop up a progress dialog in the lower right to remind you to clear the Keypress actions (just close it to clear them). It may be a bug, but PXCE is allowing Keypress actions to be added to a locked document by a menu item -- and has since at least version 9. This tool relies on that, so if at some time this window closes, the tool will no longer work on locked documents.
  • There's not currently a way to set where a popup menu shows up. It's just placed wherever the mouse is currently. This can be a bit annoying if the mouse happens to be over the field when you start typing. I've made a feature request for this, but for now, move the mouse away from the field before typing in it.
  • Fixed v1.1: When enabling the background process, if a document is open PXCE will associate the process with that document and cancel it as soon as the document is closed. I don't know how to work around this, so added an alert when the checkbox is enabled.
Minimal installation
For PDF XChange build 393 onwards, the only file that needs to be installed is autocompleteDD.js
If you don't need the ability to edit the form listbox colors, you can omit xutil.colorUtils.js
1ang.js is required by colorUtils and any translations. The translation strings are in the file below:

Translations
As of v1.0 it's translatable. Here are the translation strings (there are currently no translations)
translationData.autocompleteDD.json.zip
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Sat Dec 06, 2025 4:31 pm, edited 42 times in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

[tool] Autocomplete on form fields

Post by Daniel - PDF-XChange »

:)
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
Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Autocomplete on form fields

Post by Mathew »

Found quite a few bugs. Hopefully squashed in this. Also made it translatable.
autocompleteDD v1.0.zip

Changes in v1.0
  • make translatable;
  • fix v0.6 bug where dropdown field wasn't removed when text field deselected;
  • clear dropdown with 5 second timeout after field is deselected in pre-build 386;
  • deselect fields before applying action
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

[tool] Autocomplete on form fields

Post by Daniel - PDF-XChange »

:)
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
Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Autocomplete on form fields

Post by Mathew »

Oops: I think I spend a significant amount more time squashing the bugs I've created than actually writing the code! Hopefully I've got all the bugs now.
autocompleteDD v1.1.zip
Changes in v1.1
  • change how interval works so that it can always close the thermometer;
  • fix thermometer startup bugs;
  • always close dropdown with timeout (if esc pressed, no keypress action is thrown for field)
  • add preference setting for timeout
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

Re: [tool] Autocomplete on form fields

Post by Daniel - PDF-XChange »

Hello, Mathew

I feel like I'm sending too many smiley faces in this thread :lol:
Soooo...
Thank you kindly for the excellent work, I hope you are having fun with 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
Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Autocomplete on form fields

Post by Mathew »

Daniel - PDF-XChange wrote: Mon Sep 08, 2025 5:02 pm I hope you are having fun with it!
:lol: I saw a feature request and thought this would be an interesting challenge. I think I've taken this one as far as it can go without changes to the API.

Turns out the auto-complete part was easy :shock: , but working around actually getting what is typed, and trying to deal elegantly with events and form fields that get written into the document itself was quite an effort: I went down a few dead ends. The resulting tool could be good, but I think it's held back mostly by this (events get written into document and clobber any events already in the document). Usability of the popupmenu is also hampered by this (pop-up menu issues). These are things that are restricted by Adobe's ~2007-era API.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

Re: [tool] Autocomplete on form fields

Post by Daniel - PDF-XChange »

Hello, Mathew

Ahh yes, it looks like those ones are still awaiting a Dev reply, but they are a bit too recent for me to followup just yet.
If I haven't updated them in about 2 weeks with Feature request numbers, please nudge me in those threads, and I will go bug the Dev team directly!

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
kyle20
User
Posts: 2
Joined: Tue Oct 21, 2025 8:43 pm

Re: [tool] Autocomplete on form fields

Post by kyle20 »

Has this been found as useful for your users?
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12227
Joined: Wed Jan 03, 2018 6:52 pm

Re: [tool] Autocomplete on form fields

Post by Daniel - PDF-XChange »

Hello, kyle20

I will admit, I have seen very little feedback on it. Most of Mathew's tools have an extended discussion from the users of it, in the replies following, but as you can see there, there is very little input.

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
Mathew
User
Posts: 736
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Auto-Complete on text form fields

Post by Mathew »

A minor update to make the code more efficient, add a button to install a startup script on the document, and allow view of document-specific autocomplete values on locked documents. Also updated in the first post.
autocompleteDD v1.3.zip

Changes in v1.3
  • change scannedFields to WeakMap() to prevent memory leaks and simplify code;
  • minor code cleanup
Changes in v1.2 (not posted)
  • add button to install document open script;
  • allow view of locked document-specific autocomplete values
  • translation strings updated
You do not have the required permissions to view the files attached to this post.
User avatar
Sean - PDF-XChange
Site Admin
Posts: 629
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Auto-Complete on text form fields

Post by Sean - PDF-XChange »

Thanks Mathew.

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
Sean - PDF-XChange
Site Admin
Posts: 629
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Auto-Complete on text form fields

Post by Sean - PDF-XChange »

Thanks Mathew.

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623