Thursday, September 2, 2010
  • Index
  •  » Code Exchange
  •  » Colendar - PDF calendars with AppleScript, Python & CoreGraphics

#1 2008-06-05 02:44:37 am

Martin Michel
Administrator
From: Berlin, Germany
Registered: 2008-03-03
Posts: 655
Website

Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Have you ever wanted to directly create dynamic PDF documents from within your AppleScripts? In less than a second? While having full control over page dimensions, color space and the exact positions of inserted texts, graphics and images? Well, if your answer is a resounding Yes, then I kindly invite you to download and inspect my latest Mac scripting project:

 - Click to enlarge




Colendar is an AppleScript Studio application that requires Mac OS X 10.5 Leopard and the system font Andale Mono. Just like my RagTime template it can create customized PDF calendars in several languages, but - and that is important - without the need of owning a copy of RagTime. It just creates the whole PDF document completely on its own.

 - Click to enlarge


Now, how can our beloved language of automation instantly create rich PDF content without installing extensions like Smile? Frankly spoken, it cannot. The real magic of direct PDF calendar creation is not achieved by AppleScript itself. It’s done by a Python script that makes excessive use of the excellent Quartz 2D bindings for Python. And that is also why you necessarily need Mac OS X 10.5 to successfully run Colendar, because the Python script relies on the latest version of PyObjC, which is pre-installed on Leopard.

But don’t underestimate the power of this combination! By having the possibility to execute Python scripts with arguments from within your AppleScript code using the «do shell script command», you can easily create a Python script that creates a nicely formatted and layouted PDF document with data retrieved from the calling AppleScript.

For example, one could quickly extend Colendar to include birthdays from an iCal calendar. Or think about an AppleScript based Apple Mail rule, that extracts all available informations from an incoming eMail and then calls a Python script, which produces a corresponding PDF representation of that message to file or directly print it with the lpr command. A thousand possibilities!

You only need to keep in mind, that currently all characters used in text to be drawn to a PDF context must be able to be converted to Mac Roman text encoding. Therefor not all languages can be supported. And just in case I watered your mouth and you want to dive into Python and direct PDF creation, I recommend to install the Developer Tools and take a look at the code examples located in /Developer/Examples/Quartz/Python/ and /Developer/Examples/Python/PyObjC/. Of course, studying the well commented Python script which is responsible for the PDF calendars produced with Colendar might also be a good idea big_smile

Let's build a great web service!
I would really like to put the underlying Python script on a server running Mac OS X Server (10.5), so that anybody could create and download colorful PDF calendars online. But unfortunately I don't have access to such a server and don't want to offer such a service out of my living room using my limited bandwidth, DynDNS and an old but still beautiful Power Mac G4/400...

So if you have access to a server running Mac OS X Server 10.5 and are interested in creating such a calendar creation service, please do not hesitate to contact me!


Sal Soghoian is my role model.

Filed under: PDF, Python, coregraphics, Quartz

Offline

 

#2 2009-08-07 08:08:09 am

triple
Member
Registered: 2009-08-07
Posts: 1

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

hi Martin,

firsdt of all thanks for the great colendar-app. It's great and I used it last year. Now I found this posting and was wondering if you ever did anything like you said one could do. I'd love to have the feature to include one (or more) calenders from ical within the pdf-file.
I'm not a coder so I tried but got too confused.

greetings
triple

Offline

 

#3 2009-08-09 04:42:56 am

Martin Michel
Administrator
From: Berlin, Germany
Registered: 2008-03-03
Posts: 655
Website

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Hi triple,

First of all thank you very much for your interest in the Colendar script.

Unfortunately I did not have any time yet to implement the iCal feature in Colendar. Since the beginning of 2009 I am working as a professional scripter and I only have very little time for my private projects now smile

Best regards from sunny Berlin,

Martin


Sal Soghoian is my role model.

Offline

 

#4 2009-08-09 09:07:27 am

Adam Bell
Administrator
From: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4255

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Actually, Martin, you do have access to such a server: ScriptBuilders


Scripts are tested on a PowerMac dual-core G5/2.3 running OS X 10.5.8 or MacBook Pro Intel Core 2 Duo running OS X 10.6.4

Offline

 

#5 2009-09-04 09:47:21 am

Martin Michel
Administrator
From: Berlin, Germany
Registered: 2008-03-03
Posts: 655
Website

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Colendar won't run on Mac OS X 10.6 (Snow Leopard), as this OS does not include Core Graphics bindings (CGBindings) for 64-bit Python :-(


Sal Soghoian is my role model.

Offline

 

#6 2009-12-10 03:51:16 pm

Kiteleif
Member
Registered: 2009-05-08
Posts: 2

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Hi Martin just tried to issue the new colendar for 2010 without success.

Now I saw your commend that it's not working due to snow leopard 64 bit system.

Any other option to fix it or alternative calendars available ?

I love this kind of calendar and it's another feature which is killed by SW upgrade.....

regards
leif

Offline

 

#7 2009-12-18 03:05:49 am

Martin Michel
Administrator
From: Berlin, Germany
Registered: 2008-03-03
Posts: 655
Website

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Hi,

I get many complaints about Colendar not working in Mac OS X 10.6, even my own wife is bitter about this fact. Therefor - also to rescue my marriage - I plan to release an Obj-C version of Colendar in 2010. The internal development name is Snolendar big_smile Will use christmas time to start coding lol

Best regards from snowy Berlin!

Martin


Sal Soghoian is my role model.

Offline

 

#8 2010-01-08 12:42:17 pm

Kiteleif
Member
Registered: 2009-05-08
Posts: 2

Re: Colendar - PDF calendars with AppleScript, Python & CoreGraphics

That sounds great.

So we still have some hope for this year.

I would volunteer for the job as beta tester :-))

Many thanks ... and speed up before the year ends.

best wishes

Leif

Offline

 
  • Index
  •  » Code Exchange
  •  » Colendar - PDF calendars with AppleScript, Python & CoreGraphics

Board footer

Powered by FluxBB

[ Generated in 0.144 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)