Hi,
We are using below code to output our pdf doc to images, however it seems all annot data cannot be written, is there any step we are missing? Please advise, thanks.
int totalPage = Document_getPageCount(pdfDoc);
NSMutableArray *imgDataList = [NSMutableArray arrayWithCapacity:totalPage];
for (int i=0; i<totalPage; i++) {
PDF_PAGE page = Document_getPage(pdfDoc,i);
int w = Document_getPageWidth(pdfDoc,i);
int h = Document_getPageHeight(pdfDoc,i);
PDF_DIB m_dib = NULL;
PDF_DIB bmp = Global_dibGet(m_dib, w, h);
PDF_MATRIX mat = Matrix_createScale(1, -1, 0, h);
Page_renderPrepare( page, bmp );
Page_render(page, bmp, mat,false,1);
Matrix_destroy(mat);
void *data = Global_dibGetData(bmp);
Page_close(page);
CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, w * h * 4, NULL );
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef m_img = CGImageCreate( w, h, 8, 32, w<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault );
UIImage *img = [UIImage imageWithCGImage:m_img];
[imgDataList addObject:img];
CGColorSpaceRelease(cs);
CGDataProviderRelease( provider );
}
if(pdfDoc)
{
Document_close(pdfDoc);
}
for (int i=0; i<[imgDataList count]; i++) {
NSString *imgOutputPath = [outputDir stringByAppendingString:resultantFileName];
[UIImageJPEGRepresentation((UIImage *)[imgDataList objectAtIndex:i], 1) writeToFile:imgOutputPath atomically:YES];
}