tags:

views:

49

answers:

1

Hi,

I want to convert html to pdf dynamically in objective c. what is the best way to convert it, so that it maintains its look same as html. Thanks in advance.

Prasad.

A: 

Objective-C is a programming language, it doesn’t know anything about HTML or PDF per se. How to do this depends on the framework you’re using. I’m assuming here you’re using Cocoa on OS X.

There you can load your HTML into a WebView provided by WebKit and then use the NSView method dataWithPDFInsideRect: to render it as PDF. I haven’t tested this, but maybe you’ll have to add the web view to a window before you can query the PDF data.

Sven
Am I right in that this method is not available in the iPhone SDK? If so, does anyone know how I can do this on the iPhone?
JWD