How to Organize your PDFs in C#

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDFは、PDF生成機能を超えて、PDFドキュメントの構造を整理するために活用できる包括的なツールセットを提供します。 PDFの構造を編集するのがこれほど簡単なことはありませんでした。 PDFの構造を操作し、ブックマークや添付ファイルを追加し、理想的なPDFレイアウトを1つのライブラリで作成します。 IronPDFを使えば、PDFの整理に苦労することはもうありません。

この包括的なチュートリアルでは、IronPDFを使用してPDFドキュメントをより良く整理する方法を探ります。 これを行うために、基本的な例に従って、これらの整理機能がどのように機能するかを説明し、コード例とその対応する説明を確認します。 この記事の最後には、PDF整理のためにIronPDFをすぐに使い始める準備が整っています。

クイックスタート: IronPDFでPDFを簡単にマージ

IronPDFを使用して、わずか数行のコードでPDFを整理することから始めましょう。 この例では、IronPDFライブラリを使用して複数のPDFドキュメントを1つに簡単にマージできることを示しています。 迅速でシンプルなソリューションを求める開発者に最適なこの方法は、C#プロジェクトにシームレスに統合され、ドキュメント管理の効率を向上させます。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    IronPdf.PdfDocument.Merge(
        IronPdf.PdfDocument.FromFile("file1.pdf"), 
        IronPdf.PdfDocument.FromFile("file2.pdf"))
        .SaveAs("merged.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

目次

今日あなたのプロジェクトでIronPDFを無料トライアルで使用開始。

最初のステップ:
green arrow pointer
NuGet 購入の準備ができていませんか?

PM >  Install-Package IronPdf

IronPDFNuGet でチェックしてください。1000万回以上のダウンロードで、C#によるPDF開発を変革しています。 DLL または Windowsインストーラー をダウンロードすることもできます。

PDF構造を整理する

まず、PDFファイルの構造を制御するためにIronPDFが提供するいくつかの機能を見てみましょう。 これらのツールを使用すると、PDFドキュメント内のページを簡単に操作し、その位置を制御することができます。

PDFページを管理する

新しいページを追加することでPDFドキュメントに新しいコンテンツを追加したり、不要なページを削除したり、特定のページをコピーして重複を作成することができます。 PDF内のページを操作することで、必要に応じてPDFを再構築することができます。

ページを追加

わずか数行のコードでPDFに新しいページを追加します。 IronPDFを使用すると、PDFファイルに新しいコンテンツを簡単に追加できます。

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-add.cs
using IronPdf;

// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");

// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");

// Merge the two documents
PdfDocument finalPdf = PdfDocument.Merge(coverPage, contentPage);

finalPdf.SaveAs("pdfWithCover.pdf");
Imports IronPdf

' Import cover page
Private coverPage As PdfDocument = PdfDocument.FromFile("coverPage.pdf")

' Import content document
Private contentPage As PdfDocument = PdfDocument.FromFile("contentPage.pdf")

' Merge the two documents
Private finalPdf As PdfDocument = PdfDocument.Merge(coverPage, contentPage)

finalPdf.SaveAs("pdfWithCover.pdf")
$vbLabelText   $csharpLabel

この方法は、新しいページを追加するプロセスを簡素化します。 マルチページPDFドキュメントの特定のインデックスに新しいページを追加するには、InsertPdfメソッドを使用してこれを簡単に達成できます。

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-insert.cs
using IronPdf;

// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");

// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");

// Insert PDF
contentPage.InsertPdf(coverPage, 0);
Imports IronPdf

' Import cover page
Private coverPage As PdfDocument = PdfDocument.FromFile("coverPage.pdf")

' Import content document
Private contentPage As PdfDocument = PdfDocument.FromFile("contentPage.pdf")

' Insert PDF
contentPage.InsertPdf(coverPage, 0)
$vbLabelText   $csharpLabel

ページをコピー

PDFドキュメント内でページをコピーすることにより、一貫したスタイルを維持し、複数のPDFファイルに情報を転送することができます。 IronPDFのCopyPageCopyPagesメソッドは、わずか数行のコードでPDF内の特定のページを複製する簡単な方法を提供します。

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-copy.cs
using IronPdf;
using System.Collections.Generic;

// Copy a single page into a new PDF object
PdfDocument myReport = PdfDocument.FromFile("report_final.pdf");
PdfDocument copyOfPageOne = myReport.CopyPage(0);

// Copy multiple pages into a new PDF object
PdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
Imports IronPdf
Imports System.Collections.Generic

' Copy a single page into a new PDF object
Private myReport As PdfDocument = PdfDocument.FromFile("report_final.pdf")
Private copyOfPageOne As PdfDocument = myReport.CopyPage(0)

' Copy multiple pages into a new PDF object
Private copyOfFirstThreePages As PdfDocument = myReport.CopyPages(New List(Of Integer) From {0, 1, 2})
$vbLabelText   $csharpLabel

ページを削除

PDFから特定のページを削除するには、RemovePageRemovePagesメソッドを使用すると、プログラム的に不要なページをドキュメントから削除できます。

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-delete.cs
using IronPdf;
using System.Collections.Generic;

PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");

// Remove a single page
pdf.RemovePage(0);

// Remove multiple pages
pdf.RemovePages(new List<int> { 2, 3 });
Imports IronPdf
Imports System.Collections.Generic

Private pdf As PdfDocument = PdfDocument.FromFile("full_report.pdf")

' Remove a single page
pdf.RemovePage(0)

' Remove multiple pages
pdf.RemovePages(New List(Of Integer) From {2, 3})
$vbLabelText   $csharpLabel

上記のコードスニペットの詳細な説明と追加機能を探るには、包括的なハウツーガイドを参照してください。

PDFをマージまたは分割

PDFをマージ

IronPDFのマージツールを使用して、複数のPDFドキュメントを1つの共有しやすいPDFに結合します。 この機能は、類似のドキュメントをグループ化して配布を容易にしたり、個々のページを新しいPDFにマージしたり、様々なPDFのマージタスクを実行する際に特に便利です。 IronPDFのマージツールを使用すると、Mergeメソッドを利用してこのプロセスを簡単に自動化することができます。

:path=/static-assets/pdf/content-code-examples/how-to/merge-or-split-pdfs-merge.cs
using IronPdf;

// Two paged PDF
const string html_a =
    @"<p> [PDF_A] </p>
    <p> [PDF_A] 1st Page </p>
    <div style = 'page-break-after: always;' ></div>
    <p> [PDF_A] 2nd Page</p>";

// Two paged PDF
const string html_b =
    @"<p> [PDF_B] </p>
    <p> [PDF_B] 1st Page </p>
    <div style = 'page-break-after: always;' ></div>
    <p> [PDF_B] 2nd Page</p>";

var renderer = new ChromePdfRenderer();

var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);

