ページの向きと回転を設定する方法

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度の角度に個別に回転させることができます。


PDF 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronPdf
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

PDF 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronPdf
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

今日からプロジェクトでIronPDFを使い始めましょう。無料のトライアルをお試しください。

最初のステップ:
green arrow pointer

チェックアウト IronPDF オン Nuget 迅速なインストールと展開のために。8百万以上のダウンロード数により、PDFをC#で変革しています。

PDF 用 C# NuGet ライブラリ nuget.org/packages/IronPdf/
Install-Package IronPdf

インストールを検討してください IronPDF DLL 直接。ダウンロードして、プロジェクトまたはGACの形式で手動でインストールしてください。 IronPdf.zip

プロジェクトに手動でインストールする

DLLをダウンロード

ページの向きの例

他の形式から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")
VB   C#

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")
VB   C#

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)
VB   C#

チャクニット・ビン

ソフトウェアエンジニア

チャクニットは開発者のシャーロック・ホームズです。彼がソフトウェアエンジニアリングの将来性に気付いたのは、楽しみでコーディングチャレンジをしていたときでした。彼のフォーカスはIronXLとIronBarcodeにありますが、すべての製品でお客様を助けることに誇りを持っています。チャクニットは顧客と直接話すことで得た知識を活用して、製品自体のさらなる改善に貢献しています。彼の逸話的なフィードバックは、単なるJiraチケットを超えて、製品開発、ドキュメントおよびマーケティングをサポートし、顧客の全体的な体験を向上させます。オフィスにいないときは、機械学習やコーディングについて学んだり、ハイキングを楽しんだりしています。