RTF breaks down into four basic categories: commands, escapes, groups, and plaintext. An RTF parser knows that a command has ended when it sees a character that no longer matches that pattern. The character after the backslash is not a letter. But most groups have a more concrete purpose: to act as a barrier to the effects of character formatting commands. The final bit of RTF syntax is plaintext : the text that is sent right through to the document, character for character.
For example, when we had Hello, World! So, for example, in the PostScript graphics language, the code newpath 0 arc fill draws a black half-circle in about the middle of the page. You could write that code compactly on one line:.
However, RTF is not that kind of language. In RTF, the rules for dealing with whitespace are very different:. Otherwise, every space character means to insert a space character! In all other cases, a space in the source means a space in the document. For example:. Here, there are five spaces after the comma, and they really do insert five spaces into the document.
This may seem a very strange way for a markup language to go about doing things. It was never meant to be something that people would find easy and intuitive for typing. Nor is machine-generated RTF typically easy for people to read.
However, when you write RTF-generating programs, try to produce easy-to-read source, since it makes programs easier to debug. Your programs should insert a newline for two reasons: first, in order to make logical divisions in the RTF source; second, to avoid lines that are overly long like over characters , which become unwieldy to look at in many editors, and occasionally cause trouble when transferred through email.
Here are some rules of thumb for putting linebreaks in RTF:. Put a newline before and after the RTF font-table, stylesheet, and other similar constructs like the optional color table, described later.
For example, consider this document of 2 plain paragraphs in 12pt Times:. Formatted, they look like Figure For example, what we would call a heading is implemented in RTF as just a generally short paragraph with generally large type.
There are several kinds of paragraph-formatting commands, and we will go through them in groups. Luckily, command-pairs like that are relatively rare in RTF. The first commands we will cover are ones that tell the word processor how to justify the lines on in the current paragraph—namely, whether to make the lines flush on the left margin, or the right, or both, or whether to center each line.
Full-justify this paragraph try to make both sides smooth. Center this paragraph. This is generally used only for headings, not normal paragraphs. The following RTF code is an example that demonstrates centering, full justification, and left-justification. It is shown formatted in Figure Instead, the space is measured in twips , a unit that RTF uses for almost everything. A twip is a 1,th of an inch, or about a 57th of a millimeter. The name twip comes from a twentieth of a point a point is a typesetting unit here defined as a 72nd of an inch.
Points are rarely used except for expressing the size of a font. To help you measure distances in twips, the section Converting to Twips in Chapter 4 shows conversions between twips and inches and centimeters. Also, see the twips ruler inside the back cover of this book.
Add N twips of vertical space before this paragraph. By default, this is 0. Add N twips of vertical space after this paragraph. There are three paragraph-formatting commands that control indenting , in various ways:. Indent the first line of this paragraph by N twips. This command and the following command control block indenting , i. Bear in mind that the left and right margin do not mean the left and right edge of the page; typically, the margins are an inch in from the edge of the page.
For more about changing the margins, see the Page Margins section later. There are seven commands that control how the pagebreaking and linebreaking settings interact with paragraphs:. Try to avoid a pagebreak between this paragraph and the next—i. This command is often used on headings, to keep them together with the following text paragraph.
Turn on widow-and-orphans control for this paragraph. This is a feature that tries to avoid breaking a paragraph between its first and second lines, or between its second-to-last and last lines, since breaking in either place looks awkward. Turn off widow-and-orphans control for this paragraph. This turns on automatic hyphenation for this paragraph. This command turns off automatic hyphenation for this paragraph. Figure shows the result. To have just 1. For example, in WordPerfect, the internal code for line-spacing can be set anywhere in any paragraph—it takes effect starting on that line, and can last for the rest of the document.
Why does RTF do it that way? Paragraphs are usually placed below the previous one and against the left margin. However, in some cases, such as when printing labels, you need to print text at a specific spot on the page.
The paragraph will be 4, twips wide:. Normally, the paragraph and any border around it extends just as far down as the paragraph needs in order to show all its lines. If you have borders on this paragraph, any added space will be between the bottom of the paragraph and the bottom border instead of just being under the bottom border.
For example, the following paragraph will be inside a box created by the border lines 5, twips high:. If the current font and point size makes the text take up only a part of the space in that box, then there is just blank space left at the bottom. But if the text is too large to fit in that box, the extra text is hidden.
We will also see a very similar construct for table cell borders in the Preliminaries section of this book. It comes out looking like Figure It makes no difference to the word processor interpreting the RTF. When you have character-formatting commands at the start of the document i.
When you have a series of formatting commands that apply to the same bit of text—i. Either way is absolutely valid RTF. A nonbreaking space is a character that looks like a space. Whereas the word processor can break lines at a space character, it will never do so at a nonbreaking space character.
This avoids confusion in the case of hyphens occurring in email addresses, URLs, and other kinds of computerese. That is, if you were reading a discussion of Lisp functions, and saw the following:. If hyphenation is turned on for the document, the word processor will try to make the text wrap nicely by hyphenating words. This is discussed in greater detail in the Document Structure section. Unicode characters are characters over , usually in the range to 65, For example, the Chinese character is character 36,, and the character is character 21, If the character is between 32, and 65,, subtract 65, from it, and use the resulting negative number.
For example, the symbol is character , About the best we can do in such cases is to try to find a font that has that character at some lower character number. Or, in complete desperation, you could embed an image of the character; see the section Embedding Images. For example, the first five characters of the Tao Te Ching are these:. While the above rules hold for normal printable characters, there are four exceptions worth noting: the ASCII newline character, the ASCII form-feed character, the Latin-1 nonbreaking space, and the Latin-1 soft hyphen.
Although the specification for expressing Unicode in RTF is over five years old, support for RTF in different applications is still somewhat hit-or-miss.
The result looks like Figure MSWord tries to do that kind of helpful substitution, but it does not do it reliably. Oddly, WordPad write. In any case, in order to use a Unicode character, try to use a font that provides the character. Otherwise, you run the risk of the document coming out looking like Figure There are exceptions, however. An RTF document consists of a prolog , a font table , an optional color table , an optional stylesheet , an optional info group , preliminaries , content i.
The 1 indicates the version of RTF being used. Currently, 1 is the only version there has ever been. The way to declare a character set is with one of these commands:. This is basically Latin-1 ISO with some characters added between and In theory, this is the default for RTF. The document is in the MacAscii character set, the usual character set under old pre versions of Mac OS.
That is about the only use that CP sees these days. The bad news is that you may be using codes outside that range without noticing it, such as smart quotes, long dashes, or the like. What font the number N actually indicates is defined in the font table that follows. For example, this is a very common prolog, which declares the RTF document to be in the ANSI character set, and picks font 0 as the default font:.
A font table lists all the fonts that can be used in this document and associates a number with each one. The font table is required, although some programs will tolerate a file that has no font table. The RTF specification suggests that the declaration is syntactically needed, but hardly any word processors actually require it; for sake of brevity, almost all the examples in this book leave out the declaration.
The color table is where you define all the colors that might be used in this document. Each declaration has this basic syntax:. This convention is used for the first entry in the color table. This example color table declares entry 0 with the default text color, entry 1 as red, entry 2 as blue, entry 3 as white, and entry 4a as black:. See the Changing Text Color section for a further discussion of color commands.
In hardcopy, there is no difference, because the default color for print is black. But on screen, the default color can be anything. For example, suppose MSWindows is running and the Display Properties: Appearance control panel is set to make the default window style appear as white text on a dark blue background. And given that the background color is dark blue, that black text will be quite hard to read—unless, of course, the RTF document also specifies a different background color such as yellow , in which case, the text will display more readably, as black on yellow.
A stylesheet is where you declare any styles that you might use in the document. A stylesheet is optional. The semantics and usage of stylesheets is discussed in detail later in the Styles section, so we will focus just on the syntax here.
A paragraph style definition has this syntax:. Avoid using commas or semicolons in the style name. The formatting commands here should be just character-formatting commands, without any paragraph-formatting commands.
See the Styles section for more details. Till date, Microsoft maintains the Rich Text format. However, in a strange thing, you can see that if you save texts in Word and later versions in RTF formats, the file may not save correctly. You will find the text file looks nothing like the one you were editing and went on to save. This is because Microsoft stopped supporting RTF over the years. However, the company did slightly come around when it said that it would provide minor modifications to Rich text format files and ensure they worked properly.
You had multiple machines using it, for encoding computer languages and software programs. Now that we have a fair idea as to what a Rich Text Format, we need to know how relevant it is in the present age of digital publishing. After all, we are at a time where new formats come out every day.
Therefore, do we still need RTF to work for us? For answering this thought, we will have to take a small look back at its capacities.
Rich Text Format RTF is a file format that lets you exchange text files between different word processors in different operating systems. In some cases, the RTF capability may be built into the word processor. In others, a separate reader or writer may be required. When you take up reading a Rich text format file, you can process the control works and symbols by the RTF reader. The reader converts the RTF language into formatting for the word processor which will then the document.
A specification of the copy of archives located in World web consortium brings out tools to create RTF readers and also writers. Although many eBook users have now moved to better eBook formats like ePub , Mobi , and CBR , we still have some things which only a Rich text format allows you to do. Some specific needs which RTF files cater to. You can still use this format for the following reasons.
With Rich text format file, you get the ability to read the file in any reader possible. You do not have to worry about the platform, system or word processor you have with you. This is a great feature when you look at the way how new formats work. At present what you can read in eBook readers like Sigil, Amazon Kindle or Moon reader, is something you cannot read in any other. Of course, there are eBook conversion tools like Calibre or Scrivener , but nothing comes close to the way an RTF behaves.
To this day, Rich text format remains the most compatible file format in the last decade. As a result, most of the viruses may be carried by Word Doc files. This security against the risk of virus infection applies regardless of whether your document would be conveyed via diskette, e-mail attachment, or as an archived web file.
When your projects have only the text and not any high-end graphics, clip arts or anything, you can find that saving in RTF format will save you a greater space. Again, you have just the text materials within. We mean that complicated eBook or eText formats may not be a great option to put in within Rich Text format.
This allows you to upload, save, transfer, and send files with much ease, as the files will be in text format. This can be a considerable level of advantage to transfer via limited net speeds. E-mail transmission times would be quicker, and one would have greater disk storage capacity due to the smaller file sizes. Conversely, if your document contains graphics, audio files, media files, etc.
This process would involve a considerable amount of coding instruction. Which in turn makes the whole file more in size and difficult to process. Hence, Rich text format is adaptable and offers many options for saving text content. With RTF format, you have multiple options to save text and also other inputs in customization formats. However, with different readers available in the market, it becomes difficult to cater to just one.
Of course, most of the readers support the rich text format, but sometimes the size becomes an issue. For example, if you have high-end graphics, or you are dealing with enhanced eBooks , you will have to save RTF as a larger size.
Hence, you may have to convert RTF to other formats. This section describes the code inserted by the pivot table builder. When the Template Builder inserts the pivot table, it inserts a BI Publisher command of the following structure:.
Table Pivot Table Command Parameters. This is the XML data element that contains the data elements to include in the pivot table. If the pivot table is inside a repeating group, this field must be manually edited to achieve the expected results.
See the table following this section. This parameter defines the XML elements for row headers. The first attribute is the sort element. If not specified, the row header element is used as the sort element. Note that the sort element can be any element in the data set, and does not have to be included in the pivot table. In the preceding example, emp-lastname and emp-firstname do not have to be elements included in the pivot table.
This parameter defines the XML elements for column headers. If not specified, the column header element is used as the sort element. In the example, the first column header is "ProductsBrand".
It is sorted by "ProductsBrand"; the order is ascending, and type is text. The second column header is "PeriodYear". It is sorted by "PeriodYear"; the order is ascending, and type is text. The full data set includes four values for ProductsBrand, four values for Region, and two values for PeriodYear to be displayed in the pivot table. Each XPath in the "cttree. The information in the table is to help you understand how BI Publisher constructs the pivot table.
The generated cttree. The first level column "ProductsBrand". There are four distinct values. They are shown in the label H element. The column header label. The first level column "PeriodYear", which is the second group-by key. There are two distinct values "" and "". The first level row "Region". There are four distinct values, they are shown in the label H element.
This is the row header label for "Region". This contains elements from combining R1 and C1. There are 4 distinct values for "Region", and four distinct values for "ProductsBrand". This contains elements from combining R1, C1 and C2.
There are 4 distinct values for "Region", and four distinct values for "ProductsBrand", and two distinct values of "PeriodYear". This contains elements from combining R1 "Region" and R2 "District". Because the list of values in R2 has dependency on R1, the number of entries is not just a simple multiplication.
The R2 position number within R1. This is used to check if it is the last row, and draw table border accordingly. This contains elements from combining R1, R2, C1 and C2, which gives the finest level of details.
When you create a pivot table inside a repeating group you must manually edit the pivot table code so that the elements included in the pivot table respect the grouping context. The edit to the code depends on how you grouped the data. In the crosstab command, update the "data-element" component to "current-group ". Select and right-click the inserted pivot table. Replace the data-element component with "current-group ". This applies the XDO crosstab command only across the current group to return the expected values in the pivot table.
Procedure When the Data is Already Grouped. If the data input to the Template Builder is already grouped, then you must insert the appropriate XPath for the data-element component to ensure that the pivot table only includes the elements in the current group.
When you insert the pivot table within the repeating group, the code appears as. The edited code is:. A conditional region is an area that is surrounded by a conditional statement. If the statement tests true, the area is displayed in the report; if the condition tests false, the area is suppressed from the report. For example, the data contains sales information. The report contains a table that displays sales by industry.
You want this table in the report to display information for industries with sales amounts lower than , Using the insert conditional region functionality, you can select the region that contains the sales table and insert the condition that the sales element must be less than , Select the region that you want to apply the condition to.
For example, if you want to display a table only for a certain condition, then select the region that contains the table. Note that the region must be inside a loop. Data Field - Select the field to test for the condition. Select the value to meet the condition.
Note that you can enter an integer, enter text, or select another data element to define a comparison based on the incoming values. Click OK. The form fields that contain the conditional logic are inserted around the region. The beginning form field displays the text "C" and the form field closing the region displays the text "EC".
To edit the conditional region, double-click the inserted form field to launch the dialog for editing; or, right-click the form field and select BI Publisher , then Properties. Using the Conditional Format feature you can insert simple conditional formats to apply to table rows or cells. The dialog provides several common options that you can select and the Template Builder inserts the code automatically. The Conditional Format dialog supports two conditions per field.
The Conditional Format dialog cannot be used inside of pivot tables. You must insert the conditional formatting logic directly to the appropriate form fields. Place the cursor in the table cell of the data element for which you want to define the condition. Apply to Entire Table Row - If you want the format applied to the entire table row, not just the cell of the selected element, then select this box.
You can enter an integer, enter text, or select another data element to define a comparison based on the incoming values. Click Format to define the format you want to apply when the condition is met. Options are background color, font color, and font style regular, bold, italic, bold italic. Select the box and format of each option you want to apply. After you select the format, the Preview region displays the format chosen. The conditional format field is inserted as a form field with the display text "C".
To edit the conditional format, double-click the inserted form field to launch the dialog for editing; or, right-click the form field and select BI Publisher , then Properties. If you have not already done so, then you must load sample data to the Template Builder to preview the report. From the Preview group, select the output format. If you have not yet saved the template as an RTF file, then you are prompted to do so.
You must have Adobe Acrobat Reader version 5. To use this option, you must have Microsoft Excel or later. If you have Excel , this option generates the document in. Embedded images such as charts and logos are not supported in this output type. If you do not have Microsoft Excel or later, use this option.
This section describes additional tools provided with the Template Builder to help you validate and edit the template. This section includes:. Once you have inserted a data field see Section 5.
To invoke the BI Publisher Properties dialog, perform one of the following:. Some fields might display only the Advanced tab. Data Field - Select the data field from the list of available fields from the loaded data source. Text to Display - Enter the display text for the form field in the template. This text is replaced at runtime by the value in the data. Type - Select the type of data. The selection in this field determines the format options. Format - For any data type except Regular Text, you can select from several number or date display formatting masks or enter your own.
Force LTR - Force Left-to-Right Use this check box when you are publishing the template in a language that prints the characters from right to left, such as Arabic or Hebrew. Function - This feature enables you to perform aggregation functions Sum, Average, Count, Minimum, Maximum on data fields. For example, if you select sum for a data field, then the field shows the sum of all occurring values for this data field depending on the scope see below.
See also Section 5. Scope informational only - This field has two possible values:. Group Item - Indicates that the data field is inside a group. If you choose to perform a function on the field, then only the occurrences of the field within the current group are included in the aggregation. Normal - Indicates that the field is not inside a group. Aggregation functions are performed on all occurrences of the field in the data. The Advanced tab displays the underlying code. If the code pattern within the form field is not recognized for example, because you added commands manually to the field , then the BI Publisher Properties dialog displays this tab only.
Use this tab to edit or add code to the form field manually. Click OK to update the template. Figure shows the Advanced tab. You can also use this dialog to set the data type and number format. The Template Builder provides a validation tool to check the template for incorrect use of BI Publisher commands and unsupported elements in the RTF file. If there are no validation errors, then a "No Error found" message is returned. If an error is found, then an error message is displayed.
You can use the Field Browser to help locate the error. The field browser dialog provides a fast way to review and update the BI Publisher instructions hidden in the Microsoft Word form fields. This dialog is particularly useful to understand and modify existing templates. Figure The Field Browser Dialog. The Field Browser dialog shows a table with the display text of the form field in the Text column and the underlying code instructions in the second Code column.
When you select a specific row in the dialog, the matching form field is selected in the Microsoft Word document. If you select some part of the text before opening the Field Browser, then the dialog shows only the fields in the selection. If no text is selected, then the field browser shows all fields in the document. Table Field Browser Options. You can update processing instructions directly from the Field Browser dialog.
Select a field in the Text table. The Edit box shows the processing instructions for the field. To change the instructions for the field modify the text in the Edit field and click Update. The Field Browser dialog is not aware of any form fields that you have added or modified while the dialog is open.
Click Refresh to show any changes to the document since the Field Browser dialog has been opened. If you opened the browser with a part of the document selected, then you see only the form fields in the selected area. Click Show All to see all the form fields in the document.
Click Close to close the field property browser. The only button does not automatically update any changes in the edit field, therefore ensure that you select Update if you want to save edits. The Template Builder provides an accessibility checker to check the template for features to enhance the accessibility of the report for report consumers who may need assistive technologies to view the report.
The tool generates a report that indicates areas of a template that do not include the following accessibility features:. In some cases the accessibility checker cannot determine if the accessibility feature is present and generates a warning.
The report designer can then verify that the accessibility features are present. For information on how to add these features to the template, see Appendix C, "Designing Accessible Reports. If you used the Open Template dialog to connect to BI Publisher, and load the data to the Template Builder, or if you downloaded an existing template from the BI Publisher catalog, then you can upload the new or updated layout back to the report definition on the server.
If you downloaded an existing template and want to upload the modifications to the template, then select Upload Template from the Oracle BI Publisher menu. If this is a new template for the report definition, then use the Upload Template As option to upload the layout to the report definition on the server.
Also use this option to upload modifications to an existing template under a different name. Use the first option if the translated template requires a different layout from the original template. To use the Template Builder translation tools to create templates for translations, see the following topics in this section:. This menu item allows you to create a standard XLIFF translation file that contains the boilerplate text from the template. XLIFF is a standard file format that is understood by many translation software packages.
A "translatable string" is any text in the template that is intended for display in the published report, such as table headers and field labels. Text supplied at runtime from the data is not translatable, nor is any text that you supply in the Microsoft Word form fields. You are prompted to save the extract file as an XML file type.
Enter a name for the extract file and save to the desired location. If you want to translate the template manually, open the. For a detailed description of working with the BI Publisher generated. When done, you can preview the translation. Then upload the file to the BI Publisher report definition. Locate the file, and click Open. Because BI Publisher enables you to extract the boilerplate text strings from a template into an XLIFF file that can be translated and then applied at runtime, if the reports for additional languages only require the translation of these text strings, then you only need to supply translated XLIFF files to accompany the base template.
However, you would localize a template when the requirements for the report in the specific language go beyond the simple translation of the text in the layout. This invokes a warning message that localizing the template overwrites the template.
Locate the appropriate file and click Open. Upload the template file to the appropriate report definition in the BI Publisher catalog. Select the appropriate locale in the upload dialog. Access the Options dialog as follows: In the Options group, click Options. Use the Options dialog: UI tab to set options that influence the look and feel of the Template Builder.
The tree view that shows the data source can show either the correct XML tag names of the data source or they can show a slightly modified version that is easier to read. The Options dialog: Preview tab allows you to specify options that influence the Preview functionality of the Template Builder. Table Preview Options. A style template is an RTF template that contains style information that can be applied to RTF layouts, similar to a style sheet.
The style information in the style template is applied to RTF layouts at runtime to achieve a consistent look and feel across your enterprise reports. You can choose the language and territory used for previewing the template. While this change does not automatically translate any files, it is important to set the correct locale for the preview to use the correct direction of the text left-to-right or right-to-left , and to correctly set locale-specific date, number, and currency formats.
The Preview and export functionality requires Java code. If this option is not specified, the Template Builder assumes that the Java virtual machine java. Specify the memory to reserve for the Template Builder to process the template. The default value is -XmxM.
Use the Options dialog: Build tab to specify options that influence how the Template Builder generates tables and forms. Table Build Tab Options. The Descriptive option for example: for-each Invoice renders a descriptive form field for the processing instructions.
This option makes the layout template easier to understand. However, the longer fields may distract from the visual layout of the template. Note that the descriptive option does not apply to fields within table cells. The Abbreviated option for example: F provides a one letter abbreviation for each instruction. Select the Hidden box to generate the processing instruction form fields using Microsoft Word's hidden font effect. Hidden text is hidden in the Print Preview and you may display or hide the hidden text by changing the Hidden Text setting in the Display group of the Microsoft Word Options.
Large - inserts the BI Publisher code to a document variable. The document variable field can accommodate approximately 48 kilobytes of code line. It is important to note that this setting affects only fields that are created or edited while this option is set.
If the template is intended for use with the 10g version of BI Publisher, use the Backward Compatibility setting. This limited the length of code that could be inserted for a single form field. By default, the Large option is used because it can accommodate much larger code strings. Customize the default color for the templates. This configuration is performed at the template level.
The template-level setting overrides the server setting. The configuration file must be named xdoconfig. Alternatively, you can use the file name xdo. The configuration file allows you to:. If you are using Microsoft Word , then you might have to modify the Add-In settings. The Online group of commands enable you to initiate interaction with the BI Publisher application. For more information about working with the online commands, see Section 5.
0コメント