// Four paged PDF
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
Imports IronPdf

' Two paged PDF
Private Const html_a As String = "<p> [PDF_A] </p>
    <p> [PDF_A] 1st Page </p>
    <div style = 'page-break-after: always;' ></div>
    <p> [PDF_A] 2nd Page</p>"

' Two paged PDF
Private Const html_b As String = "<p> [PDF_B] </p>
    <p> [PDF_B] 1st Page </p>
    <div style = 'page-break-after: always;' ></div>
    <p> [PDF_B] 2nd Page</p>"

Private renderer = New ChromePdfRenderer()

Private pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
Private pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)

' Four paged PDF
Private merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
merged.SaveAs("Merged.pdf")
$vbLabelText   $csharpLabel

PDFを分割

複数のPDFを1つの簡単に共有できるPDFドキュメントにマージしたい場合もありますが、逆に、マルチページPDFファイルを別のドキュメントに分割したいこともあります。

:path=/static-assets/pdf/content-code-examples/how-to/merge-or-split-pdfs-split.cs
using IronPdf;

// We will use the 4-page PDF from the Merge example above:
var pdf = PdfDocument.FromFile("Merged.pdf");

// Takes only the first page into a new PDF
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Page1Only.pdf");

// Take the pages 2 & 3 (Note: index starts at 0)
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Pages2to3.pdf");
Imports IronPdf

' We will use the 4-page PDF from the Merge example above:
Private pdf = PdfDocument.FromFile("Merged.pdf")

' Takes only the first page into a new PDF
Private page1doc = pdf.CopyPage(0)
page1doc.SaveAs("Page1Only.pdf")

' Take the pages 2 & 3 (Note: index starts at 0)
Dim page23doc = pdf.CopyPages(1, 2)
page23doc.SaveAs("Pages2to3.pdf")
$vbLabelText   $csharpLabel

