Avoid page breaks at certain positions

Comments

8 comments

  • Avatar
    Patrick Vanhoof

    Not possible?

    0
    Comment actions Permalink
  • Avatar
    Sharon

    Has there been a response to this? I would also like to be able to keep certain lines together, basically, a "keep with next" option. 

    0
    Comment actions Permalink
  • Avatar
    Nils Bier

    Hi,

    you could try to create a user macro setting a class (e.g. "keep with next") to the content in this macro body (<p class="keep-with-next">$body</p>) and then define to avoid page breaks in this class by using the content formatting section of your template:

    p.keep-with-next {
    page-break-after: avoid;
    }

    Does that help?

    Best,
    Nils

    1
    Comment actions Permalink
  • Avatar
    Sharon

    Hi Nils, 

    That worked! Thanks so much!

    I tried the same technique for the Note Macros, but I'm still having issues keeping the icon and title with the note body text. (I had tried using the page-break-inside: avoid; attribute and it didn't work at all). I tried to apply the page-break-after: avoid; attribute to the title class:

    .wikicontent div.admonition-info div.title {
    color: Black;
    font-style: Italic;
    page-break-after: avoid;
    }

    That kept the Note title with the Note body, but the icon wound up on the previous page all by itself. 

    So I added it to the icon as well:

    .wikicontent div.admonition-info.admonition-icon {
    background-image: url(note.png);
    page-break-after: avoid;
    }

    That kept both the title and the icon with the note body, but now if there are two notes one after the other, they both move to the next page, which leave a big gap on the previous page. I want to allow the page to break after the note body but still keep the note title and the note icon with the note body. 

    I attached some screenshots so you can see the effects of each option: 

    AvoidPageBreakAfteronIconOnly.png - I added the attribute to .wikicontent div.admonition-info.admonition-icon only. Both the icon and note title are left on the previous page. 

    AvoidPageBreakAfterontitleOnly.png - I added the attribute to .wikicontent div.admonition-info div.title only. Now the title moves to the next page, but the icon is left on the previous page. 

    AvoidPageBreakAfteronBothTitleandIcon.png - I added the attribute to .wikicontent div.admonition-info.admonition-icon and to .wikicontent div.admonition-info div.title. Now both the title and the icon move to the next page, but the first note also moves to the next page instead of staying on the previous page and breaking after the note body. 

    Sharon




    AvoidPageBreakAfteronIconOnly.PNG
    AvoidPageBreakAfteronTitleonly.PNG
    AvoidPageBreakAfteronBothTitleandIcon.PNG
    0
    Comment actions Permalink
  • Avatar
    Nils Bier

    Hi Sharon,

    that's a known issue of our current library: https://k15t.jira.com/browse/EXP-528

    Unfortunately we can't change that until we move to another PDF library. We're already evaluating one, but are not able to give an ETA when the switch will be done.
    Please sign up at https://k15t.jira.com/secure/Signup!default.jspa to watch, comment on or vote for this issue. You'll then get a notification for every status update on the issue.

    Best,Nils

    0
    Comment actions Permalink
  • Avatar
    Sharon

    Hi Nils, 

    Manually inserting page breaks is a VERY bad workaround. Every time a change is made to the content, you would have to manually move the page breaks. We have 2000 pages and I really do not want to manually manage page breaks. As I described in my earlier comment, I did use the page-break-after:avoid; parameter on the note icons and titles, and it kept them with the note body, but then it doesn't break after the note body. So, to allow a page break after a note, I created another user macro to set the font size and spacing to 0 and set the page-break-after parameter to auto. After every note, I insert this page break macros so the content can break at that point. It's clumsy and messy, but it works.... but only for Warning notes. I did the same thing for Info notes, but it doesn't seem to read the page-break-after: avoid; parameter on the icon and title in the same way.... so warning notes are now breaking correctly, but Info notes are still not sticking together (i.e., the icon and/or title can be left on one page when the note body is on the next page). I haven't come across an instance where a caution note or tip note is at the page break position to know if they are working or not.

    So I'm wondering if there is a difference in the way Warning notes and Info notes are coded that would make the page-break-after:avoid; parameter work for warnings, but not for info notes? Or.... do I have a mistake in the CSS for info notes that I'm not seeing? 

    This is my CSS for warnings:

    .wikicontent div.admonition-warning {
    background-color: transparent;
    font-weight: bold;
    }

    .wikicontent div.admonition-warning.admonition-icon {

    background-image: url(warning.png);

    page-break-after: avoid;
    }
    .wikicontent div.admonition-warning div.title {
    color: Black;
    font-weight: bold;
    page-break-after: avoid;
    }

    And this is my CSS for info notes:

    .wikicontent div.admonition-info {
    background-color: transparent;
    border-color: transparent;
    font-style: Italic;
    }
    .wikicontent div.admonition-info.admonition-icon {
    background-image: url(note.png);
    page-break-after: avoid;
    }
    .wikicontent div.admonition-info div.title {
    color: Black;
    font-style: Italic;
    page-break-after: avoid;
    }

    Thanks again, 

    Sharon

    0
    Comment actions Permalink
  • Avatar
    Alexander Sopov

    Hi!

    I found the following to be very interesting:

    "you could try to create a user macro setting a class (e.g. "keep with next") to the content in this macro body (<p class="keep-with-next">$body</p>) and then define to avoid page breaks in this class by using the content formatting section of your template:

    p.keep-with-next {
    page-break-after: avoid;
    } "

     

    Could anyone tell me how to create such a user macro setting a class? That would be tremendously helpful, thank you!

    0
    Comment actions Permalink
  • Avatar
    Thomas Walker (K15t Software)

    Hi Alexander,

    thank you for the question.

    Our documentation contains a guide on how to create and use this macro to avoid unwanted page breaks, you can find it here: https://help.k15t.com/scroll-pdf-exporter/avoiding-page-breaks-in-certain-positions-117905240.html.

    If you have any difficulties, or if you don’t understand any of the steps, please ask us here.

    Best wishes,

    Tom.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk