Copy link to clipboard
Copied
I want to remove all the text boxes in my PDF but after searching a while, I didn't find any solution. I assume a script is necessary here. I know Python programming, so I assume javascript is just a syntax issue. Could someone provide some ideas about how the script should look like? Thanks!
In the document it looks like this on the bottom of every page
Copy link to clipboard
Copied
Want you remove all form text fields?
Copy link to clipboard
Copied
They are inserted text boxes, the same as one when you want to insert a text on to a page.
Copy link to clipboard
Copied
There are at least three different ways of doing that, please be more specific about what exact tool you're using to add those "text boxes".
Copy link to clipboard
Copied
Sorry for the confusion, the "Add text" tool
Copy link to clipboard
Copied
"Add Text" commenting tool?
Copy link to clipboard
Copied
You can use this code to do it:
for (var i=this.numFields-1; i>=0; i--) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="text") this.removeField(f.name);
}
Copy link to clipboard
Copied
I got
SyntaxError: syntax error
1:Console:Exec
undefined
I checked a bit and this.numFields is 0. I think you probably understand the text boxes wrong. The ones I am having in my pdf are the same as the ones when you use the "Add text" tool.
Copy link to clipboard
Copied
Does you use comments?
Can you post a screenshot?
Copy link to clipboard
Copied
The screent shot on the content panel. It would be nice if the Container and the Annotations can also be removed.
Copy link to clipboard
Copied
Annotations can be removed with a script. See above.
Copy link to clipboard
Copied
Page Content cannot be modified with a script.
Copy link to clipboard
Copied
Not quite true. It can be removed, using redactions. And it can be added, by flattening fields or comments.
Copy link to clipboard
Copied
Yes, that right. But it's definately the long way around. And no reflow.
Copy link to clipboard
Copied
It is better to change the original document and re-create the PDF file.
Copy link to clipboard
Copied
You can use preflight profiles to move all of the page content text to a new layer, and delete that layer, although this would affect all (live) text and would probably ignore outlined text.
Copy link to clipboard
Copied
The fact there are no fields in the file should not cause an error. It will just mean that nothing happens when you run the script.
Copy link to clipboard
Copied
Ha ha. Explicit language is very important for solving technical issue. We have to know what you are talking about. Gilad thought you mean text fields, but you mean something else. Very important distinction.
If you are using the commenting tools to add test, then use this code in the console window
this.getAnnots().forEach(function(a){if(a.type == "FreeText") a.destroy()});
But if you are using the "Edit PDF" tools, your SOL. That text is part of the page contents. JavaScript only has access to annotations.