# The OpenJade RTF backend

### Created by James Clark

## Contents

- Supported Flow Objects
  - character
  - display-group
  - rule
  - score
  - line-field
  - leader
  - link
  - box
  - sequence
  - external-graphic
  - paragraph
  - paragraph-break
  - simple-page-sequence
  - table
  - table-part
  - table-column
  - table-row
  - table-cell
  - table-border
  - table-border
  - math objects to be included

## Supported Flow Objects

character
Inherited characteristics | Non-inherited characteristics

- font-weight
- font-posture
- font-name
- font-size
- input-whitespace-treatment
- position-point-shift
- language
- country
- color

Back to top

display-group
Inherited characteristics | Non-inherited characteristics

- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?

Back to top

rule
Inherited characteristics | Non-inherited characteristics

- line-cap
- line-thickness
- line-repeat
- line-sep
- position-point-shift
- display-alignment (start, end, center)
- start-indent
- end-indent
- span (spans all columns if > 1)
- color

- orientation (horizontal, escapement)
- length
- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?

Only the horizontal orientation is supported. Rules only show up in Page Layout View

Back to top

score
Inherited characteristics | Non-inherited characteristics

- line-repeat (1 for type of before and through, 1 or 2 for after)

- type (before, through, after)

Back to top

line-field*
Inherited characteristics | Non-inherited characteristics

- field-width
- field-align

* At the beginning of paragraph only.

Back to top

leader*
Inherited characteristics | Non-inherited characteristics
* On the last line of paragraph only. The principal port (the leader string itself) can contain characters only. The content of the flow object is ignored: a dotted leader will always be used. The specified length is ignored: it always fills out the line.

Back to top

link
Inherited characteristics | Non-inherited characteristics

