PowerPoint のハイパーリンクとは、同じ/別の PowerPoint 内の他のスライドにや、特定の Web サイトにジャンプすることができるクリック可能なオブジェクトです。これらはスライドに追加のリソースを追加する素晴らしい方法であり、文書をよりインタラクティブにすることもできます。Spire.Presentation for Java では、PowerPoint 文書にハイパーリンクを追加するだけでなく、既存のハイパーリンクを変更または削除することもサポートしています。この記事では、上記の2つの機能をどのように実現するかを紹介します。 PowerPoint 内のハイパーリンクを変更する PowerPoint 内のハイパーリンクを削除する Spire.Presentation for Java をインストールします まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。 <repositories> <repository> <id>com.e-iceblue</id> <name>e-iceblue</name> <url> https://repo.e-iceblue.com/nexus/content/groups/public/</url> </repository> </repositories> <dependencies> <dependency> <groupId>e-iceblue</groupId> <artifactId>spire.presentation</artifactId> <version>8.3.2</version> </dependency> </dependencies> PowerPoint 内のハイパーリンクを変更する Spire.Presentation for Java を使用すると、既存のハイパーリンクのアドレスとアンカーテキストを変更することができます。以下は PowerPoint でハイパーリンクを変更する詳細な手順です。 Presentation オブジェクトを作成し、Presentation.loadFromFile() メソッドを使用して PowerPoint をロードします。 Presentation.getSlides().get() メソッドを使用して、指定されたスライドを取得します。 ISlide インターフェイスの getShapes()メソッドを使用して、指定されたスライドの図形を取得します。 ShapeList.get() メソッドを使用してハイパーリンクを含む指定された図形を取得します。 IAutoShape.getTextFrame().getTextRange() メソッドを使用して既存のハイパーリンクのテキスト範囲を取得します。 PortionEx.setText() メソッドを使用してテキスト範囲の新しいハイパーリンクのテキストを設定します。 TextCharacterProperties.getClickAction() メソッドを使用してテキスト範囲の既存のハイパーリンクを取得します。 ClickHyperlink.setAddress() メソッドを使用して新しいハイパーリンクのアドレスを設定します。 Presentation.saveToFile() メソッドを使用して文書に保存します。 Java import com.spire.presentation.*; public class modifyHyperlink { public static void main(String[] args) throws Exception { //Presentationオブジェクトを作成し、PowerPointをロードする Presentation presentation = new Presentation(); presentation.loadFromFile("test.pptx"); //ハイパーリンクを含む図形を取得する IAutoShape shape = (IAutoShape)presentation.getSlides().get(0).getShapes().get(0); //ハイパーリンクのテキストとアドレスを編集する shape.getTextFrame().getTextRange().setText("Spire.Presentation for Java"); shape.getTextFrame().getTextRange().getClickAction().setAddress("https://jp.e-iceblue.com/introduce/spire-presentation-for-java.html"); //文書に保存する presentation.saveToFile("ModifyHyperlink.pptx", FileFormat.PPTX_2013); } } PowerPoint 内のハイパーリンクを削除する 何らかの理由でハイパーリンクを削除する必要がある場合、Spire.Persentation for Java は TextCharacterProperties.setClickAction() メソッドを提供します。その値を null に設定すると、PowerPoint でハイパーリンクを削除できます。詳細な手順は次のとおりです。 Presentation オブジェクトを作成し、Presentation.loadFromFile() メソッドを使用して PowerPoint をロードします。 Presentation.getSlides().get() メソッドを使用して、指定されたスライドを取得します。 ISlide インターフェイスの getShapes() メソッドを使用して、指定されたスライドの図形を取得します。 ShapeList.get() メソッドを使用してハイパーリンクを含む指定された図形を取得します。 IAutoShape.getTextFrame().getTextRange() メソッドを使用して既存のハイパーリンクのテキスト範囲を取得します。 TextCharacterProperties.setClickAction() メソッドの値を null に設定してハイパーリンクを削除します。 Presentation.saveToFile() メソッドを使用して文書に保存します。 Java import com.spire.presentation.*; public class removeHyperlink { public static void main(String[] args) throws Exception { //Presentationオブジェクトを作成し、PowerPointをロードする Presentation presentation = new Presentation(); presentation.loadFromFile("test.pptx"); //ハイパーリンクを含む図形を取得する IAutoShape shape = (IAutoShape)presentation.getSlides().get(0).getShapes().get(0); //クリックアクションをnullに設定してハイパーリンクを削除する shape.getTextFrame().getTextRange().setClickAction(null); //文書に保存する presentation.saveToFile("RemoveHyperlink.pptx", FileFormat.PPTX_2013); } } 一時ライセンスを申請する 結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。 にお問い合わせ、30 日間有効な一時ライセンスを取得してください。