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

TOPIC:

Thumbnails for PDF pages are distorted 8 years 6 months ago #9739

  • deepaksharma
  • deepaksharma's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
If asked for a thumbnail image with small width and height, the image generated seems quite distorted with single lines appearing choppy though the original PDF page is very clear.
We have tried to get thumbnail with width 100 and height 80.
If asked for a thumbnail with higher width and height, the image generated is quite clear.

We are using the below code to get thumbnail previews for PDF pages

PDF_DIB m_dib = NULL;
PDF_DIB bmp = Global_dibGet(m_dib, imageWidth, imageHeight);
float ratiox = imageWidth/w;
float ratioy = imageHeight/h;

if (ratiox>ratioy) {
ratiox = ratioy;
}
ratiox = ratiox * 1.0;
PDF_MATRIX mat = Matrix_createScale(ratiox, -ratiox, 0, h * ratioy);
Page_renderPrepare(page.handle, bmp);
Page_render(page.handle, bmp, mat, false, 1);
Matrix_destroy(mat);
page = nil;

void *data = Global_dibGetData(bmp);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, data, imageWidth * imageHeight * 4, NULL);
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef imgRef = CGImageCreate(imageWidth, imageHeight, 8, 32, imageWidth<<2, cs, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault);
CGColorSpaceRelease(cs);
CGDataProviderRelease(provider);

UIImage *imgDef = [UIImage imageWithCGImage:imgRef];

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

Thumbnails for PDF pages are distorted 8 years 6 months ago #9742

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

can you share the pdf used for this test?
also a screenshot could help to better understand your issue.

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

  • Page:
  • 1
Powered by Kunena Forum