Skip to content

Page break feature? #113

@ericphanson

Description

@ericphanson

I wanted to have a cell that would insert a page break for customizing how PDFs render. I came up with

page_break = html"""
<style>
@media print {
   .noprint {
 	  margin: 0px;
	  visibility: hidden;
	  min-height: 0px;
          max-height: 0px;
   }
   .noprint kbd {
	  content: "";
   }
}
</style>
<script>
let cell = currentScript.closest("pluto-cell");
cell.style.pageBreakAfter = "always";
cell.style.borderBottom = "3px solid rgba(0, 0, 0, 0.25)";
cell.style.borderTop = "3px solid rgba(0, 0, 0, 0.25)";
cell.classList.add("noprint");
</script>
<kbd>Break</kbd>
"""

so that if you write page_break as a cell, it will make a page break in the PDF and hide that cell.

I thought others might find this useful or have ideas for how to improve it, and that something like this could be useful in PlutoUI. (Wasn't sure where to put it, let me know if this is the wrong place).

edit: tweaked it a few times in edits; it's tricky because display: none deletes it from the print mode (I think?) so it doesn't make the page breaks, but visibility: hidden makes it take up vertical space that can throw off the page breaks. So I tried to just make it take up no vertical space in print mode, but still exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions