Anyone get AirPrint to work with iOS?

Hello,

Has anyone gotten AirPrint to work with corona? I’m trying to print from an iOS app. I know Rob showed a tutorial on printing with iOS but that was with images. I thought I might can print from the webview from it does not have a print method either. I’ve given up on printing from Android. There is such a demand to print from apps now and no one wants to support it.

Warren

Not sure if it can be done in corona… I wonder if you can call some type of URI that you can send to IOS and get it to open in the native os browser.

Good luck.

The tutorial I did was for Enterprise subscribers.  You cannot print from Corona SDK.   Now the Enterprise tutorial should also print PDF files.  This tutorial seems to confirm that most people will generate a PDF and print it, but there are a few other options:

http://b2cloud.com.au/how-to-guides/including-airprint-on-an-ios-app/

Rob

But you cannot create a PDF with corona also right? You would have to pass the data to a server, generate the PDF and then retrieve it to print. Unless I’m missing something.

Warren

Since you have to have Enterprise to print a PDF you can use native to make a PDF to use.  I don’t know how to print a webView nor do I believe you could get access to the one Corona SDK uses anyway.

Rob

Not sure if it can be done in corona… I wonder if you can call some type of URI that you can send to IOS and get it to open in the native os browser.

Good luck.

The tutorial I did was for Enterprise subscribers.  You cannot print from Corona SDK.   Now the Enterprise tutorial should also print PDF files.  This tutorial seems to confirm that most people will generate a PDF and print it, but there are a few other options:

http://b2cloud.com.au/how-to-guides/including-airprint-on-an-ios-app/

Rob

But you cannot create a PDF with corona also right? You would have to pass the data to a server, generate the PDF and then retrieve it to print. Unless I’m missing something.

Warren

Since you have to have Enterprise to print a PDF you can use native to make a PDF to use.  I don’t know how to print a webView nor do I believe you could get access to the one Corona SDK uses anyway.

Rob

One year later, is it possible to print a webview by now?

Thanks so much in advance,

Philipp

There are two options. On iOS you can use the Activity plugin which gives you access to the default printing option when you tap an app’s Send To button (sharing). For Enterrpise users, we did a tutorial that included a bonus “How to print” option.

The Activity plugin can take a text string, an image, and/or a hyper link. I suppose you could try and pass a PDF in as an image, though that’s not been proven. But all this said, what would you print? We can’t easily create PDF’s. The utility of what you would print is kinda minimal.

Rob

Thank you very much for your reply. I’m basically trying to print a full-screen screenshot. I could do the screenshot in the webview via html2canvas but when I press the print-button in the webview nothing happens.

I guess I would somehow have to overlay a native corona print button at the right time in order for it to work?  

I don’t know about printing webViews. But what you might be able to do is have a button in your app that would take the webView (as long as it’s from a website, not a local file) and run it through the SafariView plugin. It might have a print button as it’s a full page widget.

Rob

Slightly tangential to the discussion but it is possible to generate PDFs in Corona (none enterprise) using the lua port of a PDF library (no native components required!). It’s at: luaFpdf.zip - Google Code

It works very well indeed, and it can pull background images in, on which you can overlay text using grid coordinates, and so you have some proforma style capability. We’ve used v1.7 quite a bit now.

The difficulty we still have is printing (grr) - even after the advent of the activity plugin!

It seems that printer service does not respond to (‘see’) the url type item. Apple’s documentation says the print service will respond to NSURL where it refers to a local url, but there seems to be no way in Corona to ‘phrase a url’ to a generated PDF residing in the sandbox’s Documents directory - shame - so near and yet so far!

Any light on this would be most welcome.

Gary

Well back to Enterprise. I did a tutorial a while back that showed how to print and while I was using images, it’s really expecting a PDF.

What happens if you pass the PDF as the image, not the URL?

Rob

Rob - do you have a link to the tutorial to hand?

If I use the following then the printer service does not appear at all - ie. none of the item types trigger it.

local items =

{

      { type = “image”, value = { filename = “gm.pdf”, baseDir = system.ResourceDirectory, } },

    { type = “string”, value = “Hello, World” },

    { type = “url”, value = “http://services.geant.net/cbp/Knowledge_Base/Security/Documents/gn3-na3-t4-ufs126.pdf” },

}

conclusions…

I don’t seem to be able to con it with a PDF as an image as you suggest trying

But also, and more worrying, is that a url to a web PDF does not trigger the printer service - according to the Corona and the Apple documentation this should should at least work as is an NSURL being passed through (supposedly).

 I did get it to work with a real image (an icon from app as per the example), but when this printed the image was clipped and the scaling awful.

I remain puzzled at the practical usefulness of the activity plugin in respect of printing.

Would be a relief If I’d made an error somewhere as this would be a darm useful feature - but I simply copied the example code and used the item table mentioned above.

:-{

Gary

Here:  https://coronalabs.com/blog/2014/04/22/tutorial-image-printing-via-corona-enterprise-ios/

Rob

Thanks for pointing this library out.  Any tutorials on how to use this library to create PDFs in Corona SDK?

Jason

One year later, is it possible to print a webview by now?

Thanks so much in advance,

Philipp

There are two options. On iOS you can use the Activity plugin which gives you access to the default printing option when you tap an app’s Send To button (sharing). For Enterrpise users, we did a tutorial that included a bonus “How to print” option.

The Activity plugin can take a text string, an image, and/or a hyper link. I suppose you could try and pass a PDF in as an image, though that’s not been proven. But all this said, what would you print? We can’t easily create PDF’s. The utility of what you would print is kinda minimal.

Rob