How to convert html data to PDF in objective c - 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.

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:
Convert Html or UIWebView to pdf in iPhone or iPad
Making a PDF from a UIWebView

I have used this Haru open source library, it is quite simple and useful for creating pdfs http://libharu.org/wiki/Main_Page

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.

Related

How to generate PDF offline with UWP

I'm developing a UWP app for tablet and i need to generate a PDF with data from SQLite. I need to do this completely offline because where I will use the app there is no connection. What could I do?
I'd prefer not to use paid libraries like Syncfusion and XFinium so I'm trying to find an alternative solution.
I tried with iTextSharp but unfortunately I can't find a good documentation to render a complex PDF or to export a Bitmap generated from a Grid Component to a PDF File.
Why not render your data into a webpage displayed with a WebView control? Then you can use any permissive licensed javascript library to generate the PDF.
If it hasn't changed much, then you can only send text back and forth between your WebView and UWP app, but that's workable. Your final PDF result can be read back as a base64 encoded string.
A very quick search found this one that seems easy to use and you can just download the source to put into your app:
https://github.com/MrRio/jsPDF

Is there a way to display PDF on Apple tvOS?

I just started exploring Apple's tvOS and am looking if there is a way to display PDFs in a carousel or of that sorts. However, I cannot find a way to achieve that without converting PDF to JPEG images. Can someone guide me if there is a Document object that can read and render PDF on tvOS?
I think CGPDFPage and its related API:s are available, https://developer.apple.com/library/prerelease/tvos/documentation/GraphicsImaging/Reference/CGPDFPage/index.html

Fetching PDF file content into NSString

I am working on iPad application in which i have to show PDF data into table. Firstly,I want to fetch PDF file content into NSString, how to achieve this. I tried a lot but i am unable to get it.
Thanks
You have to use Quartz2d.
Check this page of the Quartz 2D Programming Guide, it covers everything you need to open and parse a PDF file in iOS. Note that it is not a simple task, since there's no method to extract the full text in one line. You have to work with the data as an input stream, using a CGPDFScanner

Alternative to PDF on iPad

I have to create a PDF reader for Ipad, so i read about CGPDFdocument and UIWebView.
In my opinion CGPDFDocument is too complex(i need to mange link) and using a UIWebView i can't customize behavior.
Is there an alternative way to build that? Perhaps a way to convert PDF to another format like ebook ?
Thank you !
What's hard about CGPDFDocument? Apple's example in the Quartz2D programming guide is only 30 lines long.

QuickLook plugin displaying an image and some infos

I'm currently writing a QuickLook plugin, and I wondering how I can display an image and some information about that image at the same time, similar to http://www.code-line.com/software/sneakpeekphoto/ .
There is only one way to do so: Convert your content to an already supported one. This means either PDF or HTML. There are two options you have:
For static information you create a simple PDF preview by rendering a view into a PDF. (Use -dataWithPDFInsideRect: method of NSView)
For dynamic information create a HTML page with links and so on. QuickLook will then show it. (I think this is also the way your example does it.)
We have not found a way to create complex previews on ur own and had to stick to one of the methods, too. Keynote and Pages do the same -- they convert their presentations to multi-page PDF previews...