using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
string json = @"
{
'config': {
'delimiter': {
'start': '{{',
'end': '}}'
}
},
'model': {
'placeholder1': 'replacementValue 1',
'placeholder2': 'replacementValue 2'
}
}";
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(json);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);