Create Beautiful PDFs From Your Tinderbox Documents

I meant to add that sadly the Table of contents (TOC) functionality can’t be done via the styled HTML. If you want fine control of the TOC you’ll need to get into XSLT. Good grief, all that ‘just’ to make a PDF. Still, massive kudos to all those who kindly made and shared this code. Otherwise the solution is pay-for and not cheap**.

** I looked at this in some depth a while back. Having chivvied Eastgate into doing HTML help out (and using Tinderbox to do it) I felt bad for those whose can’t understand who to use hypertext and need a long form document to work from, thus the above.

1.

Thanks, @mwra. But I am not even certain yet where to start from. The Terminal?

2.

Otherwise the solution is pay-for and not cheap

Which solution explicitly do you mean?

  1. Sorry, yes. It’s not an app. Download/install the software from wkhtmltopdf and then run the command line in Terminal.

  2. If I recall: Prince - Buy Prince only $495 for a single desktop licence. OK, it’s intended to do far more. But, that’s the irony, if you ‘just’ want to use styled HTML to make a PDF


Fellow forum members feel free to point up better/cheaper solutions. I did the recce on this about 5 years back and things move on…

2 Likes

Greetings. I need some help with printing out several notes, onto the same PDF page. Actually, 4 per A4 page (landscape) so I can cut them out into A6s.

Please see the attached sample files of what I’m trying to achieve. Any and all How To’s and tips will be great! Thank you.
Sample for Printing.tbx (146.9 KB)

Here’s a link to the desired output:

Tinderbox is not a desktop-publishing/page layout app. So as you’ve discovered you can print the view (i.e. what you see there) or the text pane, i.e. the $Text of the note. Select multiple notes and click in the text pane and print, you get all the selected note’s text.

However you want a quite precise page layout, so we have to approach this indirectly. This likely can be done by using HTML export and then using pandoc or print-to-PDF from a web browser to make the PDF.

It seems you want:

  • all child articles of container ‘Notes’
  • a two-column layout
  • landscape page orientation
  • per page item order (left to right/top to bottom) of note $SiblingOrder 2,1,4,3
  • per ‘cell’:
    • $Title + space-plus-ellipsis
    • A horizontal rule
    • Ellipsis-plus-space + $Text

Unclear:

  • title/text styling, if any (i.e. ^value($Text)^ vs ^text^, etc)
  • use of images, if any

So, possible, but not a 5 minute-job and requiring a fair degree of skill with HTML. I’ll let someone else take a crack at expanding this—if you need more help, I’m buried with work at present.

Okay. Thanks. In the interim, I’ll keep tinkering. I think I’m halfway there already actually. Thank you.

1 Like

Just curious, I would consider using MultiMarkdown and Marked in a table. Might be simpler and Marked has some nice easy export from Tinderbox or any text application. You might try that as well.

Tom

I note this as I was thinking about the fact that an HTML table probably isn’t the best approach and that <div>s and float positioning give more control in ‘table’ making, such that the eventual ‘print’ to PDF works as intended. It’s also why I suggested this wasn’t a simple 5-min task. This is not something basic table syntax will solve well, noting the “beautiful PDFs” in the thread title.

Given that Markdown is just inline markup for a limited subset of HTML I’m wondering how far this would get to the actual layout needed. Mixing Markdown with extra HTML seems to add complexity, might as well start out with the tool you are going to use: I’m sure opinions will vary. To be clear, I say that note to criticise Markdown as a technique but in regards to its suitability to achieve the degree of subtlety of layout-related code needed.

One practical point, arising form the order of the Tinderbox outline source vs. use on-page in the PDF, I’d consider either:

  • storing the source notes in the order they will be exported
  • storing the order in an attribute that can be used with an agent to export in the desired order (so the current outline order is maintained)

More radical, but if the key point is the end PDFs, you might consider structuring the source notes to assist the export. For instance, per-page (and per-row?) containers. The source notes are ‘cells’ in the layout whether using a table or stacked divs in a bounding box. A note doesn’t have to export any content. It can equally well act as an anchor for a template, such that the relationship of source and the template cascade can be seen—this is can be useful for those whose struggle abstracting the structure for the mind’s eye.

It’s been some years since I got deep into @media CSS and printing and I wondered about setting (signalling) intended page size—for fine control of design/test. This stackoverflow thread might be of use.

Actually, if one wanted to do this in HTML, I think the new(ish) grid module is likely what you want.

Edit: See the next post!
For those like me, for whom this is new (HTML’s evolving all the time), this might help explain:

I didn’t find a W3C formal link, so I guess it’s a technique more than a feature/standard. Avoiding tables seems a boon.

I was thinking of something else:

CSS Grid Layout (aka “Grid” or “CSS Grid”), is a two-dimensional grid-based layout system that, compared to any web layout system of the past, completely changes the way we design user interfaces.

