#1
Posted
:
Thursday, March 1, 2018 11:15:25 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 89
Was thanked: 4 time(s) in 4 post(s)
Working with the LEADTOOLS
DocumentConverter Class can be quite simple.
In the code below the input .docx file is being converted into a .pdf.
To expand on the working version of the project attached just add the DLL references that are required to work with the different
file types that LEADTOOLS supports on our
"Files to be Included with Your Application" webpage.
Below I have included a working sample of the code that is referenced on the LEADTOOLS website.
Code:using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Document.Writer;
using Leadtools.Document.Converter;
namespace simpleConvertDemo_20
{
class Program
{
static void Main(string[] args)
{
string licenseFilePath = @"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC";
string keyFileValue = File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY");
RasterSupport.SetLicense(licenseFilePath, keyFileValue);
DocumentConverter documentConverter = new DocumentConverter();
string inputFile = @"C:\Users\cthompson\Desktop\test-1.Docx";
string outputFile = @"C:\Users\cthompson\Desktop\test-1_Output.pdf";
var format = DocumentFormat.Pdf;
var jobData = DocumentConverterJobs.CreateJobData(inputFile, outputFile, format);
var job = documentConverter.Jobs.CreateJob(jobData);
documentConverter.Jobs.RunJob(job);
if (job.Status == DocumentConverterJobStatus.Success)
{
Console.WriteLine("Success");
}
else
{
Console.WriteLine("{0} Errors", job.Status);
foreach (var error in job.Errors)
{
Console.WriteLine(" {0} at {1}: {2}", error.Operation, error.InputDocumentPageNumber, error.Error.Message);
}
}
Console.ReadLine();
documentConverter.Dispose();
}
}
}
Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.
![LEAD Logo LEAD Logo](https://www.leadtools.com/images/new-site-images/leadtools-logo-header.png)
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.