Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

Get View,Context,Image of PDFPage

More
IP: 192.168.0.71 11 years 8 months ago #6864 by Mahesh007
I want to show all pdf page in gridvieww (Collection view). how to get view,context,image or any nsdata from PDFPage so we show all pages in gridview.please reply asap.
More
IP: 192.168.0.71 11 years 8 months ago #6866 by radaee
step 1. create PDFDIB object for render, and invoke [PDFPage renderPrepare];
step 2. render the page to PDFDIB object using [PDFPage render];
step 3. create CGImage like:
Code:
Byte *data = (Byte *)[dib data]; int w = [dib width]; int h = [dib height]; CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, w * h * 4, NULL ); CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); CGImageRef img = CGImageCreate( w, h, 8, 32, w<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault );
step 4. set CGImageRef to image view of cell.

notice: step 1 - 3 can be run on backing thread, and do not release PDFDIB object till CGImageRef object not used.
More
IP: 192.168.0.71 11 years 8 months ago #6870 by Mahesh007
i am using your step but this gives me blank image. please help on this.


PDFDIB *dib = [[PDFDIB alloc] init:100 :100];
PDFMatrix *mat = [[PDFMatrix alloc] init:10 :10 :100 :100];
[page renderPrepare:dib];
[page render:dib :mat :1];
Byte *data = (Byte *)[dib data];
int w = [dib width];
int h = [dib height];
CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, w * h * 4, NULL );
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef img = CGImageCreate( w, h, 8, 32, w<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault );
UIImage *image = [UIImage imageWithCGImage:img];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[self saveImage:image withFileName:@"mahesh" ofType:@"jpeg" inDirectory:documentsDirectory];
More
IP: 192.168.0.71 11 years 8 months ago - 11 years 8 months ago #6871 by radaee
parameters are wrong.
codes like this:
int pageNO = 0;
float scale = 1.2f;
int width = [PDFDoc pageWidth:pageNO] * scale;
int height = [PDFDoc pageHeight:pageNO] * scale;
PDFDIB *dib = [[PDFDIB alloc] init:width :height];
PDFMatrix *mat = [[PDFMatrix alloc] init: scale : -scale : 0 : height ];
[page renderPrepare:dib];
[page render:dib :mat :1];
...
Last edit: 11 years 8 months ago by .
More
IP: 192.168.0.71 11 years 8 months ago #6873 by Mahesh007
Thanks for help..
Time to create page: 0.407 seconds
Powered by Kunena Forum