User guide - Model creation - Samples

Model creation samples

rtftemplate-usecases-<version> distribution give samples which implements net.sourceforge.rtf.usecases.AbstractRTFUseCase.

Manage fields and loop

net.sourceforge.rtf.usecases.jakartavelocityproject package have samples which use RTFTemplate to manage context with simple object and collection of object in RTF model.

RTF Table

net.sourceforge.rtf.usecases.page package have samples which use RTFTemplate to manage RTF table.

Manage images

net.sourceforge.rtf.usecases.image package have samples which use RTFTemplate to manage images.

To insert image in your RTF model, you must define a getter which returns the stream of your image. The getter must return java.io.InpuStream in order to RTFTemplate interprate the filed as image. This stream is transformed into RTF code. To insert image in your RTF model, use merge field which is linked with the getter which returns the image stream.

RTFTemplate support PNG, JPG, EMF et BPM image format.

Manage page break

net.sourceforge.rtf.usecases.page package have samples which use RTFTemplate to manage page break.

To insert page break in your RTF model, click here.

it's possible to group items of the list and generate a page break after each group. To manage that, call method setGroupByPerPageBreak like this :

public class RTFTemplatePageBeakWithGroupWithVelocity extends AbstractRTFUseCase {

  public static void main( String[] args ) throws Exception {
  
    RTFTemplatePageBeakWithGroupWithVelocity usecase = ...
    ...
    usecase.setGroupByPerPageBreak(3);    
    usecase.run(rtfSource);
  }
  

Map Context

net.sourceforge.rtf.usecases.map package have samples with RTFTemplate to use java.util.Map as context in order to avoiding create JAVA POJO Object.