GroupDocs.Mergerで特定ページのPDFを抽出する方法
Extracting specific pages pdf is a common requirement when you need to reuse, share, or archive only a portion of a larger document. With GroupDocs.Merger for .NET you can programmatically pull out single pages, page ranges, or custom selections from PDF, Word, and DOCX files without manual editing. This tutorial walks you through the concepts, prerequisites, and step‑by‑step workflow so you can integrate page extraction into any .NET application.
クイック回答
- 「extract specific pages pdf」とは何ですか? PDF(または他のサポートされている形式)から個々のページまたは範囲を選択し、新しい小さなドキュメントとして保存することを意味します。
- サポートされているフォーマットは何ですか? GroupDocs.Merger は PDF、DOCX、PPTX、画像など、50 以上の入力および出力フォーマットに対応しています。
- ライセンスは必要ですか? テスト用には一時ライセンスで動作しますが、本番環境で使用するにはフルライセンスが必要です。
- 大きなファイルを処理できますか? はい。ライブラリはストリーミングを使用して数百ページのファイルを処理し、メモリ使用量を低く抑えます。
- .NET Coreはサポートされていますか? もちろんです。API は .NET Framework 4.6 以降、.NET Core 3.1 以降、そして .NET 6/7 で動作します。
「extract specific pages pdf」とは何か?
extract specific pages pdf は、既存の PDF(またはサポートされているドキュメント)から1ページまたは複数ページを取り出し、それらのページだけを含む新しい PDF を作成する操作を指します。これにより、元のファイルをそのままにして、関連するセクションだけを共有できます。
GroupDocs.Mergerで特定ページのPDFを抽出する理由
GroupDocs.Merger は 50 以上のファイル形式 に対応し、500 ページ以上 のドキュメントからページを抽出する場合でも、一般的なサーバークラスの CPU で 2 秒未満 で処理できます。API は Microsoft Office や Adobe Acrobat のインストールを必要としないため、導入の複雑さとライセンスコストを削減できます。
前提条件
- .NET 6 SDK(または .NET Core 3.1 / .NET Framework 4.6+)が開発マシンにインストールされていること。
- プロジェクトに有効な GroupDocs.Merger for .NET NuGet パッケージ(
GroupDocs.Merger)が追加されていること。 - (オプション)評価期間を超えてコードを実行する場合は、一時またはフルライセンスファイルが必要です。
C#でGroupDocs.Mergerを使用して特定ページのPDFを抽出する方法
Load the source document, specify the pages you need, and save the result. The library abstracts all format‑specific details, so the same code works for PDF, DOCX, PPTX, and more.
Load your source file and call the Extract method with the desired page numbers. The Extract method creates a new document containing only the specified pages. The method returns a new Document object that you can immediately save. A Document object represents an in‑memory representation of the resulting file.
ステップ1: Mergerインスタンスの作成
The Merger class is the entry point for loading and manipulating documents. Instantiate the Merger class by passing the path of the source file. This object represents the document you will work with.
ステップ2: 抽出するページの指定
Provide a list of page indexes (1‑based) or a range string such as "1-3,5" to tell the library which pages to keep.
ステップ3: 抽出したドキュメントの保存
Call Save on the Document object, supplying the output path and desired format (e.g., SaveFormat.Pdf). SaveFormat is an enumeration that specifies the output file type, such as PDF. The operation writes a new file containing only the selected pages.
一般的な問題と解決策
- ページが1つずれている: GroupDocs.Merger は 1 ベースのページ番号を使用します。リストが 0 ではなく 1 から始まっていることを確認してください。
- パスワード保護されたファイル: パスワードを
Mergerコンストラクタに渡すか、LoadOptionsオブジェクトを使用してください。LoadOptionsはドキュメントの読み込み方法を制御する設定(例: メモリキャッシュの有効化)を提供します。 - 大きなファイルでタイムアウトが発生する:
LoadOptions.UseMemoryCache = trueを設定してストリーミングを有効にし、メモリ使用量を低く保ちます。
よくある質問
Q: Word ドキュメントからページを抽出して PDF にできますか?
A: はい。Extract 呼び出しは DOCX でも機能し、結果を SaveFormat.Pdf を使用して直接 PDF として保存できます。
Q: 連続しないページを抽出できますか?
A: もちろんです。"2,4,7" のようなカンマ区切りリストや、"1-2,5,8-10" のような混合範囲を指定してください。
Q: ライブラリは暗号化された PDF をサポートしていますか?
A: はい。ドキュメントを開く際にパスワードを提供すれば、API が自動的に復号します。
Q: GroupDocs.Merger は PDF 内の画像をどのように扱いますか?
A: 画像は選択したページ上に表示されている通りに正確に保持され、追加の変換ステップは不要です。
Q: 公式にサポートされている .NET バージョンは何ですか?
A: .NET Framework 4.6 以降、.NET Core 3.1 以降、そして .NET 5/6/7 が完全にサポートされています。
利用可能なチュートリアル
GroupDocs.Merger for .NETでドキュメントから特定ページを抽出する
Learn how to efficiently extract specific pages using GroupDocs.Merger for .NET. Ideal for managing Word, PDF, and more in professional environments.
C#でGroupDocs.Merger for .NETを使用してドキュメントから特定ページを抽出する方法
Learn how to extract specific pages from documents using GroupDocs.Merger for .NET with this comprehensive guide. Streamline your document management tasks effortlessly.
追加リソース
- GroupDocs.Merger for .net ドキュメント
- GroupDocs.Merger for .net API リファレンス
- GroupDocs.Merger for .net のダウンロード
- GroupDocs.Merger フォーラム
- 無料サポート
- 一時ライセンス
最終更新日: 2026-08-31
テスト環境: GroupDocs.Merger 23.9 for .NET
作者: GroupDocs