docx_mailmerge 1.0.3 docx_mailmerge: ^1.0.3 copied to clipboard
Package for performing a mailmerge operation on merge fields within a DOCX document
example/docx_mailmerge_example.dart
import 'dart:io';
import 'package:docx_mailmerge/docx_mailmerge.dart';
void main() {
//Read a docx file as bytes and pass it to the constrcutor
final merge = DocxMailMerge(File('test/files/original1.docx').readAsBytesSync());
//This is just to ensure the output directory exists
Directory('test/tmp').createSync();
//Writes the generated merge infomation(bytes) to the output file
File('test/tmp/example.docx').writeAsBytesSync(merge.merge({'First_Name': 'hello world'}, removeEmpty: false));
}