This example demonstrates the header and footer capabilities provided with an enhanced formatting license (included in a ScriptX.Services license but an option with the Add-on). These are significantly more rich and customizable than those provided with the browser.
The enhanced formatting options are set using the printing.enhancedFormatting object. For example, this sample is formatted like this:
var ef = MeadCo.ScriptX.Printing.enhancedFormatting; // save some typing ef.allPagesHeader = "<div style='border: 1pt solid red; font: bold 12pt Arial; background: threedface; color: navy; padding-Top: 5px; padding-Bottom: 6px; background-Image: url(http://support.meadroid.com/images/non_act_bg.jpg)'> <center> --- Header for page <b> &p </b>---</i> </center></div>"; ef.allPagesFooter = "<div style='border: 1pt solid red; font: bold 12pt Arial; background: threedface; color: navy; padding-Top: 5px; padding-Bottom: 6px; background-Image: url(http://support.meadroid.com/images/non_act_bg.jpg)'> <center> --- Footer for page <b> &p </b> ---</i> </center></div>"; ef.firstPageHeader = "<div style='border: 1pt solid red; font: bold 12pt Arial; background: threedface; color: white; padding-Top: 5px; padding-Bottom: 6px; background-Image: url(http://support.meadroid.com/images/act_bg.jpg)'> <center> --- Header for page <b> &p </b>--- </center> </div>"; ef.firstPageFooter = "<div style='border: 1pt solid red; font: bold 12pt Arial; background: threedface; color: white; padding-Top: 5px; padding-Bottom: 6px; background-Image: url(http://support.meadroid.com/images/act_bg.jpg)'> <center> --- Footer for page <b> &p </b>--- </center> </div>"; ef.extraFirstPageFooter = "<div style='color:red; font:bold 6pt Arial'> <img src='http://support.meadroid.com/quicksamples/sx_stat.gif'> EXTRA FIRST PAGE FOOTER AS IMAGE<br> </div>";
HTML headers and footers are described by setting printing.enhancedFormatting properties in script. The following properties are supported:
Property | Description |
allPagesHeader | A string value of the (html) header to apply to all pages. |
allPagesFooter | A string value of the (html) footer to apply to all pages. |
irstPageHeader | A string value of the (html) header to apply to the first page only, this value will override any allPagesHeader value on the first page (only). |
firstPageFooter | A string value of the (html) footer to apply to the first page only, this value will override any allPagesFooter value on the first page (only). |
extraFirstPageFooter | A string value of an additional (html) footer to apply to the first page only, this footer will be in addition to any footer already specified and positioned above the footer. |
allHeaderHeight | The height, in points, of the all pages header. |
allFooterHeight | The height, in points, of the all pages footer. |
firstHeaderHeight | The height, in points, of the header for the first page only. |
firstFooterHeight | The height, in points, of the footer for the first page only. |
extraFirstFooterHeight | The height, in points, of any extra footer that is applied to the first page only. |
A header such as this:
is scripted by setting either the firstPageHeader or allPagesHeader property, for example:
MeadCo.ScriptX.Printing.enhancedFormatting.allPagesHeader = "<div style="border: 1pt solid red; font: bold 12pt Arial; background: threedface; color: navy; padding-Top: 5px; padding-Bottom: 6px; background-Image: url(http://support.meadroid.com/images/non_act_bg.jpg)"> <center><i>--- Header for page <b> &p </b> ---</i> </center></div>"
applies the given header to all pages. See the following section for discussion of firstPageHeader.
To print specific information as part of the header or footer, include the following meta-characters as part of the text:
Use this | To print this |
&w | Window title |
&u | Page address (URL) |
&d | Date in short format (as specified by Regional Settings in Control Panel) |
&D | Date in long format (as specified by Regional Settings in Control Panel) |
&t | Time in the format specified by Regional Settings in Control Panel |
&T | Time in 24-hour format |
&p | Current page number |
&P | Total number of pages |
&& | A single ampersand (&) |
Enable different headers and footers for the first page by providing values for the header and/or footer to be used on the first page; firstPageHeader and/or firstPageFooter
An additional footer for the first page only can also be provided. This is how the footer image on the first previewed/printed page of this example is defined:
MeadCo.ScriptX.Printing.enhancedFormatting.extraFirstPageFooter = "<div><img src='http://support.meadroid.com/quicksamples/sx_stat.gif'></div>"
Required heights can be set by defining various properties
var ef = MeadCo.ScriptX.Printing.enhancedFormatting; ef.firstHeaderHeight = 180; ef.firstFooterHeight = 180; ef.extraFirstFooterHeight = 60; ef.allHeaderHeight = 120; ef.allFooterHeight = 120;
All of these values will be calculated automatically if you don't set their properties.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ultricies varius metus, sit amet pretium nulla varius sit amet. In vestibulum felis vel leo condimentum, eget blandit enim mattis. Morbi et sapien sed leo lacinia scelerisque. Suspendisse ullamcorper libero sed sem molestie, quis tristique massa convallis. Vivamus egestas finibus turpis, sed iaculis augue tincidunt vel. Nunc lobortis ultrices massa, non lobortis neque. Proin faucibus condimentum justo, in lobortis mauris maximus vel. Duis eu urna ut massa imperdiet placerat vel vel dolor. Nullam id velit pharetra, molestie tellus non, sagittis purus. Aenean pellentesque sapien nisl, quis cursus neque malesuada sit amet. Vivamus vitae lectus turpis. Donec porta sem ac cursus mattis.
Suspendisse potenti. Mauris et fringilla diam. Phasellus sed feugiat eros. Etiam sed posuere ex, ut feugiat neque. Donec luctus, eros vel tempus varius, nisi justo interdum ipsum, dignissim ultricies dolor enim in diam. Pellentesque aliquam sapien a dolor vulputate posuere. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet elit a sem varius sollicitudin. Nullam suscipit aliquet libero, dictum volutpat mi elementum ac.
Ut sit amet odio sagittis, dapibus dui sit amet, luctus sem. Proin viverra ligula quis ligula egestas dapibus. Pellentesque consectetur luctus nulla. Vestibulum vel turpis vulputate, fermentum ligula et, pellentesque orci. Sed vehicula ex ut sem tincidunt luctus in at enim. Nulla non urna non tortor vestibulum tincidunt consectetur quis sapien. Sed venenatis mattis quam ac pretium. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec auctor viverra pharetra. Morbi suscipit massa vel consectetur imperdiet. Sed ultrices iaculis lectus et accumsan. Donec malesuada vitae diam ac vehicula. Cras ullamcorper metus metus. Nulla venenatis mauris odio, in sollicitudin nunc viverra vel. Nam velit enim, bibendum eu commodo sed, aliquet nec turpis.
Nulla aliquam lacinia lectus, sit amet eleifend dui sollicitudin eget. Ut blandit malesuada lacus, quis mattis lorem. Integer commodo arcu sit amet pretium laoreet. Sed nulla ipsum, rutrum non ornare et, molestie eu ex. Etiam dignissim, urna sed faucibus commodo, felis quam vehicula neque, condimentum faucibus velit ex eu magna. Nulla laoreet magna ut mauris elementum, non iaculis neque faucibus. Cras rutrum venenatis mi a ornare. Cras pretium, libero ac faucibus bibendum, quam leo fringilla enim, quis pharetra enim libero vel libero.
Ut libero neque, lobortis blandit mollis in, finibus vitae dolor. Fusce luctus sodales neque, at lacinia urna consequat quis. Nunc eget tincidunt lorem. Nulla facilisi. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean id suscipit metus, in bibendum nibh. In hac habitasse platea dictumst. Vivamus interdum metus mi, eget ullamcorper lectus rutrum non.
Quisque eu erat risus. Phasellus tempus tellus dolor, in luctus augue congue nec. Nulla lacinia blandit neque ac volutpat. Suspendisse facilisis luctus ex, quis elementum neque faucibus nec. Duis vitae nibh purus. Proin vulputate eros nisi. In ut volutpat massa, sit amet ultricies leo. Mauris nec maximus justo. Fusce molestie tempor quam a tempus. Curabitur tristique pellentesque accumsan. Nunc sit amet felis sed est commodo auctor. Curabitur ligula justo, ullamcorper at congue sed, posuere eu elit. Fusce interdum porttitor metus, eu imperdiet sapien ultrices eu.
Vivamus molestie sem eget nibh euismod, eu lobortis mi vestibulum. Vestibulum tempor ante massa. Ut neque leo, pellentesque vitae mollis eget, facilisis nec nulla. Nulla non lacus massa. Fusce quam metus, accumsan malesuada rhoncus sit amet, viverra eget eros. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis finibus augue in ante porttitor eleifend. Cras vehicula maximus orci, at convallis nunc lacinia nec. Morbi placerat elementum iaculis. Maecenas euismod, augue vel semper luctus, ipsum turpis commodo nunc, nec gravida nisl felis id eros. Aliquam erat volutpat.
Quisque et blandit sapien. Integer vitae congue erat, id vulputate nibh. Praesent tristique tincidunt facilisis. Nunc suscipit pulvinar velit at lobortis. Cras faucibus elit finibus, elementum ipsum a, euismod nunc. Etiam gravida dolor in quam aliquet, non maximus est finibus. Nam in urna venenatis metus bibendum scelerisque non eget lorem. Suspendisse ultrices venenatis aliquet. Nam tincidunt et felis sit amet elementum. Nullam vitae orci enim. Vivamus dapibus diam id tristique commodo. Curabitur rutrum accumsan congue.
Nunc accumsan suscipit diam ac mattis. Integer lorem arcu, blandit ac vestibulum eu, rhoncus et leo. Fusce blandit eu turpis non varius. In rutrum, leo et venenatis pulvinar, tellus metus euismod elit, vel semper enim arcu ac turpis. Nunc non ex vitae mi porttitor mollis non a turpis. Nunc lacinia imperdiet imperdiet. Curabitur vehicula interdum odio sit amet volutpat. Nulla sed suscipit justo.
Fusce a suscipit nisi. Proin in ultrices turpis. Integer bibendum ipsum vestibulum, malesuada elit eget, fermentum magna. Vivamus cursus suscipit massa, in iaculis risus molestie et. Aliquam erat volutpat. Etiam pulvinar auctor dui. Sed sed eros sapien. Morbi convallis, libero quis tincidunt tempor, arcu ex vulputate justo, efficitur pulvinar dolor enim eget elit. Integer gravida orci ex, vitae efficitur leo condimentum vel. Nunc eu purus lorem. Mauris et augue viverra, pretium metus et, lobortis arcu.