rtf 0.0.2
rtf: ^0.0.2 copied to clipboard
A library to build an RTF document. RTF (Rich Text Format) is a document format that most word processors are able to read and write. This first library release implements a subset of the RTF features.
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:
- Add this package to your package's pubspec.yaml file as described on the installation tab
- 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'));
See example directory