Skip to main content
Participating Frequently
May 22, 2021
Question

[HELP JAVASCRIPT] Delete in a table the texts containing a "Yy" prefix

  • May 22, 2021
  • 1 reply
  • 1539 views

Hello,

Is it possible to help me with a program?

I would like to delete in a table all the texts containing a "Yy" prefix like the words "Yycar", "Yytravel", etc...

I developped a code but it doesn't seem to work at runtime, if you have a track I will be totally grateful to you 🙂

 

Here is my code:

// recovery. of all <td> 
const oCells = document.querySelectorAll("table td");
const search = "Yy";
// the search loop
for (let cell of oCells) {
  const text = cell.textContent;      // reading raw content
  if (text.startsWith(search)) {      // occurrence found
    cell.textContent = " ";       // we replace the content with nothing
  }
}

This JavaScript code will be used on a PDF document containing a table with data and I would like to delete in this table all the texts containing the prefix "Yy". 

Thanks in advance for your reply and have a nice day!

This topic has been closed for replies.

1 reply

Brainiac
May 22, 2021

This is not Acrobat JavaScript. It's got a browser. 

Muzan5EC8Author
Participating Frequently
May 22, 2021
quote

This is not Acrobat JavaScript. It's got a browser. 


By @Test Screen Name

Do you have a solution in this case?

Muzan5EC8Author
Participating Frequently
May 22, 2021

Unfortunately not because as I say on word I created a pre-filled table with data in some cells starting with "Yy". And the cells contain names for that when I export my file to PDF. The fields automatically take the name of the cell data with the field recognition tool.


If Acrobat Javascript can't change texts in a PDF document, can it at least hide / hide them?