[tool] Draw regular polygons or stars

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: 570
Joined: Thu Jun 19, 2014 7:30 pm

[tool] Draw regular polygons or stars

Post by Mathew »

Maybe there's a built-in way to do this, but here's a tool I made because sometimes I need to draw regular polygons to mark up symbols. This tool will draw a polygon annotation in the middle of the page. I didn't bother to make an icon or put it in the Add-on Toolbar because I don't use it very often.
drawPolygon v0.1.zip

To use, unzip and copy the .js file to the JavaScripts folder and restart PDF-XChange. You can test it out by copy and past the code into the javascript console (CTRL-J) and run it from there.

It will add a menu item "Draw Regular Polygon…" to the Comments menu, or if you are using the ribbon UI it will add it to the end of the File menu. Select that menu item and it opens a dialog box:
image.png
Enter number of sides (at least 3), scale (this is the radius of a circle that circumscribes the polygon), and angle. It will draw the polygon in the center of the current page:
image(1).png
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:
image(2).png
There's an option in the javascript file on line 26 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 = 0.5;
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11027
Joined: Wed Jan 03, 2018 6:52 pm

Re: [tool] Draw regular polygons or stars

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for this, I do not believe we offer a feature to accommodate something like this just yet, so this could be very handy indeed!

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