Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, March 1, 2018 11:15:25 AM(UTC)

Groups: Registered, Tech Support, Administrators
Posts: 88

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.

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);

            if (job.Status == DocumentConverterJobStatus.Success)
                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);

File Attachment(s):
simpleConvertDemo_20.zip (215kb) downloaded 148 time(s).
Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

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.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.082 seconds.