ページの向きと回転を設定する方法
「ページの向き」は、ページが縦方向に配置されているか横方向に配置されているかを指します。(縦方向)または水平に(横向き).
ページ回転は、ページの角度を調整することで、その向きを変更することを指します。これにより、ページの整列を修正したり、特定の表示の好みに合わせたりするのに役立ちます。 ページの角度は90度、180度、270度に設定できます。
IronPDFでは、レンダリングプロセス中に縦向きまたは横向きを指定することができます。 さらに、新しくレンダリングされたPDFページや既存のPDFページを、必要に応じて0度、90度、180度、または270度の角度に個別に回転させることができます。
ページの向きと回転を設定する方法
今日から無料トライアルでIronPDFをあなたのプロジェクトで使い始めましょう。
ページの向きの例
他の形式からPDFドキュメントを生成する場合にのみ、向きを設定できます。 次のクラスからPaperOrientationプロパティにアクセスできます: RenderingOptionsクラス。 このプロパティは、縦向きまたは横向きに設定することができます。 縦向きはデフォルトのページの向き設定です。
コード
: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")
PDFを出力
ページ回転の例
IronPDFで提供される回転度数は次の4種類です:
- None: 0度または回転されていないドキュメント。
- Clockwise90: 時計回りに90度回転。
- Clockwise180: 時計回りに180度回転。
-
Clockwise270: 時計回りに270度回転します。
次の内容にご注意ください。
以下に記載されているすべてのページインデックス位置は、ゼロベースのインデックス付けに従います。
ページの回転を設定
以下の方法を使用して単一ページ、複数ページ、またはすべてのページの回転を設定します。
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")
PDFを出力
ページ回転を取得
GetPageRotation
メソッドを使用して、PDFドキュメントの特定のページの回転を取得します。 ページインデックスをメソッドに単純に指定します。
: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)