はじめに

この投稿では、Aspose.PDF FOSS for Java 26.9.0 に搭載された新しい変換 API を使用して、PDF を Excel ワークブックまたは Markdown ドキュメントに変換し、さらに逆変換する方法を示します。両方向がサポートされており、PDF を編集可能なワークブックまたは Markdown ドキュメントにエクスポートでき、編集したワークブックや Markdown ファイルを PDF に再変換できます。

PDF が次のワークフローのステップに適さない形式である場合に便利です。たとえば、スプレッドシートで表データを編集する必要があるレビュアーや、テキストコンテンツをプレーンテキストで、バージョン管理に適した形式で必要とするライターなどです。

Aspose.PDF FOSS for Java は MIT ライセンスで、外部依存関係がありません。


含まれるもの

Excel へのエクスポート

Document.save with SaveFormat.Xlsx は PDF をワークブックに変換します。ExcelSaveOptions は出力の形状を制御します — 特に、ページを少数のワークシートに結合するか、シートごとに 1 ページに保つかを決定します:

import org.aspose.pdf.Document;
import org.aspose.pdf.ExcelSaveOptions;

try (Document doc = new Document("report.pdf")) {
    ExcelSaveOptions options = new ExcelSaveOptions();
    options.setFormat(ExcelSaveOptions.ExcelFormat.XLSX); // default
    options.setMinimizeTheNumberOfWorksheets(true);        // merge pages onto fewer sheets
    options.setInsertBlankColumnAtFirst(false);            // no leading spacer column
    options.setUniformWorksheets(false);                   // allow per-sheet column widths
    options.setStructuralHeuristics(true);                 // recover tables on untagged PDFs
    options.setSuppressRunningHeadersFooters(true);         // drop repeated page furniture
    doc.save("report.xlsx", options);
}

Markdown にエクスポート

MarkdownSaveOptions は、ドキュメント構造の復元や埋め込みグラフィックの処理オプションを備えて、同様の方法で Markdown エクスポートを制御します:

import org.aspose.pdf.Document;
import org.aspose.pdf.MarkdownSaveOptions;

try (Document doc = new Document("article.pdf")) {
    MarkdownSaveOptions options = new MarkdownSaveOptions();
    options.setStructuralHeuristics(true);          // recover headings/lists/tables
    options.setSuppressRunningHeadersFooters(true);  // drop repeated page furniture
    options.setRasterizeVectorGraphics(true);        // charts/shapes -> referenced images
    doc.save("article.md", options);
}

PDF に再変換

ExcelLoadOptions と MarkdownLoadOptions は、ワークブックまたは Markdown ファイルを読み込み、PDF に再変換するために Document コンストラクタに渡されます:

import org.aspose.pdf.Document;
import org.aspose.pdf.ExcelLoadOptions;

try (Document doc = new Document("book.xlsx", new ExcelLoadOptions())) {
    doc.save("book.pdf");
}

クイックスタート

<dependency>
  <groupId>org.aspose</groupId>
  <artifactId>aspose-pdf-foss</artifactId>
  <version>26.9.0</version>
</dependency>

上記の依存関係を追加し、SaveFormat.Xlsx を使用して数行で PDF を XLSX に変換します — 基本的なエクスポートには追加オプションは不要です:

import org.aspose.pdf.Document;
import org.aspose.pdf.SaveFormat;

try (Document doc = new Document("report.pdf")) {
    doc.save("report.xlsx", SaveFormat.Xlsx); // SaveFormat.Excel is an alias
}

サポートされている形式

フォーマット拡張子読み取り書き込み
PDFpdf✓✓
Excelxlsx✓✓
Markdownmd✓✓

オープンソースとライセンス

Aspose.PDF FOSS for Java は MIT ライセンスで提供されており、https://github.com/aspose-pdf-foss/Aspose.PDF-FOSS-for-Java で入手可能です。MIT ライセンスの条件の下で商用利用が許可されています。プロジェクトでエンタープライズ向けサポート、拡張フォーマットのカバレッジ、またはクラウド統合が必要な場合、Aspose.PDF — Enterprise Product Family は別途の商用オファーです。


はじめに

関連リソース