- destination [#f, objects returned by (idref-address ...) and (current-node-address ...)]

* Only destinations that are single elements in the same RTF output file.

Back to top

index-entry
Inherited characteristics | Non-inherited characteristics

- components
- page-number?
- sort-string
- starts-page-range?
- ends-page-range?

components
  is a list of strings that represent index entry levels. This characteristic is not inherited and shall be specified.
page-number?
  is a boolean specifying whether this index entry should contain page number information. This characteristic is not inherited. The default is #t.
sort-string
  is either #f, specifying that this index entry's components should be used for sorting the index, or a string that should be used for sorting. This characteristic is not inherited. The default is #f.
starts-page-range?
  is a boolean specifying whether the index entry starts a page range. This characteristic is not inherited. The default is #f.
ends-page-range?
  is a boolean specifying whether the index entry starts a page range. This characteristic is not inherited. The default is #f.

Only destinations that are single elements in the same RTF output file.

Back to top

external-graphic
Inherited characteristics | Non-inherited characteristics

- space-before
- space-after

- display?
- scale (max)
- max-width
- max-height
- entity-system-id
- display-alignment
- start-indent
- end-indent
- span (spans all columns if > 1)
- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?

On Windows platforms, this can be used to embed OLE objects, by making the the value of the `notation-system-id:` a formal system identifier whose storage manager is `CLSID` and whose storage object identifier is the COM CLSID (including surrounding braces). The system identifier may also be just `<CLSID>` (that is, the storage object identifier may be empty); in this case, the OLE default CLSID for the file (usually chosen based on the file's extension) will be used.

Back to top

paragraph
Inherited characteristics | Non-inherited characteristics

- lines (wrap, asis-wrap)
- hyphenation-ladder-count
- hyphenation-remain-char-count
- hyphenation-push-char-count
- font-weight
- font-posture
- font-name
- font-size
- quadding
- widow-count
- orphan-count
- language
- country

- span (spans all columns if > 1)
- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?
- line-spacing
- min-leading (#f or 0 for proportional line spacing)
- first-line-start-indent

Back to top

paragraph-break
Inherited characteristics | Non-inherited characteristics
Same as for paragraph | Same as for paragraph

Back to top

simple-page-sequence
Inherited characteristics | Non-inherited characteristics

- page-width
- page-height
- left-margin
- right-margin
- top-margin
- bottom-margin
- header-margin
- footer-margin

- left-header
- center-header
- right-header
- left-footer
- center-footer
- right-footer

(page-number-sosofo)
(current-node-page-number-sosofo)
"UNREGISTERED::James Clark//Procedure::if-first-page"
  This can be used only in the specification of the value of one of the header/footer characteristics of simple-page-sequence. It returns a sosofo that will display as sosofo1 if the page is the first page of the simple-page-sequence and as sosofo2 otherwise.
"UNREGISTERED::James Clark//Procedure::if-front-page"
  This can be used only in the specification of the value of one of the header/footer characteristics of simple-page-sequence. It returns a sosofo that will display as sosofo1 if the page is a front (ie recto, odd-numbered) page and as sosofo2 if it is a back (i.e. verso, even-numbered) page.
"UNREGISTERED::James Clark//Characteristic::page-n-columns"
  Value is a strictly positive integer, specifying the number of columns. The initial value is 1.
"UNREGISTERED::James Clark//Characteristic::page-column-sep"
  Value is a length, specifying the separation between columns. The initial value is .5in.
"UNREGISTERED::James Clark//Characteristic::page-balance-columns?"
  Value is a boolean. If true, the columns on the final page of the page-sequence should be balanced. The initial value is #f.

Here's how to enable the above extensions:
(define if-first-page (external-procedure
"UNREGISTERED::James Clark//Procedure::if-first-page"))
(define if-front-page (external-procedure
"UNREGISTERED::James Clark//Procedure::if-front-page"))
(declare-characteristic page-n-columns
"UNREGISTERED::James Clark//Characteristic::page-n-columns" 1)
(declare-characteristic page-n-columns
"UNREGISTERED::James Clark//Characteristic::page-column-gap" (* 36 1pt))
(declare-characteristic page-balance-columns?
"UNREGISTERED::James Clark//Characteristic::page-balance-columns?" #f)

Back to top

table
Inherited characteristics | Non-inherited characteristics

- table-border
- display-alignment
- start-indent
- end-indent

- table-width
- before-row-border
- after-row-border
- before-column-border
- after-column-border
- span (spans all columns if > 1)
- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?

Back to top

table-part
Inherited characteristics | Non-inherited characteristics

- space-before
- space-after
- keep-with-previous?
- keep-with-next?
- break-before (#f, page)
- break-after (#f, page)
- keep (#f, page)
- may-violate-keep-before?
- may-violate-keep-after?

- header
- footer

Back to top

table-column
Inherited characteristics | Non-inherited characteristics

- start-indent
- end-indent

- column-number
- n-columns-spanned
- width

- (table-unit k)

Back to top

table-cell
Inherited characteristics | Non-inherited characteristics

- cell-before-row-margin
- cell-after-row-margin
- cell-before-column-margin
- cell-after-column-margin
- cell-row-alignment
- cell-before-row-border
- cell-after-row-border
- cell-before-column-border
- cell-after-column-border
- cell-background?
- background-color

- column-number
- n-columns-spanned
- n-rows-spanned
- starts-row?
- ends-row?

Back to top

table-border
Inherited characteristics | Non-inherited characteristics

- border-present?
- line-thickness
- line-repeat (0, 1, or 2)
- line-sep
- color

Back to top

Many DSSSL characteristics cannot be implemented in RTF. The backend does the best it can.

In order to get correct page numbers in Microsoft Word, type the following after opening the document:

1. CTRL+END
2. CTRL+A
3. F9

In Word Viewer 97, you must instead do:

1. CTRL+END
2. ALT
3. V
4. N
5. ALT
6. V
7. P

Page numbers also get updated automatically when you print.

We also ship a perl script `contrib/rtf2doc` for this purpose.

The RTF backend supports some additional characteristics. To use a characteristic named here as `C`, declare it using `declare-characteristic` with the public identifier:

    "UNREGISTERED::James Clark//Characteristic::C"

`heading-level`
  Value is an integer. It applies to paragraph flow objects. If the value is between 1 and 9, then the paragraph is output as a header of this level, otherwise it is output as body text. Using this characteristic allows Word to provide useful outline views and a document map. (Note that Word's handling of document maps for RTF documents is buggy: if you load an RTF document, and the previous document was using the Online Layout view, then RTF will attempt to guess what paragraphs are headings, which it will almost always do wrong. To avoid this, switch to the Normal view before loading an RTF document.) The initial value is `0`
`page-number-format`
  Value is a string as for format-number procedure. This controls the format of the number used by page-number-sosofo and current-page-number-sosofo for references to pages in the simple-page-sequence. The initial value is `"1"`. It applies to simple-page-sequence flow objects.
`page-number-restart?`
  Value is a boolean. If true, then for the purposes of page-number-sosofo and current-page-number-sosofo, the page numbers for this simple-page-sequence will restart from 1. The initial value is `#f`. It applies to simple-page-sequence flow objects.
`page-n-columns`
  Value is a strictly positive integer, specifying the number of columns. The initial value is 1. It applies to simple-page-sequence flow objects.
`page-column-sep`
  Value is a length, specifying the separation between columns. The initial value is `.5in`. It applies to simple-page-sequence flow objects.
`page-balance-columns?`
  Value is a boolean. If true, the columns on the final page of the page-sequence should be balanced. The initial value is `#f`. It applies to simple-page-sequence flow objects.
`superscript-height`
  Value is a length. Specifies the height of the baseline of a superscript above its parent's baseline. It applies to superscript and script flow objects.
`subscript-depth`
  Value is a length. Specifies the depth of the baseline of a subscript below its parent's baseline. It applies to subscript and script flow objects.
`over-mark-height`
  Value is a length. Specifies the height of the baseline of the contents of the over-mark area of a mark flow object above the baseline of the contents of the main area. It also controls the height of the contents of the mid-sup area of the script flow object. It applies to mark and script flow objects.
`under-mark-depth`
  Value is a length. Specifies the depth of the baseline of the contents of the under-mark area of a mark flow object below the baseline of the contents of the main area. It also controls the depth of the contents of the mid-sub area of the script flow object. It applies to mark and script flow objects.
`grid-row-sep`
  Value is a length. Specifies the separation between rows of a grid flow object.
`grid-column-sep`
  Value is a length. Specifies the separation between columns of a grid flow object.