Print PDF from WebView which has URL. Objective C macOS - objective-c

I want to print a PDF file from WebView as there is a print button in WebView and when I click it, I'll get the URL of PDF and its content type as application/pdf. I searched so much and exhausted for how to print a PDF file in Objective C - cocoa. All I saw is to print content from a view and it'll print all the WebView
[NSPrintOperation printOperationWithView:webView]
But I need to print the PDF I got, not the entire WebView
Please help me...
NB Swift coders: Please don't put your code here. I don't know swift
Edit 1: No iOS codes please. Its about macOS
Edit 2: From the screenshot, when I click print, I get that PDF in the PDF viewer in the WebView. I need to print it directly. Thats my scenario.

did you try this? It explains how to render PDF document from a UIWebView on iOS. If it works on iOS, my first guess would we that it should on macos.
Good luck!
Hichem
Creating PDF file from UIWebView

Related

About how to upload PDF file and show it

I can't figure out how to do like this page http://service.citroen.com/ddb/modeles/c5/c5_c5/ed10-07/de_de/4_21_c5-al-ed10-2007.pdf I embed usually the PDF from slideside in my site but people cant dowload from because they need to have an accoount. So technically how ? Thanks
You will need a PDF viewer component for displaying the PDF. You will have to configure the PDF component so as to limit download and print options.
http://www.gnostice.com/nl_article.asp?id=329&t=Display_PDF_without_saving_file_to_disk_in_WinForms_and_ASP_NET

Convert PDF to Keynote - iOS

Is it possible to convert each page in a PDF into separate images and then add those images to separate slides in an Apple Keynote file all with Objective-C and on iOS? After that, if that was possible - I would then need to import that keynote file into Keynote, again, on iOS.
Some basic playing around with the core-graphics pdf api should get you the UIImages for each page. For the Keynote part you might need to do some more digging.

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

Generate Paginated PDF from UIWebView

I've got a UIWebView that I'm using to display a stylized NSString of HTML that I'm generating. I'd like to be able to email a paginated PDF of the displayed page.
Right now, I can use the iOS 4.0 printing features to print a nice, paginated representation of all the text in the UIWebView. Can I do the same, but rather than print the PDF, generate an NSData object (or a file in the sandboxed file system) from the HTML string?
I can already generate an image of the UIWebView, but this doesn't paginate easily and requires a lot more work than I think should be necessary to do this.
Thanks.

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.
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.