Skip to content

StasClick/DocumentGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Single leaflet

Prepare .docx for leaflets

Add text fields to your document: DEVELOPER -> Controls -> Rich Text Content Control. Set control's tag value to name you will use later.

Coding:

  1. Create 'DocxGenerator':
var docx = new DocxGenerator(@"C:\Temp\MyTestTemplates\Hello Tag 1.docx");
  1. Create 'Leaflet':
Leaflet leaflet = new Leaflet();
docx.AddLeaflet(leaflet);
  1. Fill tags:
leaflet.AddGlobal("tag name", "value");
  1. Save document:
docx.Generate(@"C:\Temp\MyTestTemplates\outFile");

Multiple leaflets

Do the same as for single leaflet, but create and add Leaflet several times. Example:

var docx = new DocxGenerator(@"C:\Temp\MyTestTemplates\Hello Tag 1.docx");

foreach (var leafletData in <>)
{
  Leaflet leaflet = new Leaflet();
  leaflet.AddGlobal("Tag 1", "Henny");
  docx.AddLeaflet(leaflet);
}

docx.Generate(@"C:\Temp\MyTestTemplates\outFile");

Registry

Prepare .docx for leaflets

  1. Add table, add same tags to it.
  2. Select line you are going to repeat for registry.
  3. With line selected, click: DEVELOPER -> Controls -> Repeating Section Content Control.
  4. Set tag value, for example 'MyList'.

Coding:

  1. Create 'DocxGenerator':
var docx = new DocxGenerator(@"C:\Temp\MyTestTemplates\Hello Tag 1.docx");
  1. Create 'Leaflet':
Leaflet leaflet = new Leaflet();
docx.AddLeaflet(leaflet);
  1. Fill tags for whole document:
leaflet.AddGlobal("tag name", "value");
  1. Add row, where it is tagged as 'MyList':
leaflet.AddLine("MyList",
		new KeyValuePair("Item1", (i + 1).ToString()),
		new KeyValuePair("Item2", "Value 2"),
		new KeyValuePair("Item3", "Value 3"),
		new KeyValuePair("Item4", "Hello Registry!")
		);
  1. Save document:
docx.Generate(@"C:\Temp\MyTestTemplates\outFile");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages