Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 29    Views: 136

MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
07/14/12 10:39 PM (11 years ago)

Tutorial: Add a Print Button to a BT App

An app I'm working on for a client needed to have a way to print pdf documents. I found a pretty simple solution. This tutorial is specific to pdf screens, although it should work fine with word docs, excel files and powerpoint docs and Html docs. Custom html screens and url screens are a bit different and you'd need to do some modification. Of course, the print option will only work on wifi networks with a compatible printer or driver. There is no error trapping in this method, so if you push the button when you're not on wifi or on a system without a printer, you'll just get a "searching" screen. You can see the tutorial here: http://bit.ly/LZh1lK Cheers!
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
07/14/12 10:47 PM (11 years ago)
good work
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/14/12 10:52 PM (11 years ago)
You are Babe Ruth! Thank you AGAIN!!!!!!!!
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/14/12 10:58 PM (11 years ago)
Looks like this is for BTv2.0....any ideas on 1.5. Thanks
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/14/12 11:07 PM (11 years ago)
Haven't played with 1.5 in a while. I'll have a look and let you know.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/14/12 11:17 PM (11 years ago)
Maybe I just need to migrate over to 2.0...why did you switch?
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
07/14/12 11:33 PM (11 years ago)
@MGoBlue, awesome tutorial - thank you! David buzztouchmods.com
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/14/12 11:41 PM (11 years ago)
@lsills81 - I made the switch because I wanted to self host. I have control issues (ha ha). I actually have a couple dozen apps that I did with 1.5, but since everything is moving toward plugins, I figured 2.0 was the place to be.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
07/15/12 08:08 AM (11 years ago)
excellent, this really bridges a gap trying to move apps into the actual workplace. anxious to see how that code works and how it attaches to the network and the printer drivers and what one can do... Have/did you look at Airprint and found this code/approach better for a reason? I can see where it is just beacause it has potential to work on more devices. thanks for sharing this, great tutorial. this one is definately a big one to have for the business/workplace area type apps.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/15/12 08:35 AM (11 years ago)
I was under the impression that this was AirPrint? @atrain53 any idea on how to implement this in BTv1.5? Thanks
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/15/12 08:45 AM (11 years ago)
This is airprint. It uses the UIPrintInfo class within iOS. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPrintInfo_Class/Reference/Reference.html @lsills81 - I did a quick look at one of my 1.5 apps, and it looks like the code would go within the BT_screen_webview.m and maybe also in the BT_screen_customHTML.m screens. The code to call the button is still in BT_utilities.m at line 320. I don't have time to test it right now. Pushing a deadline before I head off to a conference on Tuesday. @ATRAIN53 - I found several tutorials online with different methods for printing. This was the simplest and easiest to modify for BT.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/15/12 08:47 AM (11 years ago)
@MGoBlue That is MORE then enough!!!!! Thank you so much. I will test it today and let you know my results.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/15/12 08:48 AM (11 years ago)
Last thing...where would I go to start to comprehend WHERE to put code like this. That is what I struggle with the most!
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/15/12 08:53 AM (11 years ago)
This one should be pretty easy. The variable definitions still need to go in the .h and .m files (BT_screen_webview) like the tutorial. Try putting the "-(IBAction)printdoc{" code block at the very end of the file before the @end. If that doesn't work, just try in different spots. Trial and error testing is how I learn. Just don't put it within another class/method.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/15/12 08:55 AM (11 years ago)
Got it...
 
mitchellapps
Aspiring developer
Profile
Posts: 170
Reg: Aug 15, 2011
St. Louis
4,300
like
07/15/12 10:25 AM (11 years ago)
@MGoBlue, You never cease to amaze me! Keep up the great work!
 
Stephen Mercurio
buzztouch Evangelist
Profile
Posts: 260
Reg: Jan 01, 2010
Monterey, Calif...
4,150
like
07/15/12 12:59 PM (11 years ago)
@MGoBlue, we really appreciate your efforts and equally appreciate your willingness to share with the community. Thanks for the generosity....
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/15/12 01:03 PM (11 years ago)
@Stephen - my pleasure
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/17/12 08:27 AM (11 years ago)
Nice share! I've had success on the simulator but when tested on the device, the print option doesn't come up on my ipad. Could it be my device or anyone else have this issue? Tested on BT 2.0 server and Buzz 1.5 still no go thanks!
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/17/12 08:41 AM (11 years ago)
@mysps Doing this right now....keep us posted on how it goes. Thanks
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/17/12 11:11 AM (11 years ago)
OK I just my lost my voice from yelling!!!!!!!!!!! THIS WORKS in BTv1.5 & BTv2.0 Thank you! I'll post video for both later today!
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/17/12 12:23 PM (11 years ago)
great@ isills81, i think the tutorial that blue made is very simple so i'm not sure that video is needed. i'm just clueless why it works on the simulator and won't work on my device iPad using iOS 5+ .. must be my iPad.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/17/12 02:49 PM (11 years ago)
I make video tutorials and save them on YouTube as my own personel "how to" for all that I do. I think that for some....not you....a video is needed. PS: I bet you didn't replace the top line on the last step... Let me know as I have it up on both 1.5 and 2.0 on my iPad and iPhone...
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/17/12 03:20 PM (11 years ago)
ok great! yeah i replaced the top line.. :) i'll have to test on another device when i get a chance. thanks
 
Vashann
I hate code!
Profile
Posts: 7
Reg: Jun 30, 2012
Dallas
6,070
like
07/17/12 03:45 PM (11 years ago)
I would like to see the video. :). Had some issues with it but I am sure it is my not capitalizing or forgetting punctuation somewhere.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/17/12 04:16 PM (11 years ago)
Here is the video...the code zip file is included in the disruption. Thanks to @MGoBlue for the original tutorial. http://www.youtube.com/watch?v=gtJkeakP8xs
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
08/24/12 04:42 PM (11 years ago)
How would I add this to a URL/WebView? BT2.0
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/26/12 07:38 PM (11 years ago)
@MGoBlue we followed your instructions but when we try and print one of many .PDF's either local or URL based...when we print the same PDF is printed every time. Any Ideas? Thank you!!!!
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
11/09/12 03:55 PM (11 years ago)
Hey hey! I know this is a 2 month old thread, but any answer to the above question? It was brought to my attention by a user of one of my apps that it would print out the same PDF (for me, usually the 1st one alphabetically) regardless of which one is chosen. Any info would be greatly appreciated!!! Merci ;) Nicholas
 
nyandrews
Aspiring developer
Profile
Posts: 7
Reg: Sep 19, 2012
Manlius
5,270
like
12/06/12 12:36 PM (11 years ago)
mgoblue Thank You Sir! One question I have: is there a way to edit the color for the "Print Options" screen. The standard blue clashes pretty hard with my app? Thanks again!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.