Subscribe Bookmark RSS Feed

Page Breaks in HTML

dqr2

Community Trekker

Joined:

Jun 19, 2015

Hi - I'm creating an HTML file by assembling all the display boxes I want to include into the journal, and then exporting the journal to HTML.  This works well enough, but I'd like to insert page breaks between some of the display boxes to make the resulting HTML file print neatly.  I've tried adding "current journal () << append(page break box())" commands at the appropriate points, but this doesn't seem to work.  Should I be sending control codes to the journal instead - and if so, how can I do that please?

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Page breaks in HTML is typically handled with CSS. The JSL Page Break Box  seems to add a (variable) number of extra <br> when exported as HTML, but adds no extra CSS style.

 

A workaround could be to add the required code to the HTML after exported by JMP. This could be done with any text editor but it's also possible to do it with JSL.

Example (only tested with Safari but should work in most modern browsers):

Names Default To Here(1);

// Create example Journal
Open("$SAMPLE_DATA/Big Class.jmp");
Bivariate(Y(:weight), X(:height), By(:age), FitLine) << Journal;
myjournal = Current Journal();

// Find desired points for page breaks, e.g between By-groups
L = myjournal() << xpath("//OutlineBox[@helpKey='Bivariate Report']");
// Insert page breaks after each but last bivariate report
L[1 :: N Items(L) - 1] << append(Page Break Box()); 

//Save as html
myjournal << Save HTML("$HOME/pb_test.html");

// Manipulate and resave HTML
// Add internal CSS pbreak class and replace multiple <br> with that class
myhtml = Load Text File("$HOME/pb_test.html");
pos = Contains(myhtml, "</style>");
Insert Into(myhtml, ".pbreak { page-break-after: always; }\!n", pos);
While(Pat Match(myhtml, Pat Repeat("<br>", 2), "<div class=\!"pbreak\!"> </div>"), "");
Save Text File("$HOME/pb_test.html", myhtml);
2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

Page breaks in HTML is typically handled with CSS. The JSL Page Break Box  seems to add a (variable) number of extra <br> when exported as HTML, but adds no extra CSS style.

 

A workaround could be to add the required code to the HTML after exported by JMP. This could be done with any text editor but it's also possible to do it with JSL.

Example (only tested with Safari but should work in most modern browsers):

Names Default To Here(1);

// Create example Journal
Open("$SAMPLE_DATA/Big Class.jmp");
Bivariate(Y(:weight), X(:height), By(:age), FitLine) << Journal;
myjournal = Current Journal();

// Find desired points for page breaks, e.g between By-groups
L = myjournal() << xpath("//OutlineBox[@helpKey='Bivariate Report']");
// Insert page breaks after each but last bivariate report
L[1 :: N Items(L) - 1] << append(Page Break Box()); 

//Save as html
myjournal << Save HTML("$HOME/pb_test.html");

// Manipulate and resave HTML
// Add internal CSS pbreak class and replace multiple <br> with that class
myhtml = Load Text File("$HOME/pb_test.html");
pos = Contains(myhtml, "</style>");
Insert Into(myhtml, ".pbreak { page-break-after: always; }\!n", pos);
While(Pat Match(myhtml, Pat Repeat("<br>", 2), "<div class=\!"pbreak\!"> </div>"), "");
Save Text File("$HOME/pb_test.html", myhtml);
dqr2

Community Trekker

Joined:

Jun 19, 2015

This works perfectly, and will enable me to transform the look and feel of several of my current JMP-generated HTML reports.  The example also indicates how I might be able to tackle a couple of other formatting issues that I've been mulling over recently, so that's all been phenomenally helpful.

 

Many thanks!