Reputation: 2026
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.
Upvotes: 5
Views: 9427
Reputation: 11982
UIGraphicsBeginPDFContextToFile
will help you to create a PDF file which shows your web content. Read through the documentation and create your own solution or just follow the tutorials I found:
Upvotes: 2
Reputation: 2026
I have used this Haru open source library, it is quite simple and useful for creating pdfs http://libharu.org/wiki/Main_Page
Upvotes: 1
Reputation:
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.
Upvotes: 0