Page breaks for printing/PDF Generation

After you use Eric’s method, or the Kin filter (hmm, could that be written now in wikitext?) to flatten your structure, you still have the problem of printing it out intelligently. For me, browser print-to-pdf works very poorly, especially in terms of pagination. Most of the them treat your entire document like a giant image, and then “paginate” by cutting it at regular intervals. This means that pagination can occur in the middle of an image, the middle of a paragraph, or even split a line along a horizontal axis. This is one area where some AI assistance would be welcome.

For nice looking documents, I find it necessary to copy the flattened text out to a word processor, and then go through and apply my own pagination, along with any other tweaks (like resizing or floating images).

1 Like

The situation is getting much better.

@Mohammad has done a lot of great work lately with print stylesheets. The charter I mentioned above1 uses similar techniques, and at least according to browser print previews, it now has reasonable pagination.


1 I forgot to mention earlier that the public view is read-only, but you can toggle edit mode with CTRL-SHIFT-1

1 Like

Are you talking about Printify?

When I try that, it’s very nice of course. But ideally you don’t want to print each tiddler on it’s own page unless it requires a page. What you would want is as many tiddlers printed on a page without splitting a tiddler. If you do need to split a tiddler, you would want any block content (like tables) to not be split unless of course the table is so big that it can’t fit on a single page.

I don’t think there is an easy way to automate this, but someday there might be an AI way.

I think this would do reasonably well for those requirements:

@media print {
  div.tc-tiddler-frame {break-inside: avoid;}
}

That’s a little more difficult as a general requirement, but I think you could do the same thing for table, and for other specific selectors you don’t want to break. (Arbitrary div or p elements might be more challenging.) I don’t know if there could be any useful general purpose stylesheet that would help, but I would expect you could do it for particular wikis. For instance, this seems to do reasonably well for tiddlywiki.com:

@media print {
    div.tc-tiddler-frame, table, .tc-card, .tc-link-info-item {break-inside: avoid;}
}
1 Like

Printify has a user-friendly interface that allows you to set page breaks and supports custom CSS for precise print control. It is based on the CSS Paged Media Module, though only a small part of it has been implemented in major browsers. Once fully supported, it will enable highly sophisticated printing. For instance, the running element feature lets you print a field value as the content of margin boxes for a chapter.

Ref:

1 Like

My needs to print from TW to date have been minimal, but tbh, this is likely what I’d be looking at too, though I’d likely use homebrewery, since it uses markdown and except for output generated by wikicode, could be translated to from the source tid.

(sadly, I dont think homebrewery’s markdown extensions to set styles, and etc is at all compatible with the standard TW markdown extension)