Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Need help with Pages

I have a MAC desktop, with El Capitan.

I am trying to make, and print a calendar in Pages. It needs to be a total size of 3" X 5", with seven boxes across, and five boxes down. I want to add numbers to the boxes, and add the month at the top.


I can get as far as making a landscape template. I've tried youtube, but am unable to follow it, and have also tried Pages Help, but am totally lost.


Can anyone help me?

iMac, OS X El Capitan (10.11.4)

Posted on Apr 28, 2016 10:25 AM

Reply
Question marked as Best reply

Posted on Apr 28, 2016 11:12 AM

This isn't too hard with the right tools. The following was done in Pages v5.6.1 on OS X 10.11.4.


  1. Add a default table into Pages
    1. Arrange tab : Text Wrap None
    2. Arrange tab : Sizing
      1. Width: 5 in
      2. Height: 3 in
  2. Add columns or rows to get to your 5 rows and 7 columns. These will conform to your established table size.
  3. Generate a calendar in a format that can be copy/pasted into cell 1 of your Pages table.
    1. Use short Python program to generate an HTML calendar as a table (Desktop folder as caltab.html)
    2. Double-click caltab.html to open in your browser
    3. Select entire calendar including any blank days (see April 2016)
      User uploaded fileUser uploaded file
    4. Copy/Paste selection shown (even blank spaces) into cell 1 of your table. It will automatically populate your table with the calendar data shown.
  4. Copy the April 2016 string from the HTML calendar.
    1. Select your Table
    2. Select the Table tab
      1. Click Table Name on this panel
      2. Select the Table 1 default name, and paste the April 2016 over it.
      3. Done.


Result:

User uploaded file

Python source code:


#!/usr/bin/env python

# coding: utf-8



import calendar

import os

import sys


# caltab.py




YEAR = 2016

MONTH = 4




outfile = os.path.expanduser('~/Desktop/caltab.html')



c = calendar.HTMLCalendar(calendar.SUNDAY)

with open(outfile, 'w') as hout:

hout.write(c.formatmonth(YEAR, MONTH))



sys.exit()


Copy and paste the Python source into a TextEdit plain text file in your home directory. Then open Terminal (Launchpad : Other : Terminal) and do the following. Only type what is in blue type:


# Make the caltab.py executable

$ chmod +x caltab.py

# Run it and make your caltab.html file on your Desktop

$ ./caltab.py


This is a just get it out the door solution for you. I will put this in an AppleScript wrapper that will prompt you for the calendar month/year to generate. Once I have this ready, I will post it here as an addendum, so you don't have to go to the Terminal in the future.

8 replies
Question marked as Best reply

Apr 28, 2016 11:12 AM in response to redncurly

This isn't too hard with the right tools. The following was done in Pages v5.6.1 on OS X 10.11.4.


  1. Add a default table into Pages
    1. Arrange tab : Text Wrap None
    2. Arrange tab : Sizing
      1. Width: 5 in
      2. Height: 3 in
  2. Add columns or rows to get to your 5 rows and 7 columns. These will conform to your established table size.
  3. Generate a calendar in a format that can be copy/pasted into cell 1 of your Pages table.
    1. Use short Python program to generate an HTML calendar as a table (Desktop folder as caltab.html)
    2. Double-click caltab.html to open in your browser
    3. Select entire calendar including any blank days (see April 2016)
      User uploaded fileUser uploaded file
    4. Copy/Paste selection shown (even blank spaces) into cell 1 of your table. It will automatically populate your table with the calendar data shown.
  4. Copy the April 2016 string from the HTML calendar.
    1. Select your Table
    2. Select the Table tab
      1. Click Table Name on this panel
      2. Select the Table 1 default name, and paste the April 2016 over it.
      3. Done.


Result:

User uploaded file

Python source code:


#!/usr/bin/env python

# coding: utf-8



import calendar

import os

import sys


# caltab.py




YEAR = 2016

MONTH = 4




outfile = os.path.expanduser('~/Desktop/caltab.html')



c = calendar.HTMLCalendar(calendar.SUNDAY)

with open(outfile, 'w') as hout:

hout.write(c.formatmonth(YEAR, MONTH))



sys.exit()


Copy and paste the Python source into a TextEdit plain text file in your home directory. Then open Terminal (Launchpad : Other : Terminal) and do the following. Only type what is in blue type:


# Make the caltab.py executable

$ chmod +x caltab.py

# Run it and make your caltab.html file on your Desktop

$ ./caltab.py


This is a just get it out the door solution for you. I will put this in an AppleScript wrapper that will prompt you for the calendar month/year to generate. Once I have this ready, I will post it here as an addendum, so you don't have to go to the Terminal in the future.

Apr 28, 2016 2:30 PM in response to redncurly

