prasad
prasad

Reputation: 2026

How to convert html data to PDF in objective c

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

Answers (3)

dom
dom

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

prasad
prasad

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

anon
anon

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

Related Questions