cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Styler rule to combat when the Title of a topic is to close to the bottom of the page

bfriesen
18-Opal

Styler rule to combat when the Title of a topic is to close to the bottom of the page

We have an issue where we are often left with a level 2 or 3 title and short description stuck on the bottom of a page, while the rest of the topic is on the next page.

 

bfriesen_0-1732126964253.png

What are my options? My thought is to create a rule that would check the room left on the page, and if the title element was within the last 3 in. of the bottom of the page it would start the topic on a new page. Is that possible?

 

Bryon

7 REPLIES 7
SimonTaylor
14-Alexandrite
(To:bfriesen)

Hi Bryon

You're going to need to use an APP source edit to test the baseline position of the title and, if it is greater than some threshold, output a page break or set the top margin to something large to force it over to the next page.

Something like

if (formatting.currentState.yBase > new fLength("200mm") {

  formatting.output(""); //For the page break or block.marginTop = "40mm" for the top margin

}

Put that edit in a property set and apply that to the title, then you can reuse it and it doesn't lock up your title from being styled.

Hope that helps

Simon

Hello Simon, I added the following according to your sample above

 

bfriesen_0-1732553107990.png

 

A publish throws a whole page of warnings and errors. How do I decipher the errors?

 

Bryon

 

<Record date="Mon Nov 25 10:35:22 2024" millis="1732552522"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 15 Javascript&colon; ReferenceError: reference
to undefined property formatting.currentState.yBase onEnter([object
fBlock],[object Object])@stylesheet0:PropertySet:Page_Break:onEnter:1
onEnter([object fStreamPos])@stylesheet0:Element:title:title_in_procedure_in_division:onEnter:22
runMacro("sprint \"_app:spFormatWithIndex\"",true)@:0 @_app:FormatWithIndex:3
. [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_division:onEnter"#105)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[1]/procedure[1]/title/#_app:Gentext})

</Message>
</Record><Record date="Mon Nov 25 10:35:22 2024" millis="1732552522"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 15 Javascript&colon; stylesheet0:PropertySet:Page_Break:onEnter:1:
ReferenceError: reference to undefined property formatting.currentState.yBase
. [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_division:onEnter"#105)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[1]/procedure[1]/title/#_app:Gentext})

</Message>
</Record><Record date="Mon Nov 25 10:35:22 2024" millis="1732552522"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 15 Block end mismatch: Trying to end
(title_in_procedure_in_division) with current nesting (techinfomap_everywhere/division_everywhere_else/procedure_first_in_its_parent_anywhere_i7A22)
[1209] (2:"stylesheet0:Element:title:title_in_procedure_in_division:onExit"#0)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[1]/procedure[1]/titlealts})

</Message>
</Record><Record date="Mon Nov 25 10:35:22 2024" millis="1732552522"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 15 Block end mismatch: Trying to end
(procedure_first_in_its_parent_anywhere_i7A22) with current nesting
(techinfomap_everywhere/division_everywhere_else) [1209] (2:"stylesheet0:Element:procedure:procedure_first_in_its_parent_anywhere_i7A22:onExit"#122)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[1]/procedure[2]})
<Level>ERROR</Level><Message>Pg 22 Table Column 1 too narrow to fit
text - skipped to next col [1200] (3:"_s_h_o_w_22_"#2861) (2:"stylesheet0:Element:image:image_everywhere_else:onEnter"#4021)
(1:"editorDom0"#{1;/RDStyle/ResolvedMap/techinfomap/division[1]/procedure[7]/procbody/procsteps[3]/procstep/procinfo/fig/#_app:Gentext/_sfe:BeforeOrAfterText/image})

</Message>
</Message>
</Record>

SimonTaylor
14-Alexandrite
(To:bfriesen)

Hi Bryon
Sorry, I didn't get a notification that you'd had problems.

Did you try adding a big margin to the top of the block?

Simon

Finally getting back to this issue.

 

I made the following changes below to the original suggestion and it now stop throwing error messages, but still does not seem to work as expected. I would expect the title in image below should have moved to the top of the next page.

 

1 if (!formatting.currentState) {
2 formatting.currentState = {};
3 }
4 if (typeof formatting.currentState.yBase === 'undefined') {
5 formatting.currentState.yBase = new fLength("0mm");
6 }
7 if (formatting.currentState.yBase > new fLength("220mm")) {
8 formatting.output("&#5;"); // For the page break
9 block.marginTop = "10mm"; // For the top margin
10 }

 

bfriesen_0-1744746962963.png

 

Bryon

 

SimonTaylor
14-Alexandrite
(To:bfriesen)

Hi Bryon

I just noticed a syntax error in the original code I sent you - it needed an extra closing parenthesis after the condition of the if statement. Also, the property is 'ybase' rather than 'yBase'. That's probably where the errors were being generated...

if (formatting.currentState.ybase > new fLength("200mm")) {

  formatting.output("&#5;"); //For the page break or block.marginTop = "40mm" for the top margin

}

There are some naughty things in your version - formatting.currentState is set by the APP formatting engine, so you really shouldn't be redefining that! 

Hope this helps

Simon

Thanks for the help Simon, Just so I understand what the script is doing. It is looking for an element in the bottom 200mm (4in) of a page. Is this from the bottom of the physical page or from the top of the footer? If it finds one, it inserts a page break, then moves the element to the next page.

 

I have changed it back to what you had suggested. I have added the property set to all three levels of titles, but when publishing I got an error with this change something about a block end mismatch What does this mean 

 

<Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Javascript&colon; TypeError: arguments[0].source
is null onEnter([object fStreamPos])@stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter:28
runMacro("sprint \"_app:spFormatWithIndex\"",true)@:0 @_app:FormatWithIndex:3
. [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter"#155)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/title/#_app:Gentext})

</Message>
</Record><Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Javascript&colon; stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter:28:
TypeError: arguments[0].source is null . [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter"#155)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/title/#_app:Gentext})

</Message>
</Record><Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Block end mismatch: Trying to
end (title_in_procedure_in_procedure_in_division) with current nesting
(techinfomap_everywhere/division_everywhere_else/procedure_first_in_its_parent_anywhere_i7A22/procedure_everywhere_else)
[1209] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onExit"#0)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/titlealts})

</Message>
</Record><Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Javascript&colon; TypeError: arguments[0].source
is null onEnter([object fStreamPos])@stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter:28
runMacro("sprint \"_app:spFormatWithIndex\"",true)@:0 @_app:FormatWithIndex:3
. [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter"#155)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/title/#_app:Gentext})

</Message>
</Record><Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Javascript&colon; stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter:28:
TypeError: arguments[0].source is null . [1500] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onEnter"#155)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/title/#_app:Gentext})

</Message>
</Record><Record date="Thu Apr 17 08:43:37 2025" millis="1744897417"
severity="error" suppress="0">
<Level>ERROR</Level><Message>Pg 368 Block end mismatch: Trying to
end (title_in_procedure_in_procedure_in_division) with current nesting
(techinfomap_everywhere/division_everywhere_else/procedure_first_in_its_parent_anywhere_i7A22/procedure_everywhere_else)
[1209] (2:"stylesheet0:Element:title:title_in_procedure_in_procedure_in_division:onExit"#0)
(1:"editorDom0"#{0;/RDStyle/ResolvedMap/techinfomap/division[11]/procedure[1]/procedure[3]/titlealts})

</Message>
</Record>

 

Thanks

 

Bryon

I have been modifying the fLength dimension and I don;t think it is working correct yet. 

 

Bryon

 

bfriesen_1-1744979636894.png

 

Announcements

Top Tags