mindbrix / UIImage-PDF

Simple UIImage PDF renderer category for iOS scalable assets
http://blog.mindbrix.co.uk/2012/02/10/ios-scalable-assets/
1.24k stars 155 forks source link

Shrinks Images Vertically #18

Closed IamAliSufyan closed 11 years ago

IamAliSufyan commented 11 years ago

I am using this brilliant library in my app, but it shrinks every pdf vertically. I could not find any workaround. Please help!

mindbrix commented 11 years ago

Hi. Are you using an API that preserves the PDF aspect ratio, e.g.

UIImage *img = [ UIImage imageWithPDFNamed:@"YingYang.pdf" atWidth:60 ];
IamAliSufyan commented 11 years ago

I am using this. [imageView setImage:[ UIImage originalSizeImageWithPDFNamed:@"filename.pdf" ]]; Image in Pdf is Rectangular but it shrinks it vertically.

[imageView setImage:[ UIImage imageWithPDFNamed:@"filename.pdf" atHeight:70.0 ]]; It also shrinks and adds blur on image.

[imageView setImage:[ UIImage imageWithPDFNamed:@"filename.pdf" atSize:CGSizeMake( 40, 40 ) ]]; It only blurs the image. Please help! I need to solve it ASAP.

IamAliSufyan commented 11 years ago

@mindbrix Please help!

mindbrix commented 11 years ago

Sounds like you have a PDF with a bitmap in it. This only works for PDFs with pure vectors.

IamAliSufyan commented 11 years ago

@mindbrix No, image is pure vector. it is drawn in Inkscape. I tried different pdfs, even your sample pdf shows blurry.

mindbrix commented 11 years ago

Please attach a screenshot.

IamAliSufyan commented 11 years ago

[imageView setImage:[ UIImage imageWithPDFNamed:@"signals.pdf" atSize:CGSizeMake( 150, 150 ) ]];

screen shot 2013-09-20 at 5 16 09 pm

mindbrix commented 11 years ago

The image has to match the size of the UIImageView or scaling may occur, depending on the contentMode.