And here is the AppleScript/Python solution that you can build to sit on your Desktop, and when you double-click on it, you will get prompted to enter the calendar required as mm/yyyy. Instantly, it will open a new web page with the requested monthly calendar displayed. You then apply the steps from my original post to select all days (including blank days) and paste into a Pages table.


User uploaded fileUser uploaded file


Start the AppleScript Editor (Launchpad : Other : Script Editor). Copy/paste the following AppleScript into the Editor. Click the compile (hammer) icon. Click the Run ▸ button, and get your calendar results in a browser window. Save the AppleScript as htmlcal. When you click Text in the Format selector, the applescript extension will be applied to the filename. Now, option key + File menu : Save As… and use htmlcal as the name, but this time, choose Application from the Format selector, and hide the extension. Save it to your Desktop.


Code below:


-- Generate and display HTML Calendar (monthly) from user input (e.g. 4/2016). Subsequently, calendar

-- data can be copy/pasted from web page into existing Pages table for instant calendar data.

-- Name - htmlcal.applescript

-- Version 1.0

-- VikingOSX, 28-Apr-2016, Apple Support Community


-- property calfile : POSIX path of ((path to desktop) as text) & "caltab.html"


set html_pre to "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">"

set html_pre2 to "</head><body>"

set html_post to "</body></html>"


set atitle to "HTML Calendar Builder"

set amsg to "Enter the Month and Year for the calendar. No spaces." & return & "(e.g. 4/2016) "


try

set theDate to the text returned of (display dialogamsgdefault answer "" with titleatitle)

set {TID, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, "/"}

set {amonth, ayear} to text items of theDate

set AppleScript'stext item delimiters to TID


-- make Python handlers command-line arguments. Going directly to web page instead of file

set args to amonth & space & ayear-- & space & calfile's quoted form


-- the name for the new window tab shown as (e.g. HTML Calendar 4/2016)

set html_title to "<title>" & "HTML Calendar " & (amonth as text) & "/" & (ayear as text) & "</title>"


set caltable to make_HTML_calendar(args) as text


-- html5 web page to display including the new calendar table

set table_html to html_pre & html_title & html_pre2 & caltable & html_post


tell application "Safari" to open location "data:text/html," & table_html

on error errmsgnumbererrnbr

my error_handler(errnbr, errmsg)

end try

return


on make_HTML_calendar(args)

return do shell script "python <<'EOF' - " & args & "

#/usr/bin/python

# coding: utf-8


# Python script to generate a calendar table in HTML


import calendar

import sys


amonth = int(sys.argv[1])

ayear = int(sys.argv[2])

# ofile = sys.argv[3]


# Week starts on Sunday

c = calendar.HTMLCalendar(calendar.SUNDAY)

# with open(ofile, 'w') as hout:

# hout.write(c.formatmonth(ayear, amonth))

print(\"{}\".format(c.formatmonth(ayear, amonth)))

EOF"


end make_HTML_calendar


on error_handler(nbr, msg)


return display alert "[ " & nbr & " ] " & msg as critical giving up after 10


end error_handler

Apr 28, 2016 7:24 PM in response to Barry

Barry,


If the OP uses my second solution that I posted, it will write the correct Oct 2016 calendar into a new web page. Copy/Pasting that data (as directed) into the first cell of a 5 row by 7 column table will automatically expand the table to 6 rows, and the calendar result will appear correct.


I have an unposted solution of the above that uses LibreOffice to convert the HTML table into a Word .docx file. When that file is opened in Pages v5.6.1, it has the proper table already built. It only needs to have the 3 x 5 inch table size adjustment, and selecting all of the days with centered text. The Word .docx approach also automatically changes the table name to Month YYYY.


Looking for another variation that does not require LibreOffice. Playing with tidy and textutil to see if I can get the same result as LO produces.

Apr 28, 2016 8:51 PM in response to VikingOSX

Hi Viking,


I was thinking of this line in the initial post: "It needs to be a total size of 3" X 5", with seven boxes across, and five boxes down."


Could be handled by reducing the height of all the boxes to fit in the same space, by setting the space up to always allow for six rows, or by using the same method used by the producers of printed calendars—make the last day or two (it's never more than that) 'share space' with the first day or two of the previous week.


I chose the easy route (six rows, always) for a 12 month calendar I created several years ago in AppleWorks, and later ported into Numbers (either '08 or '09). The final version required only entering a date on the first page—the rest was all formulas that filled in the calendar starting on the first of that month, and finishing at the end of the twelfth month following. Interesting exercise, but I never did find much use for it—loads of printed calendars available then; fewer now, but still sufficient to my needs.


Regards,

Barry

Apr 29, 2016 6:52 AM in response to Barry

I too, adhered to the OP's table size criteria. I set the table size in the Arrange tab, before I adjusted the columns and rows, which did not change the width or height of the table.


The tidy and textutil commands are not maintaining table structure on output to Word. Looking at making a new Pages document using the generated table as data to see if it does what I hope it will.

Need help with Pages

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.