English 中文(简体)
how to set pagesize in special pages that i want to rotate just these pages!
原标题:

I have a document in iTextSharp. I want to set the default pagesize to A4 , but here we have special pages that needed to be rotated (just these pages) using A4.Rotate().

document.setpagesize(A4.Rotate()) for the pages to be rotated.

I m sorry for my bad english.

最佳回答

Here s an example. It creates a PDF file with 4 pages. Page 1,2 and 4 use A4 portrait mode while page 3 uses A4 landscape mode:

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();
        }
    }
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签