- Posts: 7
- Thank you received: 0
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
PDF rendering doesn't work on device
11 years 1 month ago #9298
by digify
PDF rendering doesn't work on device was created by digify
Have bought and activated the Pro license for iOS.
I'm trying to render a PDF to image to be displayed in my app. This is working perfectly fine when I run the app in the xcode simulator.
However, I can't get the DIB image when running the app on actual hardware devices (iPhone 5S with iOS7 and iPad with iOS8).
Any help pls? Thanks in advance.
I'm trying to render a PDF to image to be displayed in my app. This is working perfectly fine when I run the app in the xcode simulator.
However, I can't get the DIB image when running the app on actual hardware devices (iPhone 5S with iOS7 and iPad with iOS8).
Any help pls? Thanks in advance.
11 years 1 month ago #9299
by support
Replied by support on topic PDF rendering doesn't work on device
Are you experiencing the issue with our demo app too?
Which SDK version are you adopting?
If blank rendering is still present using our demo tool, may you provide one of your pdf file, please?
Send it opening a bug ticket in the support area.
In the description, put the full url from this forum thread.
Which SDK version are you adopting?
If blank rendering is still present using our demo tool, may you provide one of your pdf file, please?
Send it opening a bug ticket in the support area.
In the description, put the full url from this forum thread.
11 years 1 month ago #9301
by digify
Replied by digify on topic PDF rendering doesn't work on device
Yes, the demo app does work on both the simulators and actual devices.
However when integrating it into our own app with the below code, we can't get the image when running on actual devices. The same code works perfectly inside the xcode simulator.
We're using iospdfviewer 3.3.3
Here are the code:
However when integrating it into our own app with the below code, we can't get the image when running on actual devices. The same code works perfectly inside the xcode simulator.
We're using iospdfviewer 3.3.3
Here are the code:
Code:
PDF_DOC PDFDoc = Document_openMem((void *)(data.bytes), size, nil, &err);
PDF_PAGE PDFPage = Document_getPage(PDFDoc, pageNo - 1);
float w = Document_getPageWidth(PDFDoc,pageNo - 1);
float h = Document_getPageHeight(PDFDoc,pageNo - 1);
PDF_DIB PDFdib = NULL;
PDF_DIB bmp = Global_dibGet(PDFdib, w * pageScale, h * pageScale);
PDF_MATRIX mat = Matrix_createScale(pageScale, -pageScale, 0, h * pageScale);
Page_renderPrepare( PDFPage, bmp );
Page_render(PDFPage, bmp, mat,false,1);
Matrix_destroy(mat);
Page_close(PDFPage);
11 years 1 month ago #9304
by digify
Replied by digify on topic PDF rendering doesn't work on device
Following the previous code, I used the following to get the image out:
This code works in the simulator but not on actual devices.
When I comment out the last line Global_dibFree(bmp), it is now able to be displayed on actual devices.
However without that last line, the memory utilization increased tremendously, and the app/device will eventually crash when I open and close a complex PDF many times.
Code:
void *DIBdata = Global_dibGetData(bmp);
CGDataProviderRef DataProvider = CGDataProviderCreateWithData( NULL, DIBdata, (w * pageScale) * (h * pageScale) * 4, NULL );
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef imgRef = CGImageCreate( (w * pageScale), (h * pageScale), 8, 32, (int)(w * pageScale)<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, DataProvider, NULL, FALSE, kCGRenderingIntentDefault );
CGColorSpaceRelease(cs);
CGDataProviderRelease( DataProvider );
UIImage *imgs= [UIImage imageWithCGImage:imgRef];
Global_dibFree(bmp);
This code works in the simulator but not on actual devices.
When I comment out the last line Global_dibFree(bmp), it is now able to be displayed on actual devices.
However without that last line, the memory utilization increased tremendously, and the app/device will eventually crash when I open and close a complex PDF many times.
11 years 1 month ago #9306
by stronglee
Replied by stronglee on topic PDF rendering doesn't work on device
Hi,try use CGRef m_img as member variable,
for example:
void *data = Global_dibGetData(bmp);
CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, iw * ih * 4, NULL );
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
m_img = CGImageCreate( iw, ih, 8, 32, iw<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault );
CGColorSpaceRelease(cs);
CGDataProviderRelease( provider );
for example:
void *data = Global_dibGetData(bmp);
CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, iw * ih * 4, NULL );
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
m_img = CGImageCreate( iw, ih, 8, 32, iw<<2, cs, kCGBitmapByteOrder32Little|kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault );
CGColorSpaceRelease(cs);
CGDataProviderRelease( provider );
Time to create page: 0.409 seconds