Cloud Java SDK を使用して PDF 用テーブルを作成する方法
Cloud Java SDK を使用して PDF 用テーブルを作成するために、以下を使用します Aspose.PDF Cloud Java SDK このクラウド SDK を使用すると、さまざまなクラウドプラットフォーム向けに Java 言語でクラウドベースの PDF 作成、編集、変換アプリを簡単に構築できます。開く Repository パッケージマネージャーで Aspose.PDF Cloud を検索してください そしてインストールします。Maven を使用してインストールするには、パッケージマネージャーコンソールから次のコマンドを使用できます。
Aspose Cloud リポジトリをアプリケーションの pom.xml に追加します
Aspose Cloud リポジトリの追加
<repositories>
<repository>
<id>aspose-cloud</id>
<name>Aspose Cloud Repository</name>
<url>https://releases.aspose.cloud/java/repo/</url>
</repository>
</repositories>
API クライアントライブラリをローカルの Maven リポジトリにインストールするには、次のコマンドを実行するだけです。
GitHub からのインストール
mvn clean install
代わりにリモート Maven リポジトリへデプロイするには、リポジトリの設定を構成して実行します。
Maven リポジトリのデプロイ
mvn clean deploy
Java SDK を使用して PDF 用テーブルを作成する手順
Aspose.PDF Cloud の開発者は、数行のコードだけで拡張プロパティを持つ PDF 用テーブルを簡単にロードおよび作成できます。
- ファイルをクラウドストレージにアップロードする
- テーブルの外観を定義する
- テーブルの内容を定義する
- テーブルを PDF に追加する
- 更新されたファイルをダウンロードする
このサンプルコードは PDF ドキュメントにテーブルを追加する方法を示しています
import java.util.ArrayList;
import com.aspose.asposecloudpdf.model.BorderInfo;
import com.aspose.asposecloudpdf.model.Cell;
import com.aspose.asposecloudpdf.model.Color;
import com.aspose.asposecloudpdf.model.FontStyles;
import com.aspose.asposecloudpdf.model.GraphInfo;
import com.aspose.asposecloudpdf.model.Row;
import com.aspose.asposecloudpdf.model.Table;
import com.aspose.asposecloudpdf.model.TextRect;
import com.aspose.asposecloudpdf.model.TextState;
public class TableInitialize {
public static Table create() {
int numOfCols = 5;
int numOfRows = 5;
TextState textState = new TextState()
.fontSize(10.);
TextState headerState = new TextState()
.fontSize(10.)
.fontStyle(FontStyles.BOLD);
Table table = new Table();
table.setRows(new ArrayList<>());
String colWidths = "";
for (int c = 0; c < numOfCols; c++)
{
colWidths += " 70";
}
table.columnWidths(colWidths);
table.defaultCellTextState(textState);
GraphInfo borderTableBorder = new GraphInfo();
borderTableBorder.setColor(new Color().A(255).G(255));
borderTableBorder.setLineWidth(1.);
table.setDefaultCellBorder(new BorderInfo()
.top(borderTableBorder)
.right(borderTableBorder)
.bottom(borderTableBorder)
.left(borderTableBorder)
);
table.setTop(100.);
for (int r = 0; r < numOfRows; r++) {
Row row = new Row().cells(new ArrayList<>());
for (int c = 0; c < numOfCols; c++) {
Cell cell = new Cell();
cell.setBackgroundColor(new Color().A(255).R(150).G(150).B(150));
cell.setParagraphs(new ArrayList<>());
cell.getParagraphs().clear();
// change properties on cell
if (r == 0) {
cell.setDefaultCellTextState(headerState);
cell.getDefaultCellTextState().setForegroundColor(new Color().A(255).B(255));
cell.getParagraphs().add(new TextRect().text(String.format("Col #%d", c)));
} else {
if (c == 0) {
cell.setDefaultCellTextState(headerState);
cell.getDefaultCellTextState().setForegroundColor(new Color().A(255).B(255));
cell.getParagraphs().add(new TextRect().text(String.format("Row #%d", r)));
} else {
cell.setDefaultCellTextState(textState);
cell.getDefaultCellTextState().setForegroundColor(new Color().A(255).R(255));
cell.getParagraphs().add(new TextRect().text(String.format(" Value: row #%d - col #%d", r, c)));
}
}
row.getCells().add(cell);
}
table.getRows().add(row);
}
return table;
}
}
PDF のテーブル操作
テーブルはデータを体系的に提示するための構造化された形式を提供し、読者が情報を理解し分析しやすくします。また、文書の視覚的な魅力を高め、プロフェッショナリズムと整理整頓を加えます。数値データや比較データを扱う際、テーブルは関連情報を見やすい形式でグループ化することで明瞭さを向上させます。さらに、テーブルはデータベースや分析ダッシュボードからのデータなど、リアルタイムまたは動的に生成されたコンテンツを組み込むことも可能です。 Aspose.PDF Cloud Java SDK を使用して、PDF ドキュメント用の拡張プロパティを持つテーブルを作成します。
Java ライブラリでできること:
- PDF ドキュメントのヘッダーとフッターをテキストまたは画像形式で追加できます。
- PDF ドキュメントにテーブルやスタンプ(テキストまたは画像)を追加できます。
- 複数の PDF ドキュメントを既存のファイルに結合できます。
- PDF の添付ファイル、注釈、フォームフィールドを操作できます。
- PDF ドキュメントに暗号化/復号化を適用し、パスワードを設定できます。
- ページまたはPDF文書全体からすべてのスタンプとテーブルを削除します。
- PDF文書からIDで特定のスタンプまたはテーブルを削除します。
- PDFページ上または文書全体から単一または複数のテキストインスタンスを置換します。
- PDF文書をさまざまな他のファイル形式に変換するための広範なサポートを提供します。
- PDFファイルのさまざまな要素を抽出し、PDF文書を最適化します。
- 当社の無料アプリを試して、オンラインでPDFファイルからテーブルを抽出し、機能をテストできます。