code: private RtfHeaderFooterGroup convertHeaderFooter(HeaderFooter hf, int type) {
          if(hf != null) {
              if(hf instanceof RtfHeaderFooterGroup) {
                  return new RtfHeaderFooterGroup(this.document, (RtfHeaderFooterGroup) hf, type);
              } else if(hf instanceof RtfHeaderFooter) {
                  return new RtfHeaderFooterGroup(this.document, (RtfHeaderFooter) hf, type);
              } else {
                  return new RtfHeaderFooterGroup(this.document, hf, type);
              }
          } else {
              return new RtfHeaderFooterGroup(this.document, type);
          }
      }
docs: Converts a HeaderFooter into a RtfHeaderFooterGroup. Depending on which class
  the HeaderFooter is, the correct RtfHeaderFooterGroup is created.
  
  @param hf The HeaderFooter to convert.
  @param type Whether the conversion is being done on a footer or header
  @return The converted RtfHeaderFooterGroup.
  @see com.lowagie.text.rtf.headerfooter.RtfHeaderFooter
  @see com.lowagie.text.rtf.headerfooter.RtfHeaderFooterGroup