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.
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.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply the licenseLicense.Set(publicKey,privateKey);// Create a converter for the DOCX filevarconverter=newDocxToPdfConverter("business-plan.docx");// Convert DOCX as PDFconverter.Convert("business-plan.pdf");
ImportsSystemImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply the license
License.Set(publicKey,privateKey)' Create a converter from file path
DimconverterAsNewDocxToPdfConverter("business-plan.docx")' Convert DOCX to PDF
converter.Convert("business-plan.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply the license
License.Set(publicKey,privateKey)// Create a converter from file path
letconverter=newDocxToPdfConverter("business-plan.docx")// Convert DOCX to PDF
converter.Convert("business-plan.pdf")0
This example demonstrates how to load a document from a stream (e.g., memory or custom storage provider).
usingSystem;usingSystem.IO;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Load DOCX file as streamusingvarstream=File.OpenRead("business-plan.docx");// Create a converter from streamvarconverter=newDocxToPdfConverter(stream);// Convert DOCX to PDFconverter.Convert("business-plan.pdf");
ImportsSystem.IOImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Load stream and convert
UsingstreamAsFileStream=File.OpenRead("business-plan.docx")DimconverterAsNewDocxToPdfConverter(stream)' Convert DOCX to PDF
converter.Convert("business-plan.pdf")EndUsingEndSubEndModule
openSystemopenSystem.IOopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Load stream
usestream=File.OpenRead("business-plan.docx")// Create a converter from stream
letconverter=newDocxToPdfConverter(stream)// Convert DOCX to PDF
converter.Convert("business-plan.pdf")0
You can use the optional constructor parameter to apply custom load options such as passwords for protected files.
usingSystem;usingGroupDocs.Conversion.LowCode;// Load license keysvarpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");varprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");// Apply licenseLicense.Set(publicKey,privateKey);// Provide password through load optionsvarconverter=newDocxToPdfConverter("protected.docx",options=>{options.Password="12345";});// Convert DOCX to PDFconverter.Convert("not-protected.pdf");
ImportsGroupDocs.Conversion.LowCodeModuleProgramSubMain()' Load license keys
DimpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")DimprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")' Apply license
License.Set(publicKey,privateKey)' Provide password through load options
DimconverterAsNewDocxToPdfConverter("protected.docx",Sub(options)options.Password="12345"EndSub)' Convert DOCX to PDF
converter.Convert("not-protected.pdf")EndSubEndModule
openSystemopenGroupDocs.Conversion.LowCode[<EntryPoint>]letmain_=// Load license keys
letpublicKey=Environment.GetEnvironmentVariable("GD_PUBLIC_KEY")letprivateKey=Environment.GetEnvironmentVariable("GD_PRIVATE_KEY")// Apply license
License.Set(publicKey,privateKey)// Provide password through load options
letconverter=newDocxToPdfConverter("protected.docx",funoptions->options.Password<-"12345")// Convert DOCX to PDF
converter.Convert("not-protected.pdf")0