mindbrix / UIImage-PDF

Simple UIImage PDF renderer category for iOS scalable assets

Home Page:http://blog.mindbrix.co.uk/2012/02/10/ios-scalable-assets/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question using exported PDF files with transparency

trailblazr opened this issue · comments

Is there any magic trick how actually preserve transparency in vector-files exported to PDF?

I was trying to make this work for my vector shapes I exported with PS as a PDF and nearly tried every preset & combination of options available, also deleted all other layers with only the vector shape remaining and exporting... still no success. Tried already using ImageMagick and other applications including ShrinkIt and Preview to re-export the PDF because in ImageMagick the background is actually transparent when loading the PDF there... but all my tried ended with the image still rendering with an opaque white background.

Is that a known issue or is there a special workflow/trick/hack I have to use to get transparency?
Or is there any hint how to change the workflow for exporting vector shapes to get a PDF rendered correctly that uses transparency?

Update: The only imaginable workaround I can think of right now is to produce an exact same image mask using a black & white image and apply this image mask to the PDFImage's CALayer. This actually works to stencil out the real graphic, but it produces sharp edges, and e.g. drop shadows which use alpha blending don't work anymore.

I generate PDFs using Inkscape via Print File and I can tell you I have no problems with this library to show transparency. Did you make sure the ImageView you stick the PDF image into has a clear background?

Yep, basically applied opaque = NO and applied renderingmodeOriginal to the UIImage and backgroundColor = [UIColor clearColor] to the UIImageView, no change in result yet. I will try the "Print from Inkscape" process... thx for that hint. I will report as soon as I have a result.

Okay, I tried to fix my issue… and finally succeeded… but it is a PITA in the process. I had to reopen (aka import) every "Saved as..."-EPS-File from Photoshop (PDF-Files did not work because InkScape could not ungroup the icon-vector-shape from the white background there) in InkScape. Manually ungroup the vector shape from the background (white box), then remove the background, then "Print as File..." from InkScape to the volume again. This removed the white box and really optimized the pdf to a very small size. I will try to document this process soon in my blog and then put a last comment on this issue to close it.

As said... it is a clumsy process, that makes keeping exporting 3 different PNG's rather fine if those 3 different sizes were okay for you. I needed more than 3, so it is economically worth it and saves some binary bytes in the deployed app in the end.

Cheers, all.

Sorry to hear that, but it certainly seems like your having a problem with your tools there ;) I've got 1 PDF that I can scale up and down without any issues, and this library works well for that, best one I've seen (Although I wish I could use SVG files directly (But all the svg libraries out there are horrible)).

@skela Yep, without a doubt it is a really nice and clean Category. I love to use it and now it works great. It opens up new possibilities to auto adjust icons depending on the device orientation and the device resolution which is a great thing. I am really happy I found this piece of art here. It helps with the transition to the new way of iOS fragmentation-space made up by lots of different screen-scales and screen-sizes now.

I actually wrote down my experiences and a short How-to how I fixed the alpha blending / transparency issue in a blogpost.

See here for more: http://www.thetawelle.de/?p=4234