Git Product home page Git Product logo

docx_mailmerge's Introduction

pub package Build codecov License: MIT

Performs a mail merge operation on DOCX files. There are no platform dependant external dependencies which allows this package to run anywhere. Mail merge can even run in the browser!

Features

  • Merge values with merge fields within a DOCX document
  • Get merge fields a document contains
  • Evergy merge works on a fresh copy of the document
    • Enables batch merging
  • Enable or disable proofreading on merged fields
    • Proofreading is disabled on merged fields by default to better match behavior seen in Word
  • Enable or disable the removal of merge fields that do not have a corresponding key/value to merge with

Getting started

This package reads files as bytes through the data structure of a List<int>. For web, this project has an example in the /example/web folder for your use (JS compiled separately)

Usage

To setup a document to be merged with, pass a List<int> of the file to the DocxMailMerge constructor.

DocxMailMerge(File('test/files/original1.docx').readAsBytesSync())

There is also a named constructor which will unzip and read the merge fields immediately rather than on demand.

DocxMailMerge.preprocess(File('test/files/original1.docx').readAsBytesSync())

The mergeFieldNames getter will return a Set<String> for the merge fields that exist in a document.

DocxMailMerge(File('test/files/original1.docx').readAsBytesSync()).mergeFieldNames

The merge operation takes a Map<String, String> for the key/values to be merged. There are also optional parameters which are documented in the code. The merge operation returns a List<int> which is the new file with the merged fields. Every merge operation reuses the original file and runs a merge on it allowing for repeat merge operations to be run on a single DocxMailMerge object without needing to create more.

DocxMailMerge(File('test/files/original1.docx').readAsBytesSync()).merge({'First_Name': 'hello world'}, removeEmpty: false)

Messages are not outputted by this package unless verbose is set to true. This can be set through the static variable verbose

DocxMailMerge.verbose = true;

Additional information

This package comes from the issue of not having an easy cross-platform mailmerge package. This is inspired by the docx-mailmerge python package. The python package is more mature and may cover cases not yet addressed by this package, but this dart package does have an advantage. With the many different target platforms that dart can compile to, this package can be adopted easier into more ecosystems (Did i mention it can run in the browser?!).

docx_mailmerge's People

Contributors

wetbikeboy2500 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.