GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureOfficeTemplater Class / LoadFromFile Method
The path to the DOCX file to load.
Example





In This Topic
LoadFromFile Method (GdPictureOfficeTemplater)
In This Topic
Loads a DOCX file containing the placeholders that need replacing.
Syntax
'Declaration
 
Public Function LoadFromFile( _
   ByVal sourceFile As String _
) As GdPictureStatus
public GdPictureStatus LoadFromFile( 
   string sourceFile
)
public function LoadFromFile( 
    sourceFile: String
): GdPictureStatus; 
public function LoadFromFile( 
   sourceFile : String
) : GdPictureStatus;
public: GdPictureStatus LoadFromFile( 
   string* sourceFile
) 
public:
GdPictureStatus LoadFromFile( 
   String^ sourceFile
) 

Parameters

sourceFile
The path to the DOCX file to load.

Return Value

The GdPictureStatus of the operation.
Example
Load input template file from file path
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);
See Also