
Creating Templates
==================

 In whatever editor you are using (KWord, AbiWord, MS-Word, emacs, vi, blah,
 blah, blah), insert the string "::FieldName::" wherever a field should be
 merged at.  For example, 

   Dear ::FirstName::, 

   Thank you for your inquiry regarding ::Product::. 

::FirstName:: and ::Product:: are considered the "merge" fields. They will 
be replaced by the merge-* files with actual data.  


Merge Commands
==============

merge-latex
-----------

To test the LaTex merge, type:  

  $ ./merge-latex gnue-intro-letter.abiword.latex < records.xml > sample.tex  

This runs merge-latex using the AbiWord "Save As Latex" document 
gnue-intro-letter.abiword.latex.  The XML file "records.xml" is used
as the input stream.  This create a LaTex output file called sample.tex. 
If all goes well, you should be able to run sample.tex with the latex 
command or open sample.tex with any LaTex importer (e.g., AbiWord & KWord) 

How it works: 
The merge-latex searches for a \begin{document} and \end{document} pair. 
Everything in between is treated as a repeatable section. If multiple
records exist in the mailmerge, then this repeatable section has a
\newpage added between each instance. 

For converters between LaTex and document formats, see the FAQ at: 
   http://tug.org/utilities/texconv/

This works with LaTex files created with the "Save As" (LaTex format) 
commands of AbiWord and KWord. Your mileage may vary. 

NOTE: This script works using a simple Regular Expression... IT DOES NOT
  ACTUALLY PARSE THE LaTeX FORMAT!  As such, there are bound to be examples
  where this script does not work.


merge-rtf
---------

To test the RTF merge, type:

  $ ./merge-rtf gnue-intro-letter.abiword.rtf < records.xml > sample.rtf

This runs merge-latex using the AbiWord "Save As RTF" document
gnue-intro-letter.abiword.rtf.  The XML file "records.xml" is used
as the input stream.  This create a LaTex output file called sample.tex.
If all goes well, you should be able to run sample.tex with the latex
command or open sample.tex with any LaTex importer (e.g., AbiWord & KWord)

How it works:
The merge-rtf searches for the first \pard{ and treats it as the beginning.
Everything afterwards is treated as a repeatable section. If multiple
records exist in the mailmerge, then this repeatable section has a \Page
added between each instance.

This works with RTF files created with the "Save As" (RTF format)
commands of AbiWord and KWord. Your mileage may vary.

NOTE: This script works using a simple Regular Expression... IT DOES NOT
  ACTUALLY PARSE THE RTF FORMAT!  As such, there are bound to be examples
  where this script does not work.   

