Automatically Printing Text Files

459 views
Skip to first unread message

J. D. Harper

unread,
May 13, 2012, 11:22:53 AM5/13/12
to Printer
I wrote a little python script that checks a folder for any .txt
files, converts them into printer-friendly HTML via Markdown, and then
sends them to my thermal printer. I thought I'd post it here in case
anyone else found it interesting.

There's a bit more info and a video on my blog at
http://jdharper.com/blog/automatically-printing-text-files-to-a-thermal-printer/

Or if you just want to download the script it's here (along with the
Markdown library I'm using): http://jdharper.com/downloads/AutoPrintTxtFile.zip

-J. D. Harper

James Adam

unread,
May 14, 2012, 5:16:11 PM5/14/12
to gfr-p...@googlegroups.com
That's great work! As you mention at the bottom of your post, let us know what you end up using this for :)

- James

Jeremy Harper

unread,
Jun 3, 2012, 10:48:37 AM6/3/12
to gfr-p...@googlegroups.com
I just figured out something that this is really good for.

If This Then That (http://ifttt.com) is a neat service which connects a whole bunch of web services together with a really simple interface. One of the actions available in ifttt is to create a text file in Dropbox. Combine that with my little python script, and now ifttt can print to your GFR printer.

As a proof of concept, I just created a rule that will automatically print anything I star in Google Reader. But you could do all kinds of stuff. For example:
* print any tweet that mentions you
* print out a warning if rain is predicted for tomorrow
* print anything added to your delicious or pinboard or Evernote accounts with the tag ToPrint
* print out anything that you text to the ifttt number

That's right, I can now send text messages to my GFR printer. This is pretty awesome.

- J. D. Harper

--
You received this message because you are subscribed to the Google Groups "Printer" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/gfr-printer/-/WAE1a-WFO2sJ.

To post to this group, send an email to gfr-p...@googlegroups.com.
To unsubscribe from this group, send email to gfr-printer...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gfr-printer?hl=en-GB.

James Jefferies

unread,
Jun 5, 2012, 9:57:40 AM6/5/12
to Printer
Oh, that's a great idea to use ifttt with dropbox, I'd not thought of
that.

We're using a combination of ifttt, twilio, twitter and gmail to get
our two printers, Cathy and Heathcliff printing SMS messages and then
autotweeting them.

It's very much a first stab to get them working, hopefully I'll be
able to get some time to work with them this week. Our work flow at
the mo:

SMS to Twilio
Twilio POST to a noddy PHP page which:
* posts to the printer.gofreerange.com back end
* sends an email using gmail to ifttt
* ifttt then posts the contents of the email to twitter.

A future plan for Cathy is to get her to

* look out for tweets mentioning a specific account
* send the tweet content to printer back end

I'll have a look at your Python script, I've never used Python, so it
might be fun for me to investigate further.

cheers,

James


On Jun 3, 3:48 pm, Jeremy Harper <jeremy.har...@gmail.com> wrote:
> I just figured out something that this is really good for.
>
> If This Then That (http://ifttt.com) is a neat service which connects a
> whole bunch of web services together with a really simple interface. One of
> the actions available in ifttt is to create a text file in Dropbox. Combine
> that with my little python script, and now ifttt can print to your GFR
> printer.
>
> As a proof of concept <http://ifttt.com/recipes/38795>, I just created a
> rule that will automatically print anything I star in Google Reader. But
> you could do all kinds of stuff. For example:
> * print any tweet that mentions you
> * print out a warning if rain is predicted for tomorrow
> * print anything added to your delicious or pinboard or Evernote accounts
> with the tag ToPrint
> * print out anything that you text to the ifttt number
>
> That's right, I can now send text messages to my GFR printer. This is
> pretty awesome.
>
> - J. D. Harper
>
>
>
>
>
>
>
> On Mon, May 14, 2012 at 5:16 PM, James Adam <james.a...@gmail.com> wrote:
> > That's great work! As you mention at the bottom of your post, let us know
> > what you end up using this for :)
>
> > - James
>
> > On Sunday, 13 May 2012 16:22:53 UTC+1, J. D. Harper wrote:
>
> >> I wrote a little python script that checks a folder for any .txt
> >> files, converts them into printer-friendly HTML via Markdown, and then
> >> sends them to my thermal printer. I thought I'd post it here in case
> >> anyone else found it interesting.
>
> >> There's a bit more info and a video on my blog at
> >>http://jdharper.com/blog/**automatically-printing-text-**
> >> files-to-a-thermal-printer/<http://jdharper.com/blog/automatically-printing-text-files-to-a-therm...>
>
> >> Or if you just want to download the script it's here (along with the
> >> Markdown library I'm using):http://jdharper.com/downloads/**
> >> AutoPrintTxtFile.zip <http://jdharper.com/downloads/AutoPrintTxtFile.zip>

James Adam

unread,
Jun 6, 2012, 6:01:23 AM6/6/12
to gfr-p...@googlegroups.com
If you're in the UK and an O2 customer, you could also use the Hashblue API to get text messages sent to *your* phone. This is basically how Timmy Printface (the grandfather of Printer) worked.

- James

James Jefferies

unread,
Jun 6, 2012, 10:53:56 AM6/6/12
to gfr-p...@googlegroups.com
Yep, we started looking at Hashblue on your recommendation, but that week was such a blur, I can't remember why we ended up using Twilio.

I've cheated again with ifttt - set up a task to send an SMS to the printer when a specific twitter account is mentioned. Works a treat!

James

carfreemaine

unread,
Sep 22, 2012, 3:06:53 PM9/22/12
to gfr-p...@googlegroups.com
Speaking as someone with more experience on the hardware side of things this approach has a lot of appeal!  Especially the use of web services through IFTTT.  I would eventually love to see something like IFTTT but specifically oriented towards IOT or Home Automation applications.  In the meantime, I have found the Free Range Printer as a great test bed of how cloud-based architectures can be configured to address highly specified tasks on the individual level.  For example, I would love to be able to combine wunderground.com data with a daily planner like Google Calendar and a transportation service like OpenTripPlanner or Google Maps.  A printout could let me know the night before what clothes I should set out, what I might need to bring with me, what time I should wake up, what time I would need to leave and even recommend whether or not I should drive, bus, train or bike...
   Obviously, this would need to be coordinated within a much larger "IOT" network but without a simple dashboard style U/I things will get out of hand very quickly.
   If there's nothing like an IFTTT for the IOT than I wonder if it would be possible to write a single application in the Processing IDE and then export the code into Android, Javascript and Python.  That way you could write a single application for Arduino (which is already based on Processing) Android, the Raspberry Pi (Python) and control it all from a web-based dash using Javascript.  Am I making any huge leaps here or might this be possible without devoting the next 5 years of my life to the project?

Javed Ali

unread,
Mar 16, 2013, 12:46:08 AM3/16/13
to gfr-p...@googlegroups.com
Hey guys,

Is this script still working? If so, is it possible to get a copy of that sample markup so I can give it a shot in iift? This is the main feature I'm purchasing the printer for, so I'd love to make sure it works.

Also, how can headers/graphics be transposed from the .txt from iift to the printer?

Cheers,

J.

James Adam

unread,
Mar 18, 2013, 8:17:14 AM3/18/13
to gfr-p...@googlegroups.com
On 16 Mar 2013, at 04:46, Javed Ali <jta...@gmail.com> wrote:

> Hey guys,
>
> Is this script still working? If so, is it possible to get a copy of that sample markup so I can give it a shot in iift? This is the main feature I'm purchasing the printer for, so I'd love to make sure it works.
>
> Also, how can headers/graphics be transposed from the .txt from iift to the printer?

I can't comment on whether or not the script works, but it looks like the script will accept Markdown input, so if you supply your images using Markdown markup then the script should turn them into image tags...

... that said, the Printer server doesn't do *anything* smart on your behalf in terms of ensuring the images are the right size, or that they will look good when printed out in monochrome, so I'm not sure I'd recommend relying on this.

- James

blogmywiki

unread,
May 22, 2013, 7:21:25 AM5/22/13
to gfr-p...@googlegroups.com
Hi there

I'm trying to run your Python code on my iMac (modded for my Dropbox etc) and I'm getting a 'Failed to import ElementTree' error in the Markdown code: __init__.py and etree_loader.py - I tried updating Python and running as sudo but the errors persist. I'm new to Markdown - any ideas?

best wishes

blogmywiki

unread,
May 22, 2013, 8:14:33 AM5/22/13
to gfr-p...@googlegroups.com
Got it working, sort of now - I installed elementree on the Mac and things are looking hopeful!

Rebecca Noonan

unread,
Apr 15, 2014, 12:51:56 PM4/15/14
to gfr-p...@googlegroups.com
Hi J.D.

This is really interesting to me as I think I could definitely implement this text file method into my college project. I've been trying to figure out how to automatically print messages written into a form on a webpage. I'm not very experienced in this area but I've been trying to do it using different methods. At the moment I have the messages sent saving to a database and reprinting on a separate webpage that the user wouldn't see. I have a Processing sketch that then takes XML data from this 'hidden' webpage and redirects them to my printer URL. The only problem is, I have to press run in Processing every time in order for the newest message to print.

I've never used Python before but reading through the .py files you've provided, I can mostly understand the process through the code. However, I'm unsure about where you run the file. Is it through Processing or something else? Also, do I need to install certain libraries or something in order for it to work? As I said, I've never used Python so I would be unsure about this kind of information.

Any help is appreciated!

Thanks,
Rebecca

Meindi Zahiri

unread,
Apr 21, 2014, 12:14:57 AM4/21/14
to gfr-p...@googlegroups.com
Did you manage to resolve the problem ?

Rebecca Noonan

unread,
Apr 21, 2014, 6:21:59 AM4/21/14
to gfr-p...@googlegroups.com
Yes I did eventually by using PHP
--
You received this message because you are subscribed to a topic in the Google Groups "Printer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gfr-printer/oKYB7hHDp8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gfr-printer...@googlegroups.com.
To post to this group, send email to gfr-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gfr-printer.
For more options, visit https://groups.google.com/d/optout.

Meindi Zahiri

unread,
Apr 23, 2014, 12:31:37 AM4/23/14
to gfr-p...@googlegroups.com
Hello, is it possible to get the PHP code and the processing code please ?
To unsubscribe from this group and all its topics, send an email to gfr-printer+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages