Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden RepeatContent inside TableContent generates malformed document #54

Open
zii-dmg opened this issue Jul 25, 2018 · 0 comments
Open

Comments

@zii-dmg
Copy link

zii-dmg commented Jul 25, 2018

Word error message when opening (in russian):
worderror

Template: HiddenRepeatReproTemplate.docx

Repro:

using System;
using System.IO;
using TemplateEngine.Docx;

namespace HiddenRepeatRepro
{
	static class Program
	{
		static void Main(string[] args)
		{
			string templateFile = "HiddenRepeatReproTemplate.docx";
			string outputFile = "HiddenRepeatRepro.docx";

			File.Delete(outputFile);
			File.Copy(templateFile, outputFile);

			var repeat = new RepeatContent("repeat1")
				.AddItem(new FieldContent("val", "123"))
				.AddItem(new FieldContent("val", "456"));

			repeat.Hide(); // breaks document

			var table = new TableContent("table1")
				.AddRow(repeat);

			var content = new Content(table);

			using (var template = new TemplateProcessor(outputFile).SetRemoveContentControls(true))
			{
				template.FillContent(content);
				template.SaveChanges();
			}
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant