Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 2.5 out of 5     Rate this Document

When Using DocumentIt With Word How Do I Handle Linefeeds?

Primary Software: MATRIXx
Primary Software Version: 6.3
Primary Software Fixed Version: N/A
Secondary Software:

Problem: I am using DocumentIt to generate Microsoft Word documents. I am having trouble getting the right formatting for linefeeds. For example how do I avoid a linefeed after a command, using @@ doesn't seem to help. Also how can I have line feeds in the user parameters?

Solution: DocumentIt does not directly generate a Word document, rather it creates a RTF (Rich-Text File). Rich-Text Files are text files that contain the text of the document as well as formatting information. RTF files do not use a linefeed character to mark the beginning of a new line, instead it uses a \par. The following table illustrates how rich text interprets text.

Rich-Text SourceFinal Formatting
one
line
one line
two\parlinestwo
lines
two
\parline
two
lines

There fore when a @@ is used at the end of a line, then DocumentIt will remove the linefeed. However this has no effect on the final document, since the \par remains. DocumentIt offers an option to account for the rich-text use of \par. When using the DocumentIt dialog from SystemBuild Tools menu then place a check-mark in front of MS Word. From Xmath use the keyword msrtf and from the command line with autostar use -mswl. When this option is enabled then when a line ends in @@ and there is a \par at the beginning of the next line then it will be ignored. Regardless of whether or not the option is enabled or not, the linefeed following the @@ will be removed. The @@ must always be at the end of a line. This is illustrated in the attached template files. For more information see Appendix A of the DocumentIt User's Guide.

Another option is to do a search and replace in the final document. Before using the template with DocumentIt, do a search and replace in Word. Search for @@^p and replace it with @. The ^p can be accessed by selecting more in the Word Search and Replace dialog, then selecting paragraph mark from the special characters list. The resulting document will not be as readable as the original, but will produce a correctly formatted final document. This way you do not need to remember to enable the MS Word option when generating a document.

When using user parameters the same idea applies. If a user parameter contains a linefeed, it will be present in the final file, but will not be interpreted correctly. To see a line feed in the final document add \par to mark the beginning of a new line in the user parameter.

Related Links: KnowledgeBase: Why Do I Get Compile Errors After Editing mswgp.wrd in Word 2002?

Attachments:


linefeed.tpllinefeed.wrd



Report Date: 02/09/2004
Last Updated: 02/13/2004
Document ID: 3687C5OH

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit