Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5967877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:00:28+00:00 2026-05-22T20:00:28+00:00

How do I rotate the second page of my PdF when I’m using iText.

  • 0

How do I rotate the second page of my PdF when I’m using iText.

The first and other pages I would like to stay in the same orientation.

I know of …

Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);

But that will rotate everything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:00:29+00:00Added an answer on May 22, 2026 at 8:00 pm

    From http://itextpdf.com/examples/iia.php?id=232 :

    /*
     * This class is part of the book "iText in Action - 2nd Edition"
     * written by Bruno Lowagie (ISBN: 9781935182610)
     * For more info, go to: http://itextpdf.com/examples/
     * This example only works with the AGPL version of iText.
     */
    
    package part4.chapter13;
    
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    import part1.chapter03.MovieTemplates;
    
    import com.itextpdf.text.DocumentException;
    import com.itextpdf.text.pdf.PdfDictionary;
    import com.itextpdf.text.pdf.PdfName;
    import com.itextpdf.text.pdf.PdfNumber;
    import com.itextpdf.text.pdf.PdfReader;
    import com.itextpdf.text.pdf.PdfStamper;
    
    public class RotatePages {
    
        /** The resulting PDF. */
        public static final String RESULT
            = "results/part4/chapter13/timetable_rotated.pdf";
    
        /**
         * Manipulates a PDF file src with the file dest as result
         * @param src the original PDF
         * @param dest the resulting PDF
         * @throws IOException
         * @throws DocumentException
         */
        public void manipulatePdf(String src, String dest)
            throws IOException, DocumentException {
            PdfReader reader = new PdfReader(MovieTemplates.RESULT);
            int n = reader.getNumberOfPages();
            int rot;
            PdfDictionary pageDict;
            for (int i = 1; i <= n; i++) {
                rot = reader.getPageRotation(i);
                pageDict = reader.getPageN(i);
                pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90));
            }
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT));
            stamper.close();
            reader.close();
        }
    
        /**
         * Main method creating the PDF.
         * @param    args    no arguments needed
         * @throws DocumentException 
         * @throws IOException 
         */
        public static void main(String[] args)
            throws IOException, DocumentException {
            new MovieTemplates().createPdf(MovieTemplates.RESULT);
            new RotatePages().manipulatePdf(MovieTemplates.RESULT, RESULT);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am using jquery rotate plugin to rotate a image on the page,
I've got a div that I would like to rotate about its y-axis (with
When you rotate an image using canvas, it'll get cut off - how do
How do you rotate an image using jQuery-rotate plugin? I have tried the following
I am having trouble keeping my first and second rows of my main PdfPTable
I have a list of around 30 divs (see below.) and would like to
Why does using a primitive data type work in the second for-each loop when
I have this page that i have a rotate slideshow running. I have it
I have a function that makes a gear rotate on the page after an
My application has android:configChanges=keyboardHidden|orientation set in the manifest file. When I rotate my device,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.