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 6320051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:54:18+00:00 2026-05-24T15:54:18+00:00

I am trying to crop and then transform a UIView to a pdf file.

  • 0

I am trying to crop and then transform a UIView to a pdf file. The UIView is cropping correctly for x component, width and height. But it is taking the same y component,ie 0 for rendering.I want to crop the image 110 points from top. This is my code

UIView *tempV;
    tempV=self.view;
    CGRect fram= tempV.bounds;
    fram.origin.x=537;
    fram.origin.y=110;
    fram.size.width=404;
    fram.size.height=772;
    tempV.bounds=fram;
    NSLog(@"Mail");
    NSLog(@"%f,%f,%f,%f",tempV.bounds.origin.x,tempV.bounds.origin.y,tempV.bounds.size.width,tempV.bounds.size.height);
    NSMutableData *pdfData=[NSMutableData data];
    UIGraphicsBeginPDFContextToData(pdfData, tempV.bounds, nil);
    UIGraphicsBeginPDFPage();
    CGContextRef pdfContext= UIGraphicsGetCurrentContext();
    [tempV.layer renderInContext:pdfContext];
    UIGraphicsEndPDFContext();
    MFMailComposeViewController *mailComposer=[[[MFMailComposeViewController alloc]init] autorelease];
    mailComposer.mailComposeDelegate=self;
    [mailComposer addAttachmentData: pdfData mimeType: @"application/pdf" fileName: @"Dudel creation.pdf"];
    [pdfData writeToFile:@"Dudel creation.pdf" atomically:YES];
    [self presentModalViewController: mailComposer animated: YES];
  • 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-24T15:54:19+00:00Added an answer on May 24, 2026 at 3:54 pm

    You are doing something very wrong in your initial part of your code… I don’t even want to go there, but let me break down a few things:

    1) UIGraphicsBeginPDFContextToData second parameter is a CGRect.

    2) From what I’ve understood, you want a very specific rectangle of what’s showing on your screen and although its center is completely different from your view controller’s view (you’re trying to change both origin and size). So, why create a dependency on your view controller’s view’s bounds? (remember bounds and center always go hand in hand).

    3) So why not just get rid of the initial part of your code and do this:

    CGRect fram = CGRectMake (537, 110, 404, 772); // A rectangle with no other dependency, since you want one very specific.
    
    NSMutableData *pdfData=[NSMutableData data];
    UIGraphicsBeginPDFContextToData(pdfData, fram, nil); // Passing the newly created rectangle as the second parameter to the function.
    UIGraphicsBeginPDFPage();
    CGContextRef pdfContext= UIGraphicsGetCurrentContext();
    [tempV.layer renderInContext:pdfContext];
    UIGraphicsEndPDFContext();
    MFMailComposeViewController *mailComposer=[[[MFMailComposeViewController alloc]init] autorelease];
    mailComposer.mailComposeDelegate=self;
    [mailComposer addAttachmentData: pdfData mimeType: @"application/pdf" fileName: @"Dudel creation.pdf"];
    [pdfData writeToFile:@"Dudel creation.pdf" atomically:YES];
    [self presentModalViewController: mailComposer animated: YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to crop an image and then paste the cropped image into the
I'm currently trying to crop an image, and then save the new image. I
i am trying to upload image in yii and then crop the uploaded image
I am trying to upload a file from browser, then make one thumbnail from
I'm trying to crop a NSImage which contains a PDF. When printing I am
I am trying to do a simple crop of an image, but for some
I am trying to crop a (non background) image then scale that cropped image
I am trying to crop an image from an url and then stretch the
I'm trying to crop and scale given bitmap,But only scaling works. What am I
I'm simply trying to crop a JPEG image (no scaling) using PHP. Here is

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.