←Select platform

OcrDocumentFontType Enumeration

Summary
Font types used when saving the final document.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum OcrDocumentFontType   
typedef NS_ENUM(NSInteger, LTOcrDocumentFontType) { 
 LTOcrDocumentFontTypeProportionalSerif = 0,  
 LTOcrDocumentFontTypeProportionalSansSerif,  
 LTOcrDocumentFontTypeFixedSerif,  
 LTOcrDocumentFontTypeFixedSansSerif,  
 LTOcrDocumentFontTypeMICR 
}; 
public enum OcrDocumentFontType 
[SerializableAttribute()] 
public enum class OcrDocumentFontType   
class OcrDocumentFontType(Enum): 
   ProportionalSerif = 0 
   ProportionalSansSerif = 1 
   FixedSerif = 2 
   FixedSansSerif = 3 
   MICR = 4 
Members
ValueMemberDescription
0ProportionalSerif The font used with proportional serif characters
1ProportionalSansSerif The font used with proportional sans-serif characters
2FixedSerif The font used with monospaced serif characters
3FixedSansSerif The font used with monospaced sans-serif characters
4MICR The font used with MICR (check font) characters
Remarks

OcrDocumentFontType is used with IOcrDocumentManager.GetFontName and IOcrDocumentManager.SetFontName to get/set the fonts used in the final recognized document (PDF, DOC, HTML, etc)..

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Forms.Common; 
using Leadtools.Document.Writer; 
using Leadtools.WinForms; 
 
public void DocumentFontsTest() 
{ 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
      { 
         ocrEngine.Startup(codecs, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
         IOcrDocumentManager ocrDocumentManager = ocrEngine.DocumentManager; 
 
         using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
         { 
            // Add a page to OCR 
            IOcrPage ocrPage = ocrDocument.Pages.AddPage(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"), null); 
 
            ocrPage.AutoZone(null); 
            ocrPage.Recognize(null); 
 
            // Show the current fonts used to save default documents 
            Console.WriteLine("Saving use the following fonts:"); 
            ShowFonts(ocrDocumentManager); 
            ocrDocument.Save(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1_DefaultFonts.pdf"), DocumentFormat.Pdf, null); 
 
            // Now change the fonts to something else 
            string[] newFonts = ocrDocumentManager.GetFontNames(null); 
 
            // Use Cambira for Proportional Serif font - instead of Times New Roman 
            newFonts[0] = "Cambria"; 
            // Use Calibri for Proportional Sans-serif font - instead of Arial 
            newFonts[1] = "Calibri"; 
            // Use Lucida Console for Monospace fonts (both Serif and Sans-serif) 
            newFonts[2] = "Lucida Console"; 
            newFonts[3] = "Lucida Console"; 
            // Leave the ICR and MICR fonts the same 
 
            ocrDocumentManager.SetFontNames(null, newFonts); 
 
            // Show the new fonts used to save default documents 
            Console.WriteLine("Saving use the following fonts:"); 
            ShowFonts(ocrDocumentManager); 
            ocrDocument.Save(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1_CustomFonts.pdf"), DocumentFormat.Pdf, null); 
         } 
      } 
   } 
} 
 
private static void ShowFonts(IOcrDocumentManager ocrDocumentManager) 
{ 
   // Get the default fonts 
   // The default fonts will be used for all Latin languages 
   string[] fonts = ocrDocumentManager.GetFontNames(null); 
 
   // This should return an array of 6 items, as follows: 
   Console.WriteLine("Proportional Serif font:        " + fonts[0]); 
   Console.WriteLine("Proportional Sans-serif font:   " + fonts[1]); 
   Console.WriteLine("Monospace Serif font:           " + fonts[2]); 
   Console.WriteLine("Monospace Sans-serif font:      " + fonts[3]); 
   Console.WriteLine("ICR (hand-written) font:        " + fonts[4]); 
   Console.WriteLine("MICR (Check) font:              " + fonts[5]); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.nio.file.Files; 
import java.nio.file.Path; 
import java.nio.file.Paths; 
 
import java.util.ArrayList; 
import java.util.List; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.assertTrue; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
// // public void OcrDocumentManagerGetFontNamesExample() { 
//    final var LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images"; 
//    final var LEAD_VARS_OcrLEADRuntimeDir = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime";   
//    ILeadStream leadStream = LeadStreamFactory.create(combine(LEAD_VARS_ImagesDir, "Ocr1.tif")); 
//    RasterCodecs codecs = new RasterCodecs(); 
       
//    // Add a page to OCR 
//    OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
//    ocrEngine.startup(codecs, null, null, LEAD_VARS_OcrLEADRuntimeDir); 
//    assertTrue("OCR engine startup unsuccessful", ocrEngine.isStarted()); 
//    OcrDocumentManager ocrDocumentManager = ocrEngine.getDocumentManager(); 
//    OcrDocument ocrDocument = ocrEngine.getDocumentManager().createDocument(); 
//    OcrPage ocrPage = ocrDocument.getPages().addPage(leadStream, null); 
 
//    ocrPage.autoZone(null); 
//    ocrPage.recognize(null); 
 
//    // Show the current fonts used to save default documents 
//    System.out.println("Saving use the following fonts:"); 
//    ShowFonts(ocrDocumentManager); 
//    ocrDocument.save(combine(LEAD_VARS_ImagesDir, "Ocr1_DefaultFonts.pdf"), DocumentFormat.PDF, null); 
 
//    // Now change the fonts to something else 
//    ArrayList<String> newFonts = ocrDocumentManager.getFontNames(null); 
 
//    // Use Cambira for Proportional Serif font - instead of Times New Roman 
//    newFonts.set(0, "Cambria"); 
//    // Use Calibri for Proportional Sans-serif font - instead of Arial 
//    newFonts.set(1, "Calibri"); 
//    // Use Lucida Console for Monospace fonts (both Serif and Sans-serif) 
//    newFonts.set(2, "Lucida Console"); 
//    newFonts.set(3, "Lucida Console"); 
//    // Leave the ICR and MICR fonts the same 
 
//    ocrDocumentManager.setFontNames(null, newFonts); 
       
//    // Show the new fonts used to save default documents 
//    System.out.println("Saving use the following fonts:"); 
//    ShowFonts(ocrDocumentManager); 
//    ocrDocument.save(combine(LEAD_VARS_ImagesDir, "Ocr1_CustomFonts.pdf"), DocumentFormat.PDF, null); 
// } 
 
// private static void ShowFonts(OcrDocumentManager ocrDocumentManager) { 
//    // Get the default fonts 
//    // The default fonts will be used for all Latin languages 
//    ArrayList<String> fonts = ocrDocumentManager.getFontNames(null); 
 
//    // This should return an array of 6 items, as follows: 
//    System.out.println("Proportional Serif font:        " + fonts.get(0)); 
//    System.out.println("Proportional Sans-serif font:   " + fonts.get(1)); 
//    System.out.println("Monospace Serif font:           " + fonts.get(2)); 
//    System.out.println("Monospace Sans-serif font:      " + fonts.get(3)); 
//    System.out.println("ICR (hand-written) font:        " + fonts.get(4)); 
//    System.out.println("MICR (Check) font:              " + fonts.get(5)); 
// } 
Requirements

Target Platforms

See Also

Reference

Leadtools.Ocr Namespace

Help Version 23.0.2024.4.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.