上記のコードスニペットの詳細な説明と追加機能を探るには、包括的なハウツーガイドを参照してください。

マルチページPDFを分割

マルチページPDFを分割するには、シングルページPDFを分割する方法と同様のアプローチをとります。 この場合、forループを使用してタスクを達成します。

:path=/static-assets/pdf/content-code-examples/how-to/split-multipage-pdf-split-pdf.cs
using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");

for (int idx = 0; idx < pdf.PageCount; idx++)
{
    // Create new document for each page
    PdfDocument outputDocument = pdf.CopyPage(idx);

    string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf";

    // Export to new file
    outputDocument.SaveAs(fileName);
}
Imports IronPdf

Private pdf As PdfDocument = PdfDocument.FromFile("multiPage.pdf")

For idx As Integer = 0 To pdf.PageCount - 1
	' Create new document for each page
	Dim outputDocument As PdfDocument = pdf.CopyPage(idx)

	Dim fileName As String = $"multiPage - Page {idx + 1}_tempfile.pdf"

	' Export to new file
	outputDocument.SaveAs(fileName)
Next idx
$vbLabelText   $csharpLabel

上記のコードスニペットの詳細な説明と追加機能を探るには、包括的なハウツーガイドを参照してください。

整理ツール

このセクションでは、IronPDFが提供するPDFドキュメントの整理を改善するためのいくつかのツールを詳しく検討します。 これらのツールを活用することで、PDFドキュメントを強化し、多ページのコンテンツを読みやすくすることができます。

添付ファイルの追加・削除

添付ファイルを介して、補足資料、関連コンテンツなどをリンクすることで、PDFファイルを向上させます。 特定のページに追加資料、データ、画像を含めることで、不要なページでドキュメントを乱雑にすることを避け、ナビゲーションを容易にします。 IronPDFを使えば、添付ファイルを簡単に追加または削除し、PDFを常に関連性のあるスリムな状態に保つことができます。

添付ファイルを追加

:path=/static-assets/pdf/content-code-examples/how-to/add-remove-attachments-add-attachment.cs
using IronPdf;
using System.IO;

// Import attachment file
byte[] fileData = File.ReadAllBytes(@"path/to/file");

// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData);

pdf.SaveAs("addAttachment.pdf");
Imports IronPdf
Imports System.IO

' Import attachment file
Private fileData() As Byte = File.ReadAllBytes("path/to/file")

' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")

' Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData)

pdf.SaveAs("addAttachment.pdf")
$vbLabelText   $csharpLabel

添付ファイルを削除

:path=/static-assets/pdf/content-code-examples/how-to/add-remove-attachments-remove-attachment.cs
using IronPdf;
using System.Linq;

// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");

// Add attachment to the PDF
PdfAttachmentCollection retrieveAttachments = pdf.Attachments;

// Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First());

pdf.SaveAs("removeAttachment.pdf");
Imports IronPdf
Imports System.Linq

' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("addAttachment.pdf")

' Add attachment to the PDF
Private retrieveAttachments As PdfAttachmentCollection = pdf.Attachments

' Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First())

pdf.SaveAs("removeAttachment.pdf")
$vbLabelText   $csharpLabel

上記のコードスニペットの詳細な説明と追加機能を探るには、包括的なハウツーガイドを参照してください。

アウトラインとブックマーク

マルチページPDFドキュメントでアウトラインを使用することで、ドキュメントの使いやすさが大幅に向上し、読者が特定のページに簡単に移動できるようになります。 IronPDFを使用すると、カスタマイズされたアウトラインを作成し、ブックマークを追加して読者にシームレスなナビゲーション体験を提供できます。 同様に、PDF内の現在のブックマークをリストで取得して、アウトラインの現在の構造をすばやく確認することができます。

ブックマークを追加

IronPDFは、単一階層および複数階層のブックマークの両方をサポートし、PDFドキュメントのアウトラインの詳細レベルを完全に制御でき、特定のニーズやPDFファイルの長さに合わせて調整できます。

:path=/static-assets/pdf/content-code-examples/how-to/bookmarks-single-layer-bookmark.cs
using IronPdf;

// Create a new PDF or edit an existing document.
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");

// Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);

// Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);

pdf.SaveAs("singleLayerBookmarks.pdf");
Imports IronPdf

' Create a new PDF or edit an existing document.
Private pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")

' Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0)

' Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1)

pdf.SaveAs("singleLayerBookmarks.pdf")
$vbLabelText   $csharpLabel

ブックマークを取得

PDFドキュメント内の既存のブックマークを確認するには、GetAllBookmarksツールを使用して、任意のPDFファイルに含まれるすべてのブックマークの総合的なリストを簡単に取得できます。

:path=/static-assets/pdf/content-code-examples/how-to/bookmarks-retrieve-bookmark.cs
using IronPdf;

// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");

// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();
Imports IronPdf

' Load existing PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("multiLayerBookmarks.pdf")

' Retrieve bookmarks list
Private mainBookmark = pdf.Bookmarks.GetAllBookmarks()
$vbLabelText   $csharpLabel

上記のコードスニペットの詳細な説明と追加機能を探るには、包括的なハウツーガイドを参照してください。

結論

PDFの管理は、IronPDFを使用することで簡単になります。 このツールは、ページの管理、ドキュメントのマージまたは分割、アウトラインの作成、添付ファイルの処理など、クリーンでシンプルなC#コードで行うことができる広範な機能を提供します。 新しいドキュメントを作成する場合でも、既存のドキュメントを再構築する場合でも、IronPDFを使用すると、ナビゲートおよび共有が容易な洗練されたプロフェッショナルなPDFを作成することができます。

IronPDFについての質問や機能のリクエストがある場合は、サポートチームにご連絡ください。 お手伝いできることを嬉しく思います。

よくある質問

C#を使ってPDFを整理するにはどうすればいいですか?

C#でPDFを整理し始めるためには、IronPDFライブラリを使用します。このライブラリは、PDFファイルを効率的に操作し整理するための包括的な機能を提供します。

IronPDFはPDF整理のためにどのような機能を提供していますか?

IronPDFは、PDF文書内でのページのマージ、スプリット、抽出、並べ替えなどの機能を提供し、ファイルを簡単に整理できます。

IronPDFを使ってPDFから特定のページを抽出することは可能ですか?

はい、IronPDFはPDFから特定のページを抽出することができ、選択したコンテンツから新しい文書を作成できます。

IronPDFは複数のPDFファイルの結合に役立ちますか?

IronPDFは複数のPDFファイルをシームレスに1つの文書に結合する機能を提供し、文書管理をより簡単にします。

IronPDFはPDFを複数の文書に分割することをサポートしていますか?

はい、IronPDFはPDFを複数の文書に分割することをサポートしており、必要に応じてコンテンツを分割できます。

IronPDFはPDFページの並べ替えをどのように処理しますか?

IronPDFを使用すると、PDF文書内のページを簡単に並べ替えることができ、コンテンツ構造の編成に柔軟性を持たせることができます。

IronPDFはPDFを画像に変換することができますか?

IronPDFにはPDFページを画像に変換する機能が含まれており、プレビューの作成や異なる形式でのコンテンツ共有に役立ちます。

PDFを整理するためにIronPDFを使用するにはどのようなプログラミングスキルが必要ですか?

C#プログラミングの基本的な知識があれば、IronPDFを使用してPDFを整理することができます。このライブラリは簡単なメソッドと例を提供します。

IronPDFはPDFメタデータの追加と変更をサポートしていますか?

はい、IronPDFを使用すると、PDFメタデータを追加および変更でき、ドキュメント情報を効果的に管理できます。

IronPDFは企業レベルのPDF管理ソリューションに適していますか?

IronPDFは堅牢でスケーラブルに設計されており、小規模プロジェクトから企業レベルのPDF管理ソリューションまで適しています。

IronPDF は .NET 10 と互換性がありますか?

はい。IronPDFは、.NET 10に加え、.NET 9、8、7、6、.NET Core、.NET Standard、.NET Frameworkを完全にサポートしています。クロスプラットフォームで、Windows、macOS、Linux、Docker、Azure、AWSで動作し、C#、F#、VB.NETのプロジェクトタイプをサポートしています。

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'name'

Filename: sections/author_component.php

Line Number: 18

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 18
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/tutorials/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Tutorials.php
Line: 29
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'title'

Filename: sections/author_component.php

Line Number: 38

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 38
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/tutorials/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Tutorials.php
Line: 29
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'comment'

Filename: sections/author_component.php

Line Number: 48

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 48
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/tutorials/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Tutorials.php
Line: 29
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

準備はいいですか?
Nuget ダウンロード 16,133,208 | バージョン: 2025.11 ただ今リリースされました