rtf 0.0.1 copy "rtf: ^0.0.1" to clipboard
rtf: ^0.0.1 copied to clipboard

A library to build an rtf document

A minimal Rtf creation library for dart/flutter

Features #

The library can create RTF file

Installing #

In order to use this rtf library, follow the steps above:

  1. Add this package to your package's pubspec.yaml file as described on the installation tab
  2. Import the library

  import 'package:rtf/rtf.dart' as rtf;

Examples #

Create a document (use Times New Roman as font)


    var el = [
      rtf.Text('Test text', style: rtf.TextStyle(style: 'heading 1', align: rtf.Align.right)),
      rtf.NewLine(),
      rtf.Text('Second test text', style: rtf.TextStyle(style: 'Normal')),
      rtf.NewLine(),
      rtf.SkipPage(),
      rtf.Text('Third test text'),
    ];
    rtf.Document doc = rtf.Document(el);
    doc.addFont('Normal', 'roman', 'Times New Roman', rtf.FontStyle.regular, 9);
    doc.addFont('heading 1', 'roman', 'Times New Roman', rtf.FontStyle.bold, 14);
    doc.addFont('heading 2', 'roman', 'Times New Roman', rtf.FontStyle.bold, 12);
    doc.setHf(rtf.HF.hdLeft, rtf.PageNo());
    doc.setHf(rtf.HF.hdCenter, rtf.Image(await PlatformAssetBundle().load("assets/image.png")));
    await doc.save(File('result.rtf'));

Create a document with a table:


    List<List<rtf.Widget>> c = List.generate(3, (index) => List.generate(2, (c) => rtf.Text('Cell$index$c')));
    c.first.first = rtf.Column(children: [rtf.Text('1'), rtf.Text('alfa')]);
    var el = [
      rtf.Table(
          [
            rtf.Text('First column', style: rtf.TextStyle(style: 'heading 2', align: rtf.Align.center)),
            rtf.Text('Second column', style: rtf.TextStyle(style: 'heading 2', align: rtf.Align.center)),
          ],
          c,
          colWidths: [100, 200],
          headerShade: rtf.Shade.dark,
          pairShade: rtf.Shade.normal,
          oddShade: rtf.Shade.light,
          height: 20,
          valign: rtf.VAlign.bottom,
          left: rtf.TableBorder.standard(),
          right: rtf.TableBorder.standard(),
          top: rtf.TableBorder.standard(),
          bottom: rtf.TableBorder.standard(),
          horizontalInside: rtf.TableBorder(dash: true, color: rtf.Color.black))
    ];
    rtf.Document doc = rtf.Document(el);
    doc.addFont('Normal', 'swiss', 'Arial', rtf.FontStyle.regular, 9);
    doc.addFont('heading 1', 'swiss', 'Arial', rtf.FontStyle.bold, 14);
    doc.addFont('heading 2', 'swiss', 'Arial', rtf.FontStyle.bold, 12);
    await doc.save(File('result.rtf'));

1
likes
0
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

A library to build an rtf document

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on rtf