How to create RTFs with headings from tinderbox outline?

I’ve tried many methods to use export to create a .docx or .rtf that uses note levels to create header levels, but with no joy. I can manually set header levels in MSword, but this is not acceptable when I need to iterate a document. It seems that with any mode (text, outline) the output I get looks great but contains no header information; all note levels are converted to “normal” text, not heading1, heading2, heading 3…etc.

I haven’t tried HTML to RTF yet, maybe that will work but is crude. Thanks for any input for getting Word docs that have at least basic formatting to them from outline levels.

John L

The short answer: don’t use .doc or .rtf export. To get the styling in Word document that you want, use export templates that incorporate CSS styles in HTML exports. The CSS defines the styling for header levels, H1, H2, etc. Export the note(s) as an HTML file and import that to Word. The headers you defined in the HTML will be recognized by Word, and the CSS styles will be saved as Word Styles. Re-save the document from Word as .docx. You’re done

I do this over and over and it works very well.

You can download from the link below a zip file that contains a sample Tinderbox document with working examples of the templates you need, and a container to export into a simple document. Also included are the exported .html is included (open in Word); and the .docx I saved from that .html file.

https://d.pr/f/fNIb1w+

4 Likes

thanks so much for this. I’ve used CSS and its a lot easier to write than an rtf template. So yes I’ll try this out. Seems counterintiative, but html templates are quite simple to code up. Thanks again.

Great. Templates are portable, of course, Learn a few simple rules, copy the templates from document to document or make starter documents, and you’re good to go over the long run.

A couple of tips.

  • If you have rich, styled text in your notes (bold, italicized, etc.) then export using ^text^ in your templates, and do not use ^value($Text)^. (Thanks to @mwra for explaining this patiently to me.)
  • As shown in the templates posted, use <h^value(OutlineDepth)^>[something]</h^value(OutlineDepth)^> to get your html to contain the proper <h1></h1>, <h2></h2>, etc., tagging for different indention levels.
  • Use <div>s to set up sections / section breaks that carry forward to your Word document.
3 Likes

only one question… all this works great and with much larger files as well. BUT, I wasn’t able to keep images referred correctly; they still get referred to non-existent sub-folders that would exist with the standard html export that makes up a folder per note.

All else, styles, headings, tables all work well and create a single big html file which exports nicely into MSword. Any suggestions on the last hurdle?

Thanks,
John

There could be many things at play here. Not knowing the notes and the HTML they create, it’s hard to point a finger on the exact cause and solution. Could you post a small sample that is not working as expected?

RTF does not support images. There’s a variant standard, RTFD. that does allow embedded images; few programs support it any longer.

@eastgate, I believe @jrl is referring to exporting to HTML per this reply of mine, above, not to the RTFs per se, mentioned in the original posting in the thread.


An answer (among many) for @jrl is to put your images into a subfolder of the folder where you will export the document. I usually use a folder named images. Rather than adding the images to the $Text of your notes, you add a reference to the image such as this (for an image of a bird):

<img src=images/swallow.jpg>

When you export the HTML it will have the correct image references. When you import the HTML you will see the images. Word 365 or Word 2016 or later might ask permission to open the image files, due to macOS gatekeeper protections. You can then save that document from Word as a .docx file that contains the images.

(Note Tinderbox Preview will not show the images when you use this particular method – there are other approaches, if Preview matters to you. You can also use more complex <img> tags and CSS to position, size, add borders, etc.)

Thanks again Paul. I can certainly see where writing the html link inside $Text would do that job.

I would prefer if I could keep the images in $Text, as that is where I usually look at them while working. The export is for handing readable docs to those many others who don’t use tinderbox.

I wonder if dragging the picture into the URL attribute would allow me to use that attribute to export, while allowing internal click-access to the pictures while in tinderbox? It’s imperfect, but has the other advantage of not increasing tinderbox file size with more internally embedded pictures.

John

1 Like

That’s actually clever. If you drag an image to $URL (or any attribute you create of kind “URL”), Tinderbox will create a file:/// URL pointing at that image. In the $Text you can insert

<img src=^value($URL)^>

and the exported HTML will be fine.

1 Like