iTextSharpにドキュメントがあります。デフォルトの「pagesize」を「A4」に設定したいのですが、ここでは、を使用して回転する必要のある特別なページ(これらのページのみ)がありA4.Rotate()
ます。
document.setpagesize(A4.Rotate())
ページを回転させます。
英語が下手でごめんなさい。
iTextSharpにドキュメントがあります。デフォルトの「pagesize」を「A4」に設定したいのですが、ここでは、を使用して回転する必要のある特別なページ(これらのページのみ)がありA4.Rotate()
ます。
document.setpagesize(A4.Rotate())
ページを回転させます。
英語が下手でごめんなさい。
これが例です。4 ページの PDF ファイルを作成します。ページ 1、2、および 4 は A4 縦モードを使用し、ページ 3 は A4 横モードを使用します。
class Program
{
static void Main(string[] args)
{
Document doc = new Document(PageSize.A4);
using (var stream = new FileStream("test.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
{
var writer = PdfWriter.GetInstance(doc, stream);
doc.Open();
doc.NewPage();
doc.Add(new Paragraph("Page1 (portrait A4)"));
doc.NewPage();
doc.Add(new Paragraph("Page2 (portrait A4)"));
// Set page size before calling NewPage
doc.SetPageSize(PageSize.A4.Rotate());
doc.NewPage();
doc.Add(new Paragraph("Page3 (landscape A4)"));
// Revert to the original page size before adding new pages
doc.SetPageSize(PageSize.A4);
doc.NewPage();
doc.Add(new Paragraph("Page4 (portrait A4)"));
doc.Close();
}
}