.NET C# でページの方向と回転を設定する方法 | IronPDF

How to Set Page Orientation and Rotation

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

ページの向きは、ページが縦向き(ポートレート)か横向き(ランドスケープ)で配置されているかを指します。

ページの回転はページの角度を調整するもので、向きを変更することで、整列を修正したり特定の表示の好みに合わせるのに便利です。 ページの角度は90度、180度、270度に設定できます。

IronPDFを使用すると、レンダリングプロセス中に縦向きか横向きのいずれかの向きを指定できます。 さらに、新たにレンダリングされたPDFページや既存のPDFページを、必要に応じて0度、90度、180度、270度の角度に個別に回転させることができます。

クイックスタート:C#でPDFページの向きと回転を設定する

IronPDFを使用して、.NET C#内のPDFファイルのページの向きと回転を簡単に設定できます。 PDFをロードした後、簡単なメソッドコールで希望の回転や向きを適用します。 更新されたドキュメントを迅速に保存し、レイアウトが特定の要件を満たしていることを確認します。 このクイックガイドは手間をかけずに始めるのに役立ちます。

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.FromFile("file.pdf")
        .SetAllPageRotations(IronPdf.PdfDocument.PageRotation.Rotate90)
        .SaveAs("rotated.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

ミニマルワークフロー(5ステップ)

  1. IronPDF C# ライブラリをダウンロードしてPDFページの向きと回転を設定
  2. レンダリング前にページの向きを設定するにはPaperOrientationプロパティを使用
  3. IronPDFでのすべてのページ回転オプションを探索
  4. 個別または複数のPDFページを回転させる方法を学習
  5. IronPDFでPDFページの回転を取得


ページの向きの例

向きの設定は、他の形式からPDFドキュメントを生成する場合にのみ可能です。 RenderingOptionsクラスからPaperOrientationプロパティにアクセスできます。 このプロパティは縦向きまたは横向きに設定できます。 縦向きがデフォルトのページ向き設定です。

コード

:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-orientation.cs
using IronPdf;
using IronPdf.Rendering;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Change paper orientation
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;

PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");

pdf.SaveAs("landscape.pdf");
Imports IronPdf
Imports IronPdf.Rendering

Private renderer As New ChromePdfRenderer()

' Change paper orientation
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape

Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page")

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

出力PDF


ページの回転の例

IronPDFが提供する4つの可能な回転角度があります:

  • None: 0度または回転なしのドキュメント。
  • Clockwise90: 90度時計回り。
  • Clockwise180: 180度時計回り。
  • Clockwise270: 270度時計回り。

[{i:(以下に述べるすべてのページインデックス位置はゼロベースのインデックスを使用します。)}]

ページの回転を設定

以下のメソッドを使用して、単一ページ、複数ページ、またはすべてのページの回転を設定します。

  • SetAllPageRotations: すべてのページの回転角度を設定します。
  • SetPageRotation: 単一ページの回転角度を設定します。
  • SetPageRotations: 選択したページリストの回転角度を設定します。
:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-set-rotation.cs
using IronPdf;
using IronPdf.Rendering;
using System.Collections.Generic;

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

// Set all pages
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90);

// Set a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180);

// Set multiple pages
List<int> selectedPages = new List<int>() { 0, 3 };
pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270);

pdf.SaveAs("rotatedLandscape.pdf");
Imports IronPdf
Imports IronPdf.Rendering
Imports System.Collections.Generic

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

' Set all pages
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90)

' Set a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180)

' Set multiple pages
Dim selectedPages As New List(Of Integer)() From {0, 3}
pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270)

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

出力PDF

ページの回転を取得

任意のページの回転をPDFドキュメント内で取得するには、GetPageRotationメソッドを使用します。 メソッドにページインデックスを指定するだけです。

:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-get-rotation.cs
using IronPdf;
using IronPdf.Rendering;

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

PdfPageRotation rotation = pdf.GetPageRotation(1);
Imports IronPdf
Imports IronPdf.Rendering

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

Private rotation As PdfPageRotation = pdf.GetPageRotation(1)
$vbLabelText   $csharpLabel

よくある質問

C#を使用してPDFのページの向きを設定するにはどうすればよいですか?

IronPDFのRenderingOptionsクラスからPaperOrientationプロパティを使用してページの向きを設定できます。このプロパティは、PDFのレンダリング前に縦向きまたは横向きに設定できます。

PDFページの可能な回転角度は何ですか?

IronPDFでは、0度(なし)、90度(時計回り90)、180度(時計回り180)、270度(時計回り270)の4つの角度にPDFページを回転できます。

C#を使ってPDFドキュメント内のすべてのページを回転させるにはどうすればよいですか?

IronPDFのSetAllPageRotationsメソッドを使用して、必要な回転角度(例:PdfPageRotation.Clockwise90)を指定することで、PDFドキュメント内のすべてのページを回転できます。

C#を使用してPDFの特定のページを回転させることは可能ですか?

はい、IronPDFのSetPageRotationメソッドを使用して単一ページを、または複数のページのインデックスを指定してSetPageRotationsメソッドを使用して回転させることができます。

PDFページの現在の回転をどのように判断できますか?

IronPDFのGetPageRotationメソッドを使用して、ページインデックスを指定することで特定のページの回転角度を取得できます。

新しいPDFを作成するときのデフォルトのページの向きは何ですか?

IronPDFで新しいPDFを作成するときのデフォルトのページの向きは縦向きです。

PDF内のページの向きと回転を操作するために追加のライブラリが必要ですか?

はい、PDF内のページの向きと回転を操作するには、IronPDF C#ライブラリをダウンロードする必要があります。

C#でPDF操作にIronPDFを使用する利点は何ですか?

IronPDFは、ページの向きと回転の設定を含む、C#でPDFドキュメントの作成、編集、操作のための包括的なツールセットを提供します。これは、ドキュメントのプレゼンテーションを向上させ、特定の表示の好みに合わせるのに役立ちます。

IronPDF は、方向や回転機能を含め、.NET 10 と完全に互換性がありますか?

はい — IronPDF は、.NET 10 と以前のバージョン (.NET 9、8 など) をサポートし、すべてのページ方向および回転機能 ( RenderingOptions.PaperOrientationSetPageRotationSetAllPageRotationsGetPageRotationなど) とシームレスに連携します。

Chaknith Bin
ソフトウェアエンジニア
ChaknithはIronXLとIronBarcodeに取り組んでいます。彼はC#と.NETの深い専門知識を持ち、ソフトウェアの改善や顧客サポートに貢献しています。ユーザーとの対話から得られる洞察が、より良い製品、ドキュメント、および全体的な経験に寄与しています。
準備はいいですか?
Nuget ダウンロード 16,154,058 | バージョン: 2025.11 ただ今リリースされました