Installation To use, unzip and copy the .js files to the JavaScripts folder and restart PDF-XChange. More details: viewtopic.php?p=196006#p196006
It will show up on the "Add-in" section of the home ribbon; or in Tools > Add-in Tools for the classic UI. Select that menu item and it opens a dialog box:
Enter number of sides (at least 3), scale (this is the radius of a circle that circumscribes the polygon), and rotation. You can manually enter the rotation, or pick an alignment from the drop-down menu.
If you select to place it by pressing the CTRL key, the polygon will follow the mouse at the alignment you picked, or at its center, until CTRL is pressed (or the number of selected items increases). If not selected it will draw the polygon at the current mouse position (probably under the dialog box). The option to place by mouse click is a bit experimental -- it puts a temporary form element in the background to detect mouse clicks: You can change border color, style, fill, size, etc just as you would for any other markup - it's a Polygon annotation.
The option "Draw as Star" draws a star shape. This is a 6 sided polygon as a star: There's an option in the javascript file on line 79 to change how spiky the star is. It's the ratio of the radius at the inside of the star. A smaller number will make it extend in closer to the center:
Code: Select all
// factor to scale inner point of star
const starShape = (sides > 3) ? 0.5 : 0.25;
This tool is translatable with 1ang.js and the following translation strings:
Code: Select all
# Translation file (requires 1ang v1.0 or later)
# Domain for this translation file is "regularPolygon"
# Filename must be "translationData.regularPolygon.json" and saved in the JavaScripts folder
# It is not necessary for all strings to be included in every language,
# but don't put an empty string "" for the translation, because that's what will be shown!
# This must be formatted as a JSON file except that:
# lines starting with # and empty lines are stripped out before processing
# "Language" is three letter code as output from app.language
# "Original Text" is case sensitive!
# Notice that the last item in a list does not allow a comma after it.
# Format:
# "Language 1": {
# "Original Text": "Translated Text in Language 1",
# "Original Text 2": ["Translated Text 2 singular", "Translated Text 2 plural"]
# },
# "Language 2": {
# "Original Text": "Translated Text in Language 2"
# }
{
"": {
"Add-in Tools": "",
"Regular Polygon…": "",
"Polygon": "",
"Alignment:": "",
"Point Up": "",
"Point Down": "",
"Point Left": "",
"Point Right": "",
"Flat Up": "",
"Flat Down": "",
"Flat Left": "",
"Flat Right": "",
"Regular Polygon": "",
"Sides:": "",
"Draw as Star": "",
"Scale:": "",
"points": "",
"Rotation °": "",
"Place by pressing CTRL key": "",
"Place by mouse click": ""
}
}Limitations
- There's no built-in way to detect mouse clicks, so this was mainly an exercise in finding workarounds. The event.modifier and event.shift are constantly updated, so I used that as a way to signal placement. There's also a mouseUp event on fields, so I tried putting in temporary form fields in the background. I think a built in way to expose mouse clicks to javascript would be better, but this is the best I can do.
This is the old version: It just places the polygon in the middle of the page.