[tool] Remove polyline control points (or segments)

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

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

[tool] Remove polyline control points (or segments)

Post by Mathew »

This tool allows one to delete multiple polyline or polygon control points (or line segments) by drawing a around them. One can use a rectangle, pencil or polygon to draw around the points or line segments to delete.

There's a built-in tool to remove individual control points from polylines and polygons: Right click on each point, and select Control Points > Delete Point. Deleting multiple points this way is laborious.

Usage
Select the markup(s) you want to edit, then this tool from the Add-on Toolbar.
image(5).png
The tool will then activate the rectangle tool so you can draw a rectangle around the points you want to delete.
image(1).png
As soon as you finish drawing the rectangle, it will remove the points:
image(2).png
CTRL: Line Segments
If you want to delete line segments instead of just the points, hold down CTRL (this may split the polyline/polygon into multiple polylines if selecting interior segments). I prefer to use the tool to delete segments, so I change the default to deleting segments (and CTRL deleting points) on line 22 of the code:

Code: Select all

let segmentsDefault = true; // true = delete segments by default, CTRL deletes points
SHIFT: Inverse
If you hold down SHIFT, the tool works inversely:
image(3).png
Only the points inside the rectangle are saved:
image(4).png

Installation
deleteControlPoints v1.4.zip
Download the zip file, and copy the javascript files into the JavaScripts directory. More detailed directions here: viewtopic.php?p=196006#p196006


After PDF XChange is restarted, it will add a button to the Add-on Tools
image.png

This is the first version; doesn't add temporary markers at control points and is not localizable
deleteControlPoints v1.0.zip

Translations
This script is translatable with 1ang.js. Here are the translation strings:

Code: Select all

# Translation file (requires 1ang v1.0 or later)
# Domain for this translation file is "deleteControlPoints"
# Filename must be "translationData.deleteControlPoints.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"
#   }

{
 "": {
     "Remove Points": "",
     "Delete control points\n────────────────────────\nSelect polyline or polygons and then the tool. Draw a rectangle around the control points to delete (or if SHIFT is held down, keep only the control points inside the rectangle).": "",
     "Temporary Marker": "",
     "Select at least one polyline, polygon, rectangle or oval annotation to work on before running this tool.": "",
     "segments": "",
     "control points": "",
     "keep": "",
     "delete": "",
     "Draw around %1 to %2": "",
     "Cancelled Remove Points tool": "",
     "%1 has fewer than 2 remaining vertices - ignored: %2": "",
     "Not all selected annotations were changed.\nSee console output for details.": "",
     "%1 was unchanged: %2": ""
 }
}
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Sat Sep 19, 2026 10:34 pm, edited 8 times in total.
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

Yet another interesting tool, thank you Mathew!

Just a couple of beta comments:

  • It seems that if a color has been selected in the Rectangle tool, then the contents of the rectangle created by the Delete Control Points tool will be obscured by that color, including its opacity. Might it be better if the fill color opacity would be overridden to 0% so that users can visualize what is being deleted regardless of Rectangle tool fill color settings?
  • I see the tool does not work with an object created with the Pencil tool. I can imagine to do so would be a tremendous challenge probably because the Pencil tool does not use control points. Would I be correct in that assumption?
EDIT: I now see that my second point above is not strictly speaking correct. A Pencil-tool drawn line CAN be processed with the remove tool but it has to be converted to polyline before selection of the to-be deleted area. Would there be any prospect of re-writing the JS script to automatically do this if the object has been created by the Pencil tool?

Another beta point: I note that visibility of the Control Points goes away when the delete tool activates the area selection. Would there be any prospect retaining Control Point visibility whilst the area selection is active so the the user can see exactly which Control Points are within the selection area?
All best,

FringePhil
User avatar
Mathew
User
Posts: 923
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Remove polyline control points

Post by Mathew »

PHK wrote: Wed Sep 09, 2026 9:06 am Yet another interesting tool, thank you Mathew!

Just a couple of beta comments:

  • It seems that if a color has been selected in the Rectangle tool, then the contents of the rectangle created by the Delete Control Points tool will be obscured by that color, including its opacity. Might it be better if the fill color opacity would be overridden to 0% so that users can visualize what is being deleted regardless of Rectangle tool fill color settings?
  • I see the tool does not work with an object created with the Pencil tool. I can imagine to do so would be a tremendous challenge probably because the Pencil tool does not use control points. Would I be correct in that assumption?
EDIT: I now see that my second point above is not strictly speaking correct. A Pencil-tool drawn line CAN be processed with the remove tool but it has to be converted to polyline before selection of the to-be deleted area. Would there be any prospect of re-writing the JS script to automatically do this if the object has been created by the Pencil tool?

Another beta point: I note that visibility of the Control Points goes away when the delete tool activates the area selection. Would there be any prospect retaining Control Point visibility whilst the area selection is active so the the user can see exactly which Control Points are within the selection area?
Hi FringePhil,

Good points all; unfortunately they are all limitations of the javascript api:
  • I don't think there's a way for javascript to pick which particular rectangle tool is selected. If anyone knows, please post. The way I'm activating the rectangle tool is by app.execMenuItem('cmd.tool.annot.square', doc). Workaround: Pick another rectangle preset, or change the fill color, before drawing the rectangle.
  • There's a built-in tool that works for pencil markups: Eraser Tool. Works better than this tool, IMO.
  • Control points are only visible while the element is selected, but I need to activate the rectangle tool so one can select the area. I'm thinking I could add temporary dots where the control points are and remove them afterwards as a workaround. Added as a "todo"
- Mathew
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

Thanks, Mathew; see my responses below.
Mathew wrote: Wed Sep 09, 2026 3:29 pm
Good points all; unfortunately they are all limitations of the javascript api:
Not surprised; I thought that possible but I knew you would know.
Mathew wrote: Wed Sep 09, 2026 3:29 pm I don't think there's a way for javascript to pick which particular rectangle tool is selected. If anyone knows, please post. The way I'm activating the rectangle tool is by app.execMenuItem('cmd.tool.annot.square', doc). Workaround: Pick another rectangle preset, or change the fill color, before drawing the rectangle.
I thought that might be the case and it is not a problem to deal with the rectangle settings B4 using the tool.
Mathew wrote: Wed Sep 09, 2026 3:29 pm There's a built-in tool that works for pencil markups: Eraser Tool. Works better than this tool, IMO.
Totally agree re Eraser; more of a pedantic observation for which I apologize.
Mathew wrote: Wed Sep 09, 2026 3:29 pm Control points are only visible while the element is selected, but I need to activate the rectangle tool so one can select the area. I'm thinking I could add temporary dots where the control points are and remove them afterwards as a workaround. Added as a "todo"
Good luck on that. To me, it is the most important of my posted issues. It's a bit frustrating to think about the Control Points you want to kill and then not see them when you've got the selection rectangle activated.
All best,

FringePhil
User avatar
Mathew
User
Posts: 923
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Remove polyline control points

Post by Mathew »

This version adds temporary markers at the control points so you can actually see what you're selecting. Also made the tool translatable.
deleteControlPoints v1.1.zip
PHK wrote: Wed Sep 09, 2026 4:07 pm Good luck on that. To me, it is the most important of my posted issues. It's a bit frustrating to think about the Control Points you want to kill and then not see them when you've got the selection rectangle activated.
Agreed. Turns out it wasn't very difficult to do. The downside is that it adds LOTS of undos - basically makes undo not work for this tool, because of an ongoing PXCE bug: viewtopic.php?t=40330
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Thu Sep 10, 2026 5:40 pm, edited 4 times in total.
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

Thanks, Mathew. I may not have a chance to try it out for a few hours and possibly not today at all, fyi.
All best,

FringePhil
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

Thanks for the revision, Mathew.

I see what you've done with the "Temporary Marker" comments as Control Points; very inventive. And it works!
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1233
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Remove polyline control points

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
Mathew
User
Posts: 923
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Remove polyline control points

Post by Mathew »

OOps, bug fix for rotated polylines.
deleteControlPoints v1.2.zip
Changes v1.2
  • group markers;
  • rotate markers with annotation
You do not have the required permissions to view the files attached to this post.
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1233
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Remove polyline control points

Post by Sean - PDF-XChange »

Okay, thanks again Mathew for another great contribution!

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
ziomau10
User
Posts: 5
Joined: Sat Jun 28, 2025 11:36 am

Re: [tool] Remove polyline control points

Post by ziomau10 »

Thanks Mathew,
I installed also your other tool Roughen.
But I noticed that Roughen adds a section "Add-in Tools" to the "Home" ribbon, while this "Remove Control Points" adds a new full ribbon "Add-on Tools" at the end of the menu row.
Is it possible to have both in the same place?
After all they both regards manipulating poli-lines.

Anyway, thanks for you efforts.
Regards.
Mau.
User avatar
Mathew
User
Posts: 923
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Remove polyline control points

Post by Mathew »

ziomau10 wrote: Mon Sep 14, 2026 9:35 am Is it possible to have both in the same place?
After all they both regards manipulating poli-lines.
One can move the tool to another location by using Customize Toolbars… > Drag the tool button from the Add-on Tools to the location you want it (ie the Add-in Tools section on the Home ribbon:
move tool button.gif

I've been a bit erratic about placement of my tools, especially in the ribbon UI because I use the classic UI. I probably need a bit of help thinking about where all the tools should be...
You do not have the required permissions to view the files attached to this post.
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

Mathew wrote: Mon Sep 14, 2026 4:14 pm ...
I've been a bit erratic about placement of my tools, especially in the ribbon UI because I use the classic UI. I probably need a bit of help thinking about where all the tools should be...
My vote would be to put them all in the Add-on Tools tab and let users move them to preferred tabs as you suggest, Mathew.
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1233
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Remove polyline control points

Post by Sean - PDF-XChange »

Hi Phil,

Thanks for the input here.

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
PHK
User
Posts: 1666
Joined: Tue Nov 24, 2020 4:02 pm

Re: [tool] Remove polyline control points

Post by PHK »

8)
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1233
Joined: Wed Sep 14, 2016 5:42 pm

Re: [tool] Remove polyline control points

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
Mathew
User
Posts: 923
Joined: Thu Jun 19, 2014 7:30 pm

Re: [tool] Remove polyline control points

Post by Mathew »

I added the ability for the tool to delete line segments also, and one can use a polygon, circle or pencil tool to draw around the points/segments to delete.

By default, holding down CTRL switches the tool to deleting segments instead of points. I find I prefer to delete segments, so I change the default on line 22:

Code: Select all

let segmentsDefault = true; // true = delete segments by default, CTRL deletes points
deleteControlPoints v1.4.zip
Changes v1.4
  • Works with ink, circle, polygon as delete area;
  • works on circle or rectangle to delete from;
  • option to delete segments by default;
  • start a single interval instead of one per annotation;
  • try no to add too many markers;
  • change markers to two ink annotation for speed (v1.3 was very slow if there were a lot of control points).
You do not have the required permissions to view the files attached to this post.