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

Writing Annot data to image

More
10 years 8 months ago #9986 by mobileAsd
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];
}
More
10 years 8 months ago #9987 by emanuele
Hi,

when you call Page_render, you have to set the bool value to true: Page_render(page, bmp, mat,true,1);
As written in the method declaration's, it is show_annots bool.
More
10 years 8 months ago #9989 by mobileAsd
Thank you, it works. Didn't realize the setting as just copy from the sample app
Time to create page: 0.454 seconds
Powered by Kunena Forum