1 Like

@pat, great! Can we invite you to an April meetup where you walk us all through on how to do this? It would be great to revisit this thread and teach people. :slight_smile:

2 Likes

As a crazy thing: a few years ago, someone needed a Tinderbox ➛ PowerPoint/Keynote workflow. I think we got a good way there.

I mention this because these tools are quite good at exporting slides 4-up and 6-up.

1 Like

I had am easy method (if your data could fit through a Keynote v1 [sic] format file during the process. IIRC is used a ‘blank’ file in an early version of OmniOutliner. Basically, it seems both Apple and Microsoft make the XML of their prez software deliberately and increasingly baroque to freeze out simple inter-doc-format translation.

Yes, I’ve needed to do this several times. :slight_smile:

I suspect pandoc can probably do HTML pages to a PPT (Keynote less likely)

Here’s my Tinderbox → Keynote demo that seemingly I updated in v9.6 (I don’t recall!)
TB-to-Keynote v96.zip (456.5 KB). Instructions included. The method was worked out originally way back the early days of Tinderbox v5—so c.2010!

Thanks Mark.

I tried to run the Make-Presentation app on Sonoma but here is what I got as an error

image

Tom

Hmm. I’m still on Ventura (I know, I ned to update…) but poking in the app(let) I see it was made in Script Debugger v4.5.4 (we’re now on v8.x!). But, thanks for flagging this.

Likely the app is updatable, but it means walking back over all the old code and figuring what Apple’s deprecated/broken since, so not an instant task (especially unless anyone has a pressing need vs. general interest). That said, the script within the app is:

property presName : "Tinderbox Presentation"

tell application "Finder"
	set myPath to (folder of (path to me)) as text
	set srcPresPath to myPath & "template.key"
	set srcDataPath to myPath & "presentation.apxl"
	
	if not (exists file srcDataPath) then
		set theWarning to "No 'presentation.apxl' file found. (Did you remember to export your Tinderbox data?)" & return & return & "This script will now quit"
		display alert theWarning buttons {"OK"} as warning
		return
	end if
	
	-- get the desired Keynote file name
	try
		set dialogAnswer to display dialog ¬
			"Please name your new Keynote file: " default answer presName buttons {"Cancel", "OK"} ¬
			default button "OK"
		if button returned of dialogAnswer is "OK" then
			set presName to text returned of dialogAnswer
			set blnHasExt to false
			if (characters -4 through -1 of presName as text) is equal to ".key" then
				set blnHasExt to true
			else
				set presName to presName & ".key"
			end if
			if (blnHasExt and presName is equal to "Template.key") or presName is equal to "Template" then
				display alert ¬
					"To avoid overwriting the source Keynote, your file will use the TB-pres default name for the new file." buttons {"OK"} as warning
				set presName to "TB-pres"
			end if
		else
			display alert "Action cancelled: no new Keynote file will be created." & return ¬
				& "N. B. This script will now quit." buttons {"OK"} as warning
			return
		end if
	on error number -128 -- userCanceledErr
		display alert "Action cancelled: no new Keynote file will be created." & return & return ¬
			& "N.B. This script will now quit." buttons {"OK"} as warning
		return
	end try
	
	set srcNewPresPath to myPath & presName
	set oldPresPath to quoted form of POSIX path of srcPresPath
	set newPresPath to quoted form of POSIX path of srcNewPresPath
	
	-- warn before overwriting existing same-name file
	if exists file srcNewPresPath then
		set theQuestion to "A previous version of Keynote file '" & presName & "' already exists." & return & return & "Do you wish to overwrite it?"
		try
			set dialogAnswer to display dialog theQuestion ¬
				buttons {"Yes", "No"} ¬
				default button "No"
			if button returned of dialogAnswer is "No" then
				display alert "Script will now quit." buttons {"OK"} as warning
				return
			end if
		on error number -128 -- userCanceledErr
			display alert "Script will now quit." buttons {"OK"} as warning
			return
		end try
	end if
	
	set dittoParams to " " & oldPresPath & " " & newPresPath
	do shell script "ditto" & dittoParams
	set oldDataFilePath to quoted form of POSIX path of srcDataPath
	set newDataFilePath to quoted form of POSIX path of (srcNewPresPath & ":presentation.apxl")
	set mvParams to " " & oldDataFilePath & " " & newDataFilePath
	do shell script "mv" & mvParams
	open srcNewPresPath
end tell

-- bring Keynote to the front
tell application "Keynote"
	activate
end tell

That might help people move ahead. HTH!

ok, no credit is deserved here…

I recompiled the script in Script Debugger (no changes made) and it worked.
Go figure…

here is the file that works for me…

Make-Presentation+.app.zip (4.0 MB)

2 Likes

Excellent—thanks! I hope it helps folk.

1 Like