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

  • SEARCH
  • Home
  • 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 4024980
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:47:22+00:00 2026-05-20T10:47:22+00:00

The code below is intended to display the pages of a PDF while properly

  • 0

The code below is intended to display the pages of a PDF while properly handling any non-zero rotation angles that might be specified for each page. My test PDF file has multiple pages and one them has a 180 degree rotation angle, which the code properly detects, but the call to CGPDFPageGetDrawingTransform (followed by CGContextContactCTM) has no effect. The page is being displayed unrotated. What am I doing wrong?

CGContextSaveGState(context);

CGRect drawRect=self.bounds;
CGRect cropBox = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);

int rotationAngle=CGPDFPageGetRotationAngle(pdfPage);

if (kDebug>1) {
    NSLog(@"***** page rotation angle is %d",rotationAngle);
}

CGContextTranslateCTM(context, drawRect.origin.x, drawRect.origin.y);

CGAffineTransform transform = CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox, cropBox, rotationAngle, true);
CGContextConcatCTM (context, transform);

float xScaleFactor=drawRect.size.width / cropBox.size.width;
float yScaleFactor=drawRect.size.height / cropBox.size.height;

CGContextTranslateCTM(context, -CGRectGetMinX(cropBox), CGRectGetMaxY(cropBox)*yScaleFactor);
CGContextScaleCTM(context, xScaleFactor, -yScaleFactor);

CGContextClipToRect(context, cropBox);
CGContextDrawPDFPage(context, pdfPage);

CGContextRestoreGState(context);

Thanks,

//Scott

  • 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-20T10:47:23+00:00Added an answer on May 20, 2026 at 10:47 am

    So after a careful re-reading of the API for CGPDFPageGetDrawingTransform, I discover that the value of page’s /ROTATE attribute is ADDED to the rotation angle you specify in the method call. In my situation above, the page’s /ROTATE happend to be 180. was grabbing that in the rotationAngle var and passing that in to get the transform. So, 180+180 = 360 = no visibile rotation.

    I now call GPDFPageGetDrawingTransform with a rotation angle of 0.0. Anything in the /ROTATE is added, and voila, I get the correct results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code snippet below is intended to open a specific worksheet of a specific
I have code that is intended to show the user the number of remaining
I have a base Class akin to the code below. I'm attempting to overload
I have a text box that is intended for an Email address. I am
server: apache http server 2.2 problem: code does not load my text file hello
I would like to display the time stamp of 00:00:00 1 Nov 2010 with
Clarification This is part of a script that checks if a user has changed
I'm writing a bolt-on bit of javascript which is intended to capture information when
I am trying to write a sproc with a transaction. Can anybody tell me
I am trying to create a list containing the permutations of a given type

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.