Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to turn the page using Itextsharp

I was able to find some examples through search. However, all of the examples used PdfReader. I am only going to use PDFWriter.

Below is the code I wrote.

private void CreatePdf(string strPdfPath)
    {
        FileStream fs = new FileStream(strPdfPath, FileMode.Create, FileAccess.Write, FileShare.None);
        Document document = new Document(PageSize.A4, 45, 45, 80, 80);
        PdfWriter writer = PdfWriter.GetInstance(document, fs);
        document.Open();
        document.AddTitle("This is Title");
        document.AddCreationDate();
        Paragraph content1 = new Paragraph("This is first Page");
        document.Add(content1);

        document.NewPage();
        Paragraph content2 = new Paragraph("This is second Page");
        document.Add(content2);
        writer.Close();
        fs.Close(); }

I want to rotate the second page 90 degrees.
Please provide me with a solution.
Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could do both:

 document.open();
// Add some content in portrait
document.setPageSize(PageSize.A4.rotate());
document.newPage();
// Add some content in landscape
document.close();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading