Questo breve articolo descrive come rimuovere i collegamenti ipertestuali da Word usando Java. Include details about the IDE configuration, a list of instructions to develop the application, and sample code that demonstrates how to remove hyperlinks from a Word document using Java. Some improvements are also shared in this article to customize the output Word file, if necessary.
Steps to remove hyperlinks in Word using Java.
- Configure the IDE to use Aspose.Words for Java to remove hyperlinks.
- Upload the original Word file containing various hyperlinks into the Document object.
- Elenca tutti i hyperlinks nel documento, escludendo quelli nel sommario se necessario
- Store the visible text of each hyperlink before removing the hyperlinks.
- Remove all hyperlinks while keeping the displayed text.
- Remove the hyperlink formatting from the text of each removed hyperlink.
- Analyze the document and remove hyperlink-style formatting from any remaining text.
- Save the updated Word file that contains plain text instead of hyperlinks.
Questi passaggi riassumono come rimuovere tutti i collegamenti ipertestuali in Word usando Java. Carica il file Word di origine con i collegamenti ipertestuali, raccogli tutti i collegamenti ipertestuali, opzionalmente saltando quelli nell’indice, memorizza il testo visualizzato da ciascun collegamento ipertestuale e rimuovi tutti i collegamenti ipertestuali dal documento. Imposta il testo reale al posto di ciascun collegamento ipertestuale, rimuovi lo stile relativo al collegamento ipertestuale da quel testo, rimuovi uno stile simile dal resto del testo nel documento e salva il file Word senza collegamenti ipertestuali.
Code to remove hyperlinks in a Word document using Java
This code demonstrates how to remove all hyperlinks in Word at once using Java. Note that the current loop selects only FieldHyperlink fields, so if you want to remove the links associated with images and shapes, delete the HRef property of each of them. If you want to handle internal and external links separately, use the getSubAddress() and getAddress() methods of FieldHyperlink, respectively.
This article shows the process of using hyperlinks in a Word file. To work with document revisions and accept them all at once, refer to the article Accept all changes in Word using Java.