How to convert a pdf file to image through coding in objective c
I have a pdf file, but i want to save it into photo album of iPhone, So that's why i want to convert it. If there is another way then please suggest me.
Thanks in advance.
How to convert a pdf file to image through coding in objective c
I have a pdf file, but i want to save it into photo album of iPhone, So that's why i want to convert it. If there is another way then please suggest me.
Thanks in advance.
CGPDFDocumentRef PDFfile;
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("iPhone Sample apps.pdf"), NULL, NULL);
PDFfile = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
CGPDFPageRef page = CGPDFDocumentGetPage(PDFfile,currentpage);
context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context,self.bounds);
CGContextTranslateCTM(context, -1.0, [self bounds].size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFArtBox, [self bounds], 0, true));
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
CGImageRef imgref;
imgref=CGBitmapContextCreateImage(context);
image= [[UIImage alloc]initWithCGImage:imgref ];