Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC:

PDF rendering doesn't work on device 8 years 9 months ago #9298

  • digify
  • digify's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 7
  • Thank you received: 0
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.

Please Log in or Create an account to join the conversation.

PDF rendering doesn't work on device 8 years 9 months ago #9299

  • support
  • support's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 692
  • Thank you received: 59
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.

Please Log in or Create an account to join the conversation.

PDF rendering doesn't work on device 8 years 9 months ago #9301

  • digify
  • digify's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 7
  • Thank you received: 0
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:
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);

Please Log in or Create an account to join the conversation.

PDF rendering doesn't work on device 8 years 9 months ago #9304

  • digify
  • digify's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 7
  • Thank you received: 0
Following the previous code, I used the following to get the image out:
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.

Please Log in or Create an account to join the conversation.

PDF rendering doesn't work on device 8 years 9 months ago #9306

  • stronglee
  • stronglee's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 93
  • Thank you received: 2
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 );
The following user(s) said Thank You: digify

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum