Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-15-2011, 02:51 AM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 261
Streetboy is on a distinguished road
Default Pdf render

I am trying to render pdf in landscape using this function:

Code:
  - (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {          

 CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index + 1);
            
            CGContextTranslateCTM(ctx, 0, self.view.bounds.size.height);
            CGContextScaleCTM(ctx, 1.0, -1.0);
            
           // CGPDFPageRef page = CGPDFDocumentGetPage(pdf, currentPage);
            CGContextSaveGState(ctx);
            
            
            
            
            CGRect box = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
            
            CGContextScaleCTM(ctx, self.view.bounds.size.width/box.size.width, self.view.bounds.size.height/box.size.height);
            
            
            CGContextDrawPDFPage(ctx, page);
            CGContextRestoreGState(ctx);
}
But my pdf is upside down even words in pdf.

What to do if i want fix this ?
Streetboy is offline   Reply With Quote
Old 07-15-2011, 03:04 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

look here!
Display a PDF page on the iPhone and iPad iPDFdev - PDF development for iPhone and iPad
__________________
dany_dev is offline   Reply With Quote
Old 07-15-2011, 05:49 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 261
Streetboy is on a distinguished road
Default

Thanks, i tried to use that code but still everything is upside down. Maybe i have to change something here:

Code:
- (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex {
    NSLog(@"imageForPageIndex");
	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));
	
    

    
	[dataSource renderPageAtIndex:pageIndex inContext:context];
	
	CGImageRef image = CGBitmapContextCreateImage(context);
	CGContextRelease(context);
	
	[UIImage imageWithCGImage:image];
	CGImageRelease(image);
	
	return image;
}
There i create context.
Streetboy is offline   Reply With Quote
Old 07-15-2011, 07:02 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

1- download the sources
2- put in and load your pdf
3- if work, see the differences line per line
__________________
dany_dev is offline   Reply With Quote
Old 07-15-2011, 02:48 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 22
Splatics is on a distinguished road
Default Rotate it

have you checked the rotation?

Code:
int rotation = CGPDFPageGetRotationAngle(page);
            if (90 == rotation)
            {
                
                CGContextRotateCTM(context, 3.14/2);
}
            else if (180 == rotation)
            {
                
                CGContextRotateCTM(context, 3.14);
}
Splatics is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 360
9 members and 351 guests
apatsufas, chemistry, Kirkout, leostc, lzwasyc, MarkC, Sami Gh, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:39 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0