i am getting the following error when trying to convert a docx to pdf at the following line
providerDocx.Import(input)
The type initializer for 'Telerik.Windows.Documents.Flow.Model.RadFlowDocument' threw an exception.
using System;
using System.IO;
using Telerik.Windows.Documents.Common.FormatProviders;
using Telerik.Windows.Documents.Flow.FormatProviders.Docx;
using Telerik.Windows.Documents.Flow.FormatProviders.Pdf;
using Telerik.Windows.Documents.Flow.Model;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var providerDocx = new DocxFormatProvider();
string path = System.IO.Directory.GetCurrentDirectory();
string fileName = Path.Combine(path, "1.docx");
RadFlowDocument document = null;
using (FileStream input = new FileStream(fileName, FileMode.Open))
{
document = providerDocx.Import(input);
}
var providerPdf = new PdfFormatProvider();
Stream outStream = new MemoryStream();
providerPdf.Export(document, outStream);
//Test the conversion:
var fileStream = File.Create("PdfTest.pdf");
outStream.Seek(0, SeekOrigin.Begin);
outStream.CopyTo(fileStream);
fileStream.Close();
}
}
}