{"id":51894,"date":"2021-03-11T03:01:55","date_gmt":"2021-03-10T17:01:55","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=51894"},"modified":"2021-03-12T12:43:12","modified_gmt":"2021-03-12T02:43:12","slug":"hard-copy-flyer-automated-applescript-printing-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/hard-copy-flyer-automated-applescript-printing-tutorial\/","title":{"rendered":"Hard Copy Flyer Automated Applescript Printing Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/AppleScriptEditor\/applescript_print_landscape_safari_address_bar_url.gif\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Hard Copy Flyer Automated Applescript Printing Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/AppleScriptEditor\/applescript_print_landscape_safari_address_bar_url.gif\" title=\"Hard Copy Flyer Automated Applescript Printing Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Hard Copy Flyer Automated Applescript Printing Tutorial<\/p><\/div>\n<p>Did you read <a title='Hard Copy Flyer Letter Box Post Tutorial' href='#hcflbpt'>Hard Copy Flyer Letter Box Post Tutorial<\/a>?  It talks about something that is like a standing order, like a repeated procedure.  Can it benefit from some sort of automation?  We think yes.<\/p>\n<p>So, with our Apple MacBook Pro, what is available to us?  What about using <a target=_blank title='AppleScript information from Apple' href='https:\/\/developer.apple.com\/library\/content\/documentation\/AppleScript\/Conceptual\/AppleScriptLangGuide\/introduction\/ASLR_intro.html'>AppleScript<\/a> to automate &#8230;<\/p>\n<ul>\n<li>the printing of the &#8230;<\/li>\n<li>8 copies &#8230; of A4 &#8230;<\/li>\n<li>Landscape sheets &#8230; based on &#8230;<\/li>\n<li>a local Apache\/PHP\/MySql MAMP web server accessible URL via the Safari web browser<\/li>\n<\/ul>\n<p>We wanted to thank the authors of the links below &#8230;<\/p>\n<ul>\n<li><a target=_blank href='https:\/\/developer.apple.com\/library\/archive\/documentation\/Accessibility\/Conceptual\/AccessibilityMacOSX\/OSXAXTestingApps.html' title='Testing for Accessibility on OS X'>Testing for Accessibility on OS X<\/a><\/li>\n<li><a target=_blank href='https:\/\/apple.stackexchange.com\/questions\/340942\/applescript-how-can-i-get-ui-elements-names-attributes-properties-classe' title='AppleScript \u2013 How can I _get_ UI element names, attributes, properties, classes programmatically without \u201cguessing\u201d via AccessibilityInspector?'>AppleScript \u2013 How can I _get_ UI elements&#8217; names, attributes, properties, classes programmatically without \u201cguessing\u201d via AccessibilityInspector?<\/a><\/li>\n<li><a target=_blank href='https:\/\/discussions.apple.com\/thread\/7743420' title='How to write applescript to print TextEdit document'>How to write applescript to print TextEdit document<\/a><\/li>\n<li><a target=_blank href='https:\/\/forum.keyboardmaestro.com\/t\/how-to-set-portrait-landscape-in-print-dialog-box\/10478\/3' title='How to set portrait\/landscape in print dialog box'>How to set portrait\/landscape in print dialog box<\/a><\/li>\n<li><a target=_blank href='https:\/\/discussions.apple.com\/thread\/3342412' title='Automate Print Dialog with AppleScript in Lion - Checkbox Problem'>Automate Print Dialog with AppleScript in Lion &#8211; Checkbox Problem<\/a><\/li>\n<\/ul>\n<p> &#8230; to arrive at the AppleScript code (that works with the MacBook Pro application (in Utilities) Script Editor) &#8230;<\/p>\n<p><code><br \/>\ntell application \"Safari\"<br \/>\n\topen location \"http:\/\/localhost:8888\/lm_flyer.html\"<br \/>\n\tactivate<br \/>\n\ttell application \"System Events\" to keystroke \"p\" using {command down}<br \/>\n\ttell application \"System Events\" to keystroke \"8\"<br \/>\n\ttell application \"System Events\" to tell process \"Safari\"<br \/>\n\t\ttell window 1<br \/>\n\t\t\ttell sheet 1<br \/>\n\t\t\t\ttell radio group 1<br \/>\n\t\t\t\t\ttell (first radio button whose description is \"Landscape\")<br \/>\n\t\t\t\t\t\tif value of attribute \"AXValue\" is not 1 then perform action \"AXPress\"<br \/>\n\t\t\t\t\tend tell<br \/>\n\t\t\t\tend tell<br \/>\n\t\t\t\tclick button \"Print\"<br \/>\n\t\t\tend tell<br \/>\n\t\tend tell<br \/>\n\tend tell<br \/>\nend tell<br \/>\n<\/code><\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/hard-copy-flyer-automated-applescript-printing-tutorial\/'>Hard Copy Flyer Automated Applescript Printing Tutorial<\/a>.<\/p-->\n<hr>\n<p id='hcflbpt'>Previous relevant <a target=_blank title='Hard Copy Flyer Letter Box Post Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/hard-copy-flyer-letter-box-post-tutorial\/'>Hard Copy Flyer Letter Box Post Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/hardcopy_flyer.pdf\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Hard Copy Flyer Letter Box Post Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/hardcopy_flyer.jpg\" title=\"Hard Copy Flyer Letter Box Post Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Hard Copy Flyer Letter Box Post Tutorial<\/p><\/div>\n<p>Are you thinking of ways to tell people about your services?  Here in Australia flyers, and fridge magnets, and company sponsored calendars remain big ways to advertise these services.   Not everything happens online, and it may surprise some how much &#8220;bricks and mortar&#8221; shopping still goes on.<\/p>\n<p>It&#8217;s not hard to create and distribute a simple paper flyer that does not feel wasteful regarding resources.   It is a step harder though to create that glossy corporate look, and if this is crucial, this blog posting only has cursory interest for you in all probability, but a look at <a title='Course Flyer via Components Primer Tutorial' href='#cfcpt'>Course Flyer via Components Primer Tutorial<\/a> may be more interesting to you.<\/p>\n<p>Let&#8217;s divide the hard copy letter box distribution into its &#8230;<\/p>\n<ol>\n<li>one off &#8220;setup&#8221; components  &#8230;\n<ul>\n<li>create HTML page flyers (in our case we can fit 4 in one A4 page of web page content) in a text editor (where we use <a target=_blank href='http:\/\/www.macupdate.com\/app\/mac\/11009\/textwrangler' title='Mac TextWrangler text editor'><i>TextWrangler<\/i><\/a> on this MacBook Pro) &#8230; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/lmflyer.html_GETME\" title=\"lmflyer.html\">lmflyer.html<\/a> &#8230;<br \/>\n<code><br \/>\n&lt;html&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;table cellpadding=20 callspacing=20&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;font size=7 color=blue&gt;Robert's Lawn Mowing&lt;\/font&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;font size=7 color=black&gt;$25 large or small&lt;\/font&gt;&lt;br&gt;<br \/>\n&lt;font size=6 color=olive&gt;mobile: 7777777777&lt;\/font&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;font size=7 color=blue&gt;Robert's Lawn Mowing&lt;\/font&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;font size=7 color=black&gt;$25 large or small&lt;\/font&gt;&lt;br&gt;<br \/>\n&lt;font size=6 color=olive&gt;mobile: 7777777777&lt;\/font&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;font size=7 color=blue&gt;Robert's Lawn Mowing&lt;\/font&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;font size=7 color=black&gt;$25 large or small&lt;\/font&gt;&lt;br&gt;<br \/>\n&lt;font size=6 color=olive&gt;mobile: 7777777777&lt;\/font&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;font size=7 color=blue&gt;Robert's Lawn Mowing&lt;\/font&gt;&lt;br&gt;&lt;br&gt;<br \/>\n&lt;font size=7 color=black&gt;$25 large or small&lt;\/font&gt;&lt;br&gt;<br \/>\n&lt;font size=6 color=olive&gt;mobile: 7777777777&lt;\/font&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;td align=center&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;\/table&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n<\/code><br \/>\n<iframe style=\"width:100%;height:800px;\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/lmflyer.html\" title=\"lmflyer.html\"><\/iframe>\n<\/li>\n<li>in your favourite web browser, open <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/lmflyer.html_GETME\" title=\"lmflyer.html\">lmflyer.html<\/a> via a local web server (eg. MAMP HTTP:\/\/localhost:8888\/lmflyer.html URL) or use a web browser File-&gt;Open File<\/li>\n<li>File-&gt;Print initially for 1 copy and print until you are happy with all the alignments and justifications, changing <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/lmflyer.html_GETME\" title=\"lmflyer.html\">lmflyer.html<\/a> as necessary to fit things better<\/li>\n<li>store away what works best here bearing in mind the aesthetics and wastefulness (we settled for Landscape A4 8 copies)<\/li>\n<\/ul>\n<\/li>\n<li>standing order repeatable components regarding &#8220;supply and delivery&#8221; (we do once every work day) &#8230;\n<ul>\n<li>in your favourite web browser, open <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/lmflyer.html_GETME\" title=\"lmflyer.html\">lmflyer.html<\/a> via a local web server (eg. <a target=_blank title='MAMP Mac OS X local Apache\/PHP web server landing page' href='http:\/\/www.mamp.info'>MAMP<\/a> HTTP:\/\/localhost:8888\/lmflyer.html URL) or use a web browser File-&gt;Open File<\/li>\n<li>File-&gt;Print &#8230;<\/li>\n<li>Landscape A4 8 copies &#8230; click Print button<\/li>\n<li>in our case, turn on (wireless) printer and see green WiFi button light up &#8230;<\/li>\n<li>in our case, printer shows &#8220;Receiving Data&#8221; and then prints out 8 identical sets of 4 flyers (ie. 32 per batch)<\/li>\n<li>in our case, turn off (wireless) printer &#8230;<\/li>\n<li>we cut these out with about 5 scissor cuts to end up with 32 flyers &#8230;<\/li>\n<li>placed into our back pocket &#8230;<\/li>\n<li>and placed into &#8220;future client&#8221; letter boxes &#8230; and Luna (the brains of the operation) concurs<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p> &#8230; a lot of which you can see with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/hardcopy_flyer.pdf\" title=\"Click picture\">PDF presentation<\/a>.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/hard-copy-flyer-letter-box-post-tutorial\/'>Hard Copy Flyer Letter Box Post Tutorial<\/a>.<\/p-->\n<p><i><b>Did you know?<\/b><\/i><\/p>\n<p>If you have an aversion to &#8230;<\/p>\n<ul>\n<li>overuse of scissors<\/li>\n<li>overuse of crooked paper edges<\/li>\n<li>unnecessary yellow bin infatuations (in public)<\/li>\n<\/ul>\n<p> &#8230; unchecking &#8220;Print headers and footers&#8221; (at the web browser&#8217;s &#8220;Print&#8221; menu)  may have saved you doing as many scissor steps above.<\/p>\n<hr>\n<p id='cfcpt'>Previous relevant <a target=_blank title='Course Flyer via Components Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/course-flyer-via-components-primer-tutorial\/'>Course Flyer via Components Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/course_advertising_flyer_helper.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Course Flyer via Components Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/course_advertising_flyer_helper-487of.jpg\" title=\"Course Flyer via Components Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Course Flyer via Components Primer Tutorial<\/p><\/div>\n<p>If you&#8217;re like me, you&#8217;ll have many <a target=_blank title='Flyer information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Flyer_(pamphlet)'>flyers<\/a> come into your &#8220;radar&#8221; over the course of the day &#8230; the week &#8230; etcetera etcetera etcetera.  Many of these receive scant attention, as they often come with other junk &#8220;snail&#8221; mail.  The ones that might get more of my attention are &#8230; shallow me &#8230; the ones with some aesthetically pleasing aspect, but, alas, me being the &#8220;client web design hungry&#8221; being that I am, &#8220;shallow me&#8221; might only be paying more attention to it interested in the aesthetics achieved by that flyer&#8217;s designers <font size=1>&#8230; more so, at least for me, than its contents<\/font>.  Today, we&#8217;re going to start off on the journey towards developing a Course Flyer from its component parts.  So, for these purposes, imagine you are designing a course for a reputable educational institution, and want to design (and distribute <font size=1>&#8230; but &#8220;distribute&#8221; is another &#8220;art&#8221; altogether &#8230; a &#8230; r &#8230; t &#8230; now together &#8230; art &#8230; ta muchly<\/font>) a Course Flyer.<\/p>\n<p>Today&#8217;s component of the Course Flyer design revolves around the bulk of what you might want to present as the wording.  Guess if you want a Course Flyer to have any affect whatsoever, you&#8217;ll be hoping the reader gets to the &#8220;wording&#8221;.  Once there, and I know there&#8217;ll be marketing people out there that can say how few people get to this &#8220;wording&#8221; reading as a proportion of all people who have viewed your flyer <font size=1>&#8230; but let&#8217;s not let this put us off &#8230;<\/font> you&#8217;ll want &#8220;wording&#8221; with a combination of &#8230;<\/p>\n<ul>\n<li>clear concise detail of &#8220;administrative&#8221; information &#8230; and yet, in amongst that, some &#8230;<\/li>\n<li>reasonably detailed course content detail that both indicates what will be achieved, as well as being a &#8220;lead in&#8221; to the &#8220;juices&#8221; of the reader&#8217;s imagination, to inspire and convince and excite<\/li>\n<\/ul>\n<p> &#8230; and so, basing the &#8220;wording&#8221; content requirements on a NSW TAFE flyer (<i>&#8220;Training in Business Administration and Technology&#8221;, Office Technology<\/i> by Sydney Institute, TAFE NSW, Randwick College) we had picked up, thanks, we resolved that the information capture &#8220;data points&#8221; (for Course Flyer wording) should be &#8230;<\/p>\n<ul>\n<li>Big Top Heading<\/li>\n<li>Big Top Subheading<\/li>\n<li>Hours per Week Requirement<\/li>\n<li>Hours per Day Requirement<\/li>\n<li>Duration<\/li>\n<li>Description<\/li>\n<li>Footer<\/li>\n<li>Requirements<\/li>\n<li>Contact<\/li>\n<li>Orientation<\/li>\n<li>Start<\/li>\n<\/ul>\n<p> &#8230; and arrived at, after adding some accountability via an HTML <a target=_blank title='HTML Canvas element information from w3schools' href='http:\/\/www.w3schools.com\/tags\/ref_canvas.asp'>canvas<\/a> element redisplay of the user&#8217;s words, our <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/course_advertising_flyer_helper.html\" title='Click picture'>live run<\/a> link for a Course Flyer &#8220;wording&#8221; using HTML and Javascript and CSS you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/course_advertising_flyer_helper.html_GETME\" title=\"course_advertising_flyer_helper.html\">course_advertising_flyer_helper.html<\/a> and you could peruse for ideas, we hope.  To augment your understanding, perhaps, watch a PDF <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/course_advertising_flyer_helper.pdf\" title=\"course_advertising_flyer_helper.pdf\">slideshow<\/a> of us capturing the text in HTML textarea elements, redisplaying this in an HTML canvas, using the web browser&#8217;s own &#8220;Copy&#8221; (the canvas contents) capabilities, and Pasting that &#8220;redisplay&#8221; into the body section of an email created using the Mac OS X Mail desktop application, and sending this Course Flyer &#8220;wording&#8221; off to someone in an email.<\/p>\n<p>We hope you continue on with our Course Flyer creation journey.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d32200' onclick='var dv=document.getElementById(\"d32200\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/flyer\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d32200' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d49114' onclick='var dv=document.getElementById(\"d49114\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/textwrangler\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d49114' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d51894' onclick='var dv=document.getElementById(\"d51894\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/print\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d51894' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Did you read Hard Copy Flyer Letter Box Post Tutorial? It talks about something that is like a standing order, like a repeated procedure. Can it benefit from some sort of automation? We think yes. So, with our Apple MacBook &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/hard-copy-flyer-automated-applescript-printing-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[94,327,2307,554,576,3311,744,970,1924,985,3120,3576,1265,1404,1418,1429,1450],"class_list":["post-51894","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-applescript","tag-did-you-know","tag-flyer","tag-hardcopy","tag-html","tag-letter-box","tag-mamp","tag-post","tag-print","tag-printer","tag-printout","tag-script-editor","tag-textwrangler","tag-web-browser","tag-webpage","tag-wifi","tag-wireless"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51894"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=51894"}],"version-history":[{"count":4,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51894\/revisions"}],"predecessor-version":[{"id":51908,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/51894\/revisions\/51908"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=51894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=51894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=51894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}