GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureOfficeTemplater Class / LoadFromStream(Stream) Method
The DOCX template file stream containing the template data.
Example





In This Topic
LoadFromStream(Stream) Method
In This Topic
Loads a DOCX template file stream containing the placeholders that need replacing.
Syntax
'Declaration
 
Public Function LoadFromStream( _
   ByVal sourceStream As Stream _
) As GdPictureStatus
public GdPictureStatus LoadFromStream( 
   Stream sourceStream
)
public function LoadFromStream( 
    sourceStream: Stream
): GdPictureStatus; 
public function LoadFromStream( 
   sourceStream : Stream
) : GdPictureStatus;
public: GdPictureStatus LoadFromStream( 
   Stream* sourceStream
) 
public:
GdPictureStatus LoadFromStream( 
   Stream^ sourceStream
) 

Parameters

sourceStream
The DOCX template file stream containing the template data.

Return Value

The GdPictureStatus of the operation.
Example
Load input template file from stream
using GdPicture14;
            
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)
{
    var fileStream = new FileStream("input.docx", FileMode.Open, FileAccess.Read);
    status = templater.LoadFromStream(fileStream);
    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