1. Home
  2. /
  3. GroupDocs.Conversion.LowCode
  4. /
  5. Developer Guide
  6. /
  7. Loading Source Documents

Loading Source Documents

GroupDocs.Conversion.LowCode provides two primary ways to load documents: from a file path or a stream. This flexibility enables loading from local storage, memory, cloud, or other custom sources.

In this topic, we use the DocxToPdfConverter class as an example. The same approach applies to other converter classes.

Converter Constructors

Each converter class provides two constructors:

  • *Converter(string filePath, Action<TLoadOptions> loadOptionsAction = null)
  • *Converter(Stream stream, Action<TLoadOptions> loadOptionsAction = null)

The first constructor accepts a relative or absolute file path, while the second accepts a readable stream. Both constructors accept an optional second parameter—an action that allows you to specify the load options.

Example 1: Load from File Path

The following example shows how to load a DOCX file from a local file path.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Create a converter for the DOCX file
var converter = new DocxToPdfConverter("business-plan.docx");

// Convert DOCX as PDF
converter.Convert("business-plan.pdf");
Imports System
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply the license
        License.Set(publicKey, privateKey)

        ' Create a converter from file path
        Dim converter As New DocxToPdfConverter("business-plan.docx")

        ' Convert DOCX to PDF
        converter.Convert("business-plan.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply the license
    License.Set(publicKey, privateKey)

    // Create a converter from file path
    let converter = new DocxToPdfConverter("business-plan.docx")

    // Convert DOCX to PDF
    converter.Convert("business-plan.pdf")
    0

Sample input file: Download business-plan.docx

Example 2: Load from Stream

This example demonstrates how to load a document from a stream (e.g., memory or custom storage provider).

using System;
using System.IO;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Load DOCX file as stream
using var stream = File.OpenRead("business-plan.docx");

// Create a converter from stream
var converter = new DocxToPdfConverter(stream);

// Convert DOCX to PDF
converter.Convert("business-plan.pdf");
Imports System.IO
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Load stream and convert
        Using stream As FileStream = File.OpenRead("business-plan.docx")
            Dim converter As New DocxToPdfConverter(stream)

            ' Convert DOCX to PDF
            converter.Convert("business-plan.pdf")
        End Using
    End Sub
End Module
open System
open System.IO
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

    // Apply license
    License.Set(publicKey, privateKey)

    // Load stream
    use stream = File.OpenRead("business-plan.docx")

    // Create a converter from stream
    let converter = new DocxToPdfConverter(stream)

    // Convert DOCX to PDF
    converter.Convert("business-plan.pdf")
    0

Sample input file: Download business-plan.docx

Example 3: Set Load Options

You can use the optional constructor parameter to apply custom load options such as passwords for protected files.

using System;
using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply license
License.Set(publicKey, privateKey);

// Provide password through load options
var converter = new DocxToPdfConverter("protected.docx", options =>
{
    options.Password = "12345";
});

// Convert DOCX to PDF
converter.Convert("not-protected.pdf");
Imports GroupDocs.Conversion.LowCode

Module Program
    Sub Main()
        ' Load license keys
        Dim publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
        Dim privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")

        ' Apply license
        License.Set(publicKey, privateKey)

        ' Provide password through load options
        Dim converter As New DocxToPdfConverter("protected.docx", Sub(options)
            options.Password = "12345"
        End Sub)

        ' Convert DOCX to PDF
        converter.Convert("not-protected.pdf")
    End Sub
End Module
open System
open GroupDocs.Conversion.LowCode

[<EntryPoint>]
let main _ =
    // Load license keys
    let publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")
    let privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")
    
    // Apply license
    License.Set(publicKey, privateKey)

    // Provide password through load options
    let converter = new DocxToPdfConverter("protected.docx", fun options ->
        options.Password <- "12345"
    )
    
    // Convert DOCX to PDF
    converter.Convert("not-protected.pdf")
    0

Sample input: Download protected.docx (Password: 12345)

Additional Resources