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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:23:12+00:00 2026-05-27T21:23:12+00:00

I have a problem related to pdf drawing in iPhone. When I draw the

  • 0

I have a problem related to pdf drawing in iPhone. When I draw the pdf in ipad it works fine but in iphone quality of image of page is not good. That image contains dark spots at the place of gray background.
Can anyone help me to solve this problem?

thanks.

- (UIImage *) imageForPageIndex:(NSUInteger)pageIndex {
    UIImage *image = nil;
    if ([delegate illustration_Enable])
    {
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = CGBitmapContextCreate(NULL, 
                                                     pageSize.width, 
                                                     pageSize.height, 
                                                     8,                     /* bits per component*/
                                                     pageSize.width * 4,    /* bytes per row */
                                                     colorSpace, 
                                                     kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
        CGColorSpaceRelease(colorSpace);
        CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height));

        [self renderPageAtIndex:pageIndex OnContext:context];

        CGImageRef cgimage = CGBitmapContextCreateImage(context);
        CGContextRelease(context);
        image = [UIImage imageWithCGImage:cgimage];
        CGImageRelease(cgimage);
    }
    else 
    {
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = CGBitmapContextCreate(NULL, 
                                                     pageSize.width, 
                                                     pageSize.height, 
                                                     8,                     /* bits per component*/
                                                     pageSize.width * 4,    /* bytes per row */
                                                     colorSpace, 
                                                     kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
        CGColorSpaceRelease(colorSpace);
        CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height));

        [self renderPageAtIndex:pageIndex OnContext:context];


        CGImageRef cgimage = CGBitmapContextCreateImage(context);
        CGContextRelease(context);
        image = [UIImage imageWithCGImage:cgimage];

        CGImageRelease(cgimage);
    }


    return image;

}

-(void)renderPageAtIndex:(int)index OnContext:(CGContextRef)ctx{

    if ([delegate illustration_Enable])
    {
        if (index-1 == [imageList count]) {
            return;
        }
        UIImage *image = nil;
        image = [UIImage imageWithContentsOfFile:[imageList objectAtIndex:index-1]];
        CGRect rect1 = CGRectMake(0, 0, image.size.width, image.size.height);
        CGRect rect2 = CGContextGetClipBoundingBox(ctx);
        CGAffineTransform transform = [self aspectFill:rect1 :rect2];
        CGContextConcatCTM(ctx, transform);
        CGContextDrawImage(ctx, CGRectMake(0, 0, image.size.width, image.size.height), image.CGImage);  

    }
    else 
    {
        CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index);
        CGRect rect1 = CGPDFPageGetBoxRect(page,kCGPDFMediaBox);
        CGRect rect2 = CGContextGetClipBoundingBox(ctx);
        CGAffineTransform transform;
        if (takeBookmarkImg)
        {
            transform = [self aspectFill:rect1 :rect2];
        }
        else 
        {
            transform = [self aspectFit:rect1 :rect2];
        }
        CGContextConcatCTM(ctx, transform);
        CGContextDrawPDFPage(ctx, page);
    }



}

- (CGAffineTransform) aspectFit:(CGRect)innerRect :(CGRect) outerRect {

        scaleFactor = MIN(outerRect.size.width/innerRect.size.width, outerRect.size.height/innerRect.size.height);
        baseScaleFactor = scaleFactor;
        CGAffineTransform scale = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
        CGRect scaledInnerRect = CGRectApplyAffineTransform(innerRect, scale);

        CGAffineTransform translation = 
        CGAffineTransformMakeTranslation((outerRect.size.width - scaledInnerRect.size.width) / 2 - scaledInnerRect.origin.x-(totalMoveX+moveX), 
                                         (outerRect.size.height - scaledInnerRect.size.height) / 2 - scaledInnerRect.origin.y+(totalMoveY+moveY));
        return CGAffineTransformConcat(scale, translation);
}

.

  • 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-27T21:23:12+00:00Added an answer on May 27, 2026 at 9:23 pm

    Just a wild guess as it is hard to say without some actual screenshots, but you do not use CGContextSetInterpolationQuality in your render code. Maybe CGContextSetInterpolationQuality(your_context, kCGInterpolationHigh) fixes the problem.

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

Sidebar

Related Questions

I have seen some related questions but none focusing on the specific problem I
I have read a lot of related topics here regarding this problem but I
I have the problem related to showing the button on the page. There are
I have approx 200-300 products in store But I have a problem related products
I have a problem related to the webRole debugging. Not running in a hosted
I have a problem related to Transactional boundaries and I am not able to
I have a problem related to an array data which fetched from an external
I'm using EJB3 and I have a problem related to refreshing my EntityManager .
I have a performance problem related to string comparison (in Java). I'm working on
I have problem with my widget related to performance and memory: Issue : My

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.