Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何设置特殊页面的页面大小,我只想旋转这些页面!_C#_Itextsharp_Rotation - Fatal编程技术网

C# 如何设置特殊页面的页面大小,我只想旋转这些页面!

C# 如何设置特殊页面的页面大小,我只想旋转这些页面!,c#,itextsharp,rotation,C#,Itextsharp,Rotation,我有一份文件在里面。我想将默认的“pagesize”设置为“A4”,但这里有一些特殊的页面需要使用A4.Rotate()进行旋转(仅这些页面) document.setpagesize(A4.Rotate())用于要旋转的页面 很抱歉我的英语不好。这里有一个例子。它创建了一个包含4页的PDF文件。第1、2和4页使用A4纵向模式,而第3页使用A4横向模式: class Program { static void Main(string[] args) { Docum

我有一份文件在里面。我想将默认的“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();
        }
    }

还不错,哈米德,至少我能理解你的意思,帮你整理一下。