Markdown files: Exporting to PDF or printing

Is there any good way to print a .md file from Seahub or exporting it to PDF, including inline images? I could live with the way Seahub renders it, but printing does not work (page won’t scroll).

Generating PDF from Markdown is on the roadmap for 7.1.

1 Like

I wanted to have that for myself so I created some quick & dirty CSS rules. Tested on FF only.

Create a custom.css file as described in the manual and add:

/* Make Markdown printable */
@media print {

	.sf-md-viewer-topbar,
	.seafile-rich-editor-topbar {
		display: none;
	}

	.seafile-editor {
		position: inherit;
	}

	.seafile-editor-main,
	.seafile-editor-main-panel {
		display: block !important;
	}

	.editor {
		border: none;
		padding: 0;
	}

	.article table {
		border: 1px solid #000;
		border-collapse: separate;
		border-spacing: 0;
	}

	.article table tr {
		display: table-row;
	}

	.article table td,
	.article table th {
		border-width: 1px 1px 1px 1px;
		border-color: #000;
	}

}
2 Likes

Awesome, this works… somewhat. It breaks when displaying markdown tables* in print preview and seems to especially hate tables going across page borders.

Is there anything I can do about that? Thanks!

*these things:

| header1 | header2 |
| -----------| ----------- |
| stuff1.1  | stuff 2.1  |

I have added some rules for tables.

Cheers, looks slightly better now! Still has issue on page breaks though. I take it there’s not much more that can be done with just CSS is it?

Can you verify that the table rules

.article table tr,
.article table th {
	display: table-row;
}

are active? I have seen those crazy tables of yours before I added these rules.

I have tested them with different complex tables and they seem to work well for me. Otherwise please send a failing markdown file with test data, I will have a look.

1 Like

I did indeed not have those in my custom CSS. Something must have gone wrong during copy/paste. Everything looks good now, thanks!

Just one minor thing: is it possible somehow to “close” tables spanning page breaks properly? I.e. this is what it looks like currently:

Can the border at row “904” be closed by some CSS magic?

I had to find a compromise to put this into effect, but it works. The borders are a little bit thicker now. Just copy the updated code from my first post.

1 Like

Sorry for the late reply, christmas and new year curbed my forum posting enthusiasm. This now works beautifully, many thanks!

1 Like

@daniel.pan I think it would be great to have these or similar with Seafile to fix printing.

We will check the problem.

1 Like

@shoeper

Well, it was moved out to Seafile 8.0 with the updated roadmap.

So my effort wasn’t wasted. :grin:

1 Like