Hello Norwill,
My name is Matt and I am a member of the LEADTOOLS Support Team.
I will be happy to assist you with any questions you may have.
You are receiving this error because this demo is set up to export to document file formats only. So, when you select to export to PDF or one of the supported PDF types, the demo is exporting the image to a searchable PDF. Raster image to document format conversion always requires our OCR engine to be enabled. If you want to convert solely to raster PDF you are going to need to pass in RasterImageFormat.RasPdf into the CreateJobData() method. See the sample code below, which does not require our OCR engine to be enabled:
static void ConvertToRaster()
{
RasterImageFormat imageFormat = RasterImageFormat.RasPdf;
string file = @"C:\LEADTOOLS22\Resources\Images\ocr1.tif";
string fileName = Path.GetFileNameWithoutExtension(file);
string ext = RasterCodecs.GetExtension(imageFormat);
string outFile = Path.Combine(@"C:\Temp", $"{fileName}.{ext}");
using (DocumentConverter docConverter = new DocumentConverter())
{
DocumentConverterJobData jobData = DocumentConverterJobs.CreateJobData(file, outFile, imageFormat);
jobData.JobName = "Convert to Image Job";
DocumentConverterJob job = docConverter.Jobs.CreateJob(jobData);
docConverter.Jobs.RunJob(job);
if (job.Errors.Count > 0)
foreach (var error in job.Errors)
Console.WriteLine($"Error during conversion: {error.Error.Message}\n");
else
Console.WriteLine($"Successfully Converted {file} to {outFile}\n");
}
}
Note that this is just a proof of concept and implementation method. If you want to adjust the demo you are going to have to take the LEADDocument given and export it to RasterImageFormat.RasPdf using the overload below.
CreateJobData(LEADDocument document, string outputDocumentFileName, RasterImageFormat rasterImageFormat)
If you have any further questions please feel free to reach back out to us. Note you can reach us via email at
support@leadtools.com, or visit our Live Chat.
https://www.leadtools.com/support/chatThanks,
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.