Wednesday, November 22, 2017
  • 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: 701
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:

http://files.macscripter.net/joy/images/colendargui.jpg




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.

http://files.macscripter.net/joy/images/cal2008.jpg


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!


Plonum - Convert images to iWork Numbers documents


Filed under: PDF, Python, coregraphics, Quartz

Offline

 

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

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

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: 701
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


Plonum - Convert images to iWork Numbers documents

Offline

 

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

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

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

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


iMac running OS X 10.13.1

Offline

 

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

Martin Michel
Administrator
From:: Berlin, Germany
Registered: 2008-03-03
Posts: 701
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 :-(


Plonum - Convert images to iWork Numbers documents

Offline

 

#6 2009-12-10 04: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 04:05:49 am

Martin Michel
Administrator
From:: Berlin, Germany
Registered: 2008-03-03
Posts: 701
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


Plonum - Convert images to iWork Numbers documents

Offline

 

#8 2010-01-08 01: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

 

#9 2011-02-04 07:30:14 am

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

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

Hi Martin,

any news on colendar? Since it's 2011 now I'm in need of a new calender smile

grüsse aus der Schweiz,
triple

Offline

 

#10 2011-06-08 04:26:50 am

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

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

triple wrote:

Hi Martin,

any news on colendar? Since it's 2011 now I'm in need of a new calender smile

grüsse aus der Schweiz,
triple


Hi,

Finally I found some time to publish a new tool for creating custom calendars: It utilizes iWork Numbers '09 and includes many features that people missed when using Colendar.

The new tool is named Colina and you can download it for free here:
Download Colina.app

Of course all AppleScripts used by Colina can be viewed in Script Editor, just in case you are interested in the code (find them in the app bundle).

For the first time, I also made a small video on YouTube. Times are changing :-)

Best regards from Berlin,

Martin


Plonum - Convert images to iWork Numbers documents

Offline

 

#11 2011-06-08 05:03:12 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

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

Hello Martin,

Great app be unfortunately not every mac user has numbers right? So I wanted to make a suggestion what you can do and is also very easy (like iCal works). Make a webview and create a html page on the fly. This html page will be loaded in your webview and the only thing you need to code is that it can be printed correctly. When printing the user has also an option like, show in preview or pdf (Mac OS X built-in).

Offline

 

#12 2011-06-08 09:56:43 am

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

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

Hi DJ Bazzie Wazzie;

I like your idea of using a Webview. But one thing would still be missing:

A lot of people complained that they could not edit the calendar in Colendar, as the result was a PDF. So that is one advantage of the Numbers solution: You can create your calendar, have some iCal events included and are still able to edit the result.

Best regards to NL, was in Hilversum just lately...

Martin


Plonum - Convert images to iWork Numbers documents

Offline

 

#13 2011-06-09 01:50:14 am

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

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

hey martin,

thanks for this app ... great that you give away this app for free ... i really appreciate this.

Since I have numbers on my computer at work it works fine for me. But at home I have office 2011 ... without knowing anything about coding .... is there a chance of getting the same thing with excel? Or is that completely out of reach?

triple

Offline

 

#14 2016-08-28 04:27:49 am

macapus
Member
Registered: 2006-07-10
Posts: 2

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

hello, is there a chance that colina will run with el capitan et numbers 3.6.2 ? cool

thank

Offline

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

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)