Steps for Converting large batches of files

  1. Import the trial Developer License:

    License.Import(new StreamReader(@”C:\Users\Joe\license.xml”));

  2. Set up the folders the processed files will be moved to:

    //set your source and output folders
    static String sourceFolder = @”E:\process\source”;
    static String outputFolder = @”E:\process\output”;
    static String errorFolder = @”E:\process\error”;

    //Check there is a source folder if there isn’t throw an exception
    if (!Directory.Exists(sourceFolder))
    throw new InvalidOperationException();

    //if there is a source folder but no output folder – create the output folder.
    if (!Directory.Exists(outputFolder))

    //Lastly create the error folder.
    if (!Directory.Exists(errorFolder))

  3. Use the JobProcessor Method to start a process:

    //Simple synchronous (no events) version
    using (JobProcessor processor = new JobProcessor())
    processor.KeepJobs = true;

  4. Optionally you can configure JobProcessor to run 64-bit job handlers even if your own application is a 32 bit exe. Obviously it will only launch 64 bit job handlers if running under 64 bit Windows. This allows legacy 32 bit applications to take advantage of the performance benefits of a 64 bit operating system (OCR of multiple page scanned documents is much faster running as 64 bit):

    processor.Allow64on32 = true;

  5. For each file in Source Folder – You must set the OCR Language any other settings are optional:

    foreach (String pdfPath in Directory.GetFiles(sourceFolder, “*.pdf”, SearchOption.TopDirectoryOnly))
    PdfToWordJobEnvelope jobEnvelope = new PdfToWordJobEnvelope();

    // OCR Language must be set
    jobEnvelope.OcrLanguage = “en”;

    //Additional options could be set here

  6. Set the Source path of the files and Submit the Job:

    //Set the Source Path
    jobEnvelope.SourcePath = pdfPath;

    //Submit the Job

  7. Set “processor” to wait until all files have been completed:

    // wait until the queue is empty and all jobs are processed

  8. Now do something with the results:

    foreach (JobEnvelope processedJob in processor.ProcessedJobs)
    if ((processedJob.Status != SolidFramework.Services.Plumbing.JobStatus.Success) || (processedJob.OutputPaths.Count !=1))
    // report errors to the console window
    Console.WriteLine(Path.GetFileName(processedJob.SourcePath) + ” failed because ” + processedJob.Message);
    String eFolder = Path.Combine(errorFolder, Path.GetFileName(processedJob.SourcePath));
    String ePath = processedJob.SourcePath;
    File.Move(ePath, eFolder);

  9. Files are saved to a temporary location and need to be moved with the correct file extension:

    //This code builds the file name
    String wordOutputPath = Path.Combine(outputFolder, Path.GetFileName(processedJob.SourcePath));
    String wordTemporaryPath = processedJob.OutputPaths[0];
    String outputExtension = Path.GetExtension(wordTemporaryPath);

    //This adds the file extention that must match what was chosen above.
    wordOutputPath = Path.ChangeExtension(wordOutputPath, outputExtension);

    //For each file in the jobEnvelope copy it to the file path and format above
    File.Copy(wordTemporaryPath, wordOutputPath, true);