omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to print on a AirPrint and Non AirPrint Printer

    Pythonista
    6
    8
    6756
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Kluesi
      Kluesi last edited by

      Hi

      1. How can I print from the iPad using a AirPrint printer?

      2. How to print on a standard (old) parallel LPT Interface Printer? E.g. over a printserver. But how to print images and so on?

      Thanks

      1 Reply Last reply Reply Quote 1
      • brumm
        brumm last edited by brumm

        I haven't seen a print option in Pythonista so far, but maybe your interest is more general (otherwise I would ask for some objective c magic :)). There are several apps (like camera roll) where you can print and of course you can send images from pythonista to the camera roll. To print an image I used this tutorial with my usb printer (non airprint). As far as I can remember I tested three options. USB printer connected to the raspberry pi and raspberry pi connected to my wifi router via ethernet cable. Second option: USB printer connected to the raspberry pi with a wifi stick (as wifi hotspot). Thrid option: Raspberry pi only connected via ethernet cable (for protocoll translation) and usb printer connected to a print server. I know you wrote an old parallel LPT Interface Printer, but maybe there's also a hack for this. But there's no guarantee that you printer is supported by cups (so I would start here).

        1 Reply Last reply Reply Quote 1
        • omz
          omz last edited by

          @brumm said:

          I haven't seen a print option in Pythonista so far,

          In case this question is actually about printing source code in Pythonista, there is an option to generate a printable PDF in the "wrench" menu. After the PDF has been generated, you can print from its "Quick Look" preview.

          1 Reply Last reply Reply Quote 0
          • cook
            cook last edited by cook

            @Kluesi

            I was just asking a similar question the other day about printing something with a script. My need was for a script to print HTML content created by a script. I'll share the code below. There are a number of options, like @brumm has indicated, to set up printers for AirPrint. Here is an example for enabling AirPrint for printers on Windows..

            This script is in particular for an HTML formatted document. There are other options to program that I haven't explored yet (the different print formatters available in objective c).

            # coding: utf-8
            
            from objc_util import * 	
            
            @on_main_thread
            def print_html_orientation(input, orientation = 'P'):
            	'''takes HTML input and formats it for printing. Uses the built in ios UI print dialogue. Orientation should be 'P' or 'L' '''
            	html = ObjCClass('UIMarkupTextPrintFormatter').alloc().initWithMarkupText_(ns(input))
            	printController = ObjCClass('UIPrintInteractionController').sharedPrintController()
            	printInfo = ObjCClass('UIPrintInfo').printInfoWithDictionary_(None)
                printInfo.orientation = int(orientation[0].upper() == 'L')
            	printController.printInfo = printInfo
            	printController.setPrintFormatter_(html)
            	printController.presentAnimated_completionHandler_(0, None)
            
            
            1 Reply Last reply Reply Quote 1
            • ccc
              ccc last edited by

              printInfo.orientation = int(orientation[0].upper() == 'L')

              Phuket2 1 Reply Last reply Reply Quote 0
              • brumm
                brumm last edited by

                @cook: Thank you for sharing, btw. printContents should be input or vice versa.

                1 Reply Last reply Reply Quote 0
                • cook
                  cook last edited by

                  @brumm whoops thanks for pointing that out. I had taken a chunk out of the script to make it simple for here which included printContent (needs to be an NSString).

                  Thanks @ccc!

                  Changes made above.

                  1 Reply Last reply Reply Quote 0
                  • Phuket2
                    Phuket2 @ccc last edited by

                    @ccc , if you follow PEP8 for this, it's horrible for selecting on mobile devices. So I guess they need PEP8-M
                    But there needs to be some recognition of the changes of input devices

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors