Create a Nice PDF with Drafts and Shortcuts

Early last month, a student teacher was posting on the Automators forum about using Drafts to make dealing with templates such as lesson plans easier. Through a bit of discussion in the thread, it came about that the student teacher really just was looking for a way to get simple text entry into a format compatible with the template - i.e. printable vs. editable. With this amendment I was able to put together an example based on the template they provided that would transform text in a draft via a Drafts action and Shortcuts into a nicely formatted PDF document.

In this post I’m going to review the solution and approach as to how I did that.

Preparing the Template Format

I began with the template that had been provided. It was a Word document and I’ve provided a copy here for reference.

After sorting out some of the formatting to simplify things as much as I could, I used Microsoft Word’s option to export Word documents as web pages to get access to HTML that would be able to reproduce the structure. As a text based format that can be used to render richly formatted content, this was a good way forward in terms of getting the template to integrate with Drafts.

Even though I had tidied up the original Word document, I also took the time to simplify the output from Word as much as I could and to remove a lot of unnecessary HTML from it. It probably wasn’t necessary to do quite so much tidying up, but I always feel better with the simplest approach as it is easier to work with and reduces the number of areas in which an aberrant rendering result could occur.

Input Capture in Drafts

Next, I translated the template sections into a simple plain text structure for use in Drafts. This isn’t a reproduction of the template at this point. Purely a way to ensure that each of the template sections is represented in what is in effect a simplified, plain text only, capture form. I created a Drafts action to do this.

The Draft Action uses a single Insert Text step to add content to a draft consisting of a a set of sections marked up as level one Markdown Headings. This was fine for my example, but if you intend to use something like this yourself, consider instead an option of creating a new draft, populating the content, and loading it into the editor.

In addition, I also created a similar one for testing purposes that was pre-populated with content.

Populate an HTML Template

Once the user has added the draft outline to their draft and completed item the next step is to transform that into the template. The premise is to take out the relevant content for each section response and to convert that into an HTML page.

The Drafts action begins with a Script step that uses some JavaScript to split the completed content by the level 1 Markdown headings and then splitting those to use the heading name as a temporary template tag in Drafts, and the content beneath it, entered by the user, as the text associated with that tag.

//Split the draft by level 1 Markdown headings
let astrDraft = draft.content.split("# ");

//Drop the empty element created because the first line begins with a hash.
astrDraft.shift();

//Build ttemplate tags for each section
astrDraft.map(strSection =>
{

	let astrSectionBody = strSection.split("\n");

	let strSectionTitle = astrSectionBody.shift();
	//alert(strSectionTitle);

	let strSectionBody = astrSectionBody.join("\n");
	//alert(strSectionBody);
	
	draft.setTemplateTag(strSectionTitle, strSectionBody);
});

The next step is another script step. I separated it out so as to make the overall action a little easier to work with and maintain.

The script defines a template tag of OUTPUT HTML for the draft. This can be thought of as a special type of variable we can access outside of a script step. It is set to be equal to the HTML version of the template, but populated with template tags for each of the sections processed by the previous step.

For example, within a large table block in the template is the HTML below. Note the %%[[Development: Timing]]%% entry. This is one of the places where, when the script processes the template, it will substitute in data extracted and named by the previous action step.

<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
	border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
	solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
	padding:0cm 5.4pt 0cm 5.4pt'>
	<p class=MsoNormal>
		<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
			<o:p>%%[[Development: Timing]]%%</o:p>
		</span>
	</p>
</td>

You can expand here to view the full script and template details.
// The tag "[[OUTPUT HTML]]" will contain the HTML for outputting the draft data within the 
// template once this section of script has run.  This section is separated out purely to
// declutter and ease maintenance.


draft.setTemplateTag("OUTPUT HTML", draft.processTemplate(`

<html>
	<head>
		<meta http-equiv=Content-Type content="text/html; charset=utf-8">
		<style>
			<!--
				/* Font Definitions */
				h1
				{mso-style-priority:99;
				mso-style-unhide:no;
				mso-style-qformat:yes;
				mso-style-link:"Heading 1 Char";
				mso-style-next:Normal;
				margin-top:6.0pt;
				margin-right:0cm;
				margin-bottom:0cm;
				margin-left:0cm;
				margin-bottom:.0001pt;
				mso-pagination:widow-orphan lines-together;
				page-break-after:avoid;
				mso-outline-level:1;
				font-size:14.0pt;
				font-family:"Cambria",serif;
				mso-fareast-font-family:"Times New Roman";
				mso-bidi-font-family:"Times New Roman";
				color:#365F91;
				mso-font-kerning:0pt;
				mso-fareast-language:EN-US;}
				p.MsoNormal, li.MsoNormal, div.MsoNormal
				{mso-style-unhide:no;
				mso-style-qformat:yes;
				mso-style-parent:"";
				margin:0cm;
				margin-bottom:.0001pt;
				mso-pagination:widow-orphan;
				font-size:12.0pt;
				mso-bidi-font-size:10.0pt;
				font-family:"Times New Roman",serif;
				mso-fareast-font-family:"Times New Roman";
				mso-fareast-language:EN-US;}
				-->
		</style>
		<!--[if gte mso 10]>
		<style>
			/* Style Definitions */
			table.MsoNormalTable
			{mso-style-name:"Table Normal";
			mso-tstyle-rowband-size:0;
			mso-tstyle-colband-size:0;
			mso-style-noshow:yes;
			mso-style-priority:99;
			mso-style-parent:"";
			mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
			mso-para-margin:0cm;
			mso-para-margin-bottom:.0001pt;
			mso-pagination:widow-orphan;
			font-size:12.0pt;
			font-family:"Calibri",sans-serif;
			mso-ascii-font-family:Calibri;
			mso-ascii-theme-font:minor-latin;
			mso-hansi-font-family:Calibri;
			mso-hansi-theme-font:minor-latin;
			mso-bidi-font-family:"Times New Roman";
			mso-bidi-theme-font:minor-bidi;
			mso-ansi-language:EN-US;
			mso-fareast-language:EN-US;}
		</style>
		<![endif]--><!--[if gte mso 9]>
		<xml>
			<o:shapedefaults v:ext="edit" spidmax="1026"/>
		</xml>
		<![endif]--><!--[if gte mso 9]>
		<xml>
			<o:shapelayout v:ext="edit">
				<o:idmap v:ext="edit" data="1"/>
			</o:shapelayout>
		</xml>
		<![endif]-->
	</head>
	<body lang=EN-GB style='tab-interval:36.0pt'>
		<div class=WordSection1>
			<h1>
				<u>
					<span style='font-family:"Arial",sans-serif;mso-bidi-font-family:"Times New Roman";
						color:black'>
						LESSON PLAN PRO FORMA
						<o:p></o:p>
					</span>
				</u>
			</h1>
			<p class=MsoNormal>
				<span style='font-family:"Arial",sans-serif;mso-bidi-font-family:
					"Times New Roman"'>
					<o:p>&nbsp;</o:p>
				</span>
			</p>
			<table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width=945
				style='width:708.5pt;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;
				mso-yfti-tbllook:160;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:
				.5pt solid black;mso-border-insidev:.5pt solid black'>
				<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
					<td width=189 valign=top style='width:141.8pt;border:solid black 1.0pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Date
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=189 valign=top style='width:5.0cm;border:solid black 1.0pt;
						border-left:none;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Stage
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=291 colspan=3 valign=top style='width:218.0pt;border:solid black 1.0pt;
						border-left:none;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Focus Curriculum Area
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=276 colspan=2 valign=top style='width:206.95pt;border:solid black 1.0pt;
						border-left:none;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Whole class/Group
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:1'>
					<td width=189 valign=top style='width:141.8pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Lesson Date]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=189 valign=top style='width:5.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Stage Focus]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=291 colspan=3 valign=top style='width:218.0pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Curriculum Area]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=276 colspan=2 valign=top style='width:206.95pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Whole Class/Group]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:2'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Learning Intentions (including reference to relevant CfE
									outcomes/experiences)
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Shared Success Criteria
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:3'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Learning Intentions]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Shared Success Criteria]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:4'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Teaching Strategy(<span class=SpellE>ies</span>)
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Assessment Method(s)
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:5;height:17.25pt'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Teaching Strategy(ies)]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								<o:p>%%[[Assessment Method(s)]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:6'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt;font-family:
								"Arial",sans-serif'>Main Opportunities for developing Cross-Curricular Links
							(including reference to relevant CfE outcomes/experiences)</span></b>
							<span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p></o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:7'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt;tab-stops:423.0pt'>
							<span
								class=MsoPageNumber>
								<span style='font-size:11.0pt;font-family:"Arial",sans-serif'>
									<o:p>%%[[Main Opportunities for Developing Cross-Curricular Links]]%%</o:p>
								</span>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:8'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Differentiation
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Resources
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:9'>
					<td width=463 colspan=3 valign=top style='width:347.05pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal style='margin-right:2.85pt'>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Differentiation]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=482 colspan=4 valign=top style='width:361.45pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='margin-right:2.85pt;text-align:center'>
							<span style='font-size:10.0pt;font-family:
								"Arial",sans-serif'>
								<o:p>%%[[Resources]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:10'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Learning Activity(<span class=SpellE>ies</span>)
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									<o:p>&nbsp;</o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									<o:p>&nbsp;</o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:11'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt;font-family:
								"Arial",sans-serif'>Opening </span></b>
							<span style='font-size:10.0pt;
								font-family:"Arial",sans-serif'>
								(consider your role and the role of the pupil
								– *remember to connect to the learner and give the big picture)
								<b
									style='mso-bidi-font-weight:normal'>
									<o:p></o:p>
								</b>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Teacher role
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif'>
									Timing
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:12'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Opening]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Opening: Teacher Role]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Opening: Timing]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:13'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'><span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>Development </span></b>
							<span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								(<span
									style='color:black'>consider your role, *including relevant questions, and
								the role of the pupil</span>)
								<b style='mso-bidi-font-weight:normal'>
									<o:p></o:p>
								</b>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>&nbsp;</o:p>
							</span>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>&nbsp;</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:14'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Development]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Development: Teacher Role]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Development: Timing]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:15'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'><span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>Close </span></b>
							<span
								style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								(consider your role
								and the role of the pupil - *remember to review and reflect)
								<o:p></o:p>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>&nbsp;</o:p>
							</span>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>&nbsp;</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:16;height:36.9pt'>
					<td width=614 colspan=4 valign=top style='width:460.3pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt;height:36.9pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Close]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=255 colspan=2 valign=top style='width:191.5pt;border-top:none;
						border-left:none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;
						mso-border-top-alt:solid black .5pt;mso-border-left-alt:solid black .5pt;
						mso-border-alt:solid black .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:36.9pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Close: Teacher Role]]%%</o:p>
							</span>
						</p>
					</td>
					<td width=76 valign=top style='width:2.0cm;border-top:none;border-left:none;
						border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;mso-border-top-alt:
						solid black .5pt;mso-border-left-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt;height:36.9pt'>
						<p class=MsoNormal>
							<span style='font-size:10.0pt;font-family:"Arial",sans-serif'>
								<o:p>%%[[Close: Timing]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:17'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						background:#D9D9D9;padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal align=center style='text-align:center'>
							<b
								style='mso-bidi-font-weight:normal'>
								<span style='font-size:10.0pt;font-family:
									"Arial",sans-serif;color:black'>
									Assessment of Learning
									<o:p></o:p>
								</span>
							</b>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:18'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'>
								<span
									style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>
									Which
									children did well – what and why?
									<o:p></o:p>
								</span>
							</b>
						</p>
						<p class=xl24 style='margin:0cm;margin-bottom:.0001pt'>
							<span lang=EN-US
								style='font-family:"Arial",sans-serif;color:black'>
								<o:p>%%[[Which children did well – what and why?]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:19'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'>
								<span
									style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>
									Which
									children did not do well – what and why?
									<o:p></o:p>
								</span>
							</b>
						</p>
						<p class=xl24 style='margin:0cm;margin-bottom:.0001pt'>
							<span
								style='font-family:"Arial",sans-serif;color:black;mso-ansi-language:EN-GB'>
								<o:p>%%[[Which children did not do well – what and why?]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:20'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'>
								<span
									style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>
									What
									incidental learning, if any, occurred?
									<o:p></o:p>
								</span>
							</b>
						</p>
						<p class=xl24 style='margin:0cm;margin-bottom:.0001pt'>
							<span lang=EN-US style='font-family:"Arial",sans-serif;color:black'>
								<o:p>%%[[What incidental learning, if any, occurred?]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<tr style='mso-yfti-irow:21'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=MsoNormal>
							<b style='mso-bidi-font-weight:normal'><span
								style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>What
							might be the next steps for children’s learning?</span></b>
							<span
								style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black'>
								<o:p></o:p>
							</span>
						</p>
						<p class=xl24 style='margin:0cm;margin-bottom:.0001pt'>
							<span lang=EN-US
								style='font-family:"Arial",sans-serif;color:black'>
								<o:p>%%[[What might be the next steps for children’s learning?]]%%</o:p>
							</span>
						</p>
					</td>
				</tr>
				<!--
				<tr style='mso-yfti-irow:22;mso-yfti-lastrow:yes'>
					<td width=945 colspan=7 valign=top style='width:708.5pt;border:solid black 1.0pt;
						border-top:none;mso-border-top-alt:solid black .5pt;mso-border-alt:solid black .5pt;
						padding:0cm 5.4pt 0cm 5.4pt'>
						<p class=xl24 style='margin:0cm;margin-bottom:.0001pt'>
							<span lang=EN-US
								style='font-family:"Arial",sans-serif;color:black'>
								<o:p>&nbsp;</o:p>
							</span>
						</p>
					</td>
				</tr>
				-->
				<![if !supportMisalignedColumns]>
				<tr height=0>
					<td width=189 style='border:none'></td>
					<td width=189 style='border:none'></td>
					<td width=85 style='border:none'></td>
					<td width=151 style='border:none'></td>
					<td width=55 style='border:none'></td>
					<td width=200 style='border:none'></td>
					<td width=76 style='border:none'></td>
				</tr>
				<![endif]>
			</table>
			<p class=MsoNormal>
				<o:p>&nbsp;</o:p>
			</p>
			<p class=MsoNormal style='margin-right:2.85pt'>
				<span style='font-size:10.0pt;
					font-family:"Arial",sans-serif'>
					<o:p>&nbsp;</o:p>
				</span>
			</p>
			<p class=MsoNormal>
				<o:p>&nbsp;</o:p>
			</p>
		</div>
	</body>
</html>

`));

The third step in the action is an HTML preview step. It purely utilises the [[OUTPUT HTML]] template tag set-up in the previous step. This shows the user how the final content should look.

The fourth step is where the content leaves Drafts. Drafts has no option to actually generate the PDF and so that’s where Shortcuts comes into use. The final step calls a shortcut called “HTML2PDF - Make, View, Share”, and uses the [[OUTPUT HTML]] template tag content as the input template. Note that the action step is not set to wait for a response as once we go to Shortcuts, we’re effectively finished in Drafts.

Generating the PDF

The shortcut is relatively simple, and consists of just four steps.

The first step converts the HTML Shortcuts receives from Drafts to Rich Text, effectively rendering it like the preview in Drafts, but internally to Shortcuts. Next the Make PDF action is used to create a PDF file from the rich text content. This is then displayed to the user via a Quick Look action. Finally, once the user proceeds beyond the preview, they get the usual iOS share sheet allowing them to save the file on to wherever they like.

Speeding Things Up

I fully realise that there are two preview steps going on, once in Drafts and once in Shortcuts. This was intentional for demonstrating how things worked, to the original requester, and here. If you are reproducing this in some way I would recommend dropping at least one if not both preview steps. In Drafts you can easily disable that particular step, and in Shortcuts it is barely any effort to add and remove a Quick Look in such a small shortcut.

I’d also consider streamlining it if you can always determine a single output destination for the final PDF. This would save you having to step through the share sheet each time you run it, which I can imagine would become irksome after doing it even just a few times.

Example

The example pro forma Draft action above was used in the original Automators response to illustrate what this would produce. Here’s what they produced.

Drafts Preview

Shortcuts Preview

I thought they came out pretty well and so did quite a few others.

Hopefully the process makes sense and I hope that you’re able to put it to good use for yourself, or at least take some of the techniques I used and up your Drafts skills in particular.

Author: Stephen Millard
Tags: | drafts | shortcuts |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read