チュートリアル
簡単にライブラリーを使用するためのチュートリアルコレクション
PowerPoint のハイパーリンクとは、同じ/別の PowerPoint 内の他のスライドにや、特定の Web サイトにジャンプすることができるクリック可能なオブジェクトです。これらはスライドに追加のリソースを追加する素晴らしい方法であり、文書をよりインタラクティブにすることもできます。Spire.Presentation for Java では、PowerPoint 文書にハイパーリンクを追加するだけでなく、既存のハイパーリンクを変更または削除することもサポートしています。この記事では、上記の2つの機能をどのように実現するかを紹介します。
まず、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>
Spire.Presentation for Java を使用すると、既存のハイパーリンクのアドレスとアンカーテキストを変更することができます。以下は PowerPoint でハイパーリンクを変更する詳細な手順です。
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);
}
}
何らかの理由でハイパーリンクを削除する必要がある場合、Spire.Persentation for Java は TextCharacterProperties.setClickAction() メソッドを提供します。その値を null に設定すると、PowerPoint でハイパーリンクを削除できます。詳細な手順は次のとおりです。
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 日間有効な一時ライセンスを取得してください。