←Select platform

BlankPageDetectorCommandFlags Property

Summary

Options to use for detecting empty raster pages.

Syntax
C#
C++/CLI
Java
Python
public BlankPageDetectorCommandFlags BlankPageDetectorCommandFlags { get; set; } 
public:  
   property BlankPageDetectorCommandFlags^ BlankPageDetectorCommandFlags 
   { 
      BlankPageDetectorCommandFlags^ get() 
      void set(BlankPageDetectorCommandFlags^ value) 
   } 
// Use BlankPageDetectorCommandFlags members 
public int getBlankPageDetectorCommandFlags() 
public void setBlankPageDetectorCommandFlags(int value) 
BlankPageDetectorCommandFlags # get and set (DocumentConverterPreprocessor) 

Property Value

The options to use for detecting empty raster pages. Default value is BlankPageDetectorCommandFlags.None for default detection.

Remarks

Refer to EmptyPageMode for more information.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Document.Converter; 
using Leadtools.Annotations.Rendering; 
 
public static void Run() 
{ 
   var inputDocumentFile = @"C:\LEADTOOLS22\Resources\Images\EmptyPageTestInput.tif"; 
   var outputDocumentFile1 = @"C:\LEADTOOLS22\Resources\Images\NoSkipping.tif"; 
   var outputDocumentFile2 = @"C:\LEADTOOLS22\Resources\Images\SkippingEmptyPages.tif"; 
 
   // Create a multi-page TIF file that is 4 pages with the second page empty 
   CreateTestDocumentFile(inputDocumentFile); 
 
   using (DocumentConverter documentConverter = new DocumentConverter()) 
   { 
      documentConverter.Diagnostics.EnableTrace = true; 
 
      // Make sure the options are set to not skip empty pages 
      documentConverter.Options.EmptyPageMode = DocumentConverterEmptyPageMode.None; 
 
      // Create a job to convert the input document to the first output file and run it 
      var jobData = DocumentConverterJobs.CreateJobData(inputDocumentFile, outputDocumentFile1, RasterImageFormat.CcittGroup4); 
      jobData.JobName = "No skipping empty pages"; 
      var job = documentConverter.Jobs.CreateJob(jobData); 
      documentConverter.Jobs.RunJob(job); 
 
      // Now, tell the document converter to skip empty pagess 
      documentConverter.Options.EmptyPageMode = DocumentConverterEmptyPageMode.SkipIgnoreAnnotations; 
      // And create a job to convert the input document to the second output file and run it 
      jobData = DocumentConverterJobs.CreateJobData(inputDocumentFile, outputDocumentFile2, RasterImageFormat.CcittGroup4); 
      jobData.JobName = "Skipping empty pages"; 
      job = documentConverter.Jobs.CreateJob(jobData); 
      documentConverter.Jobs.RunJob(job); 
 
      Console.WriteLine("Finished, checking the number of pages"); 
 
      // Show the number of pages in the first and second document, should report 4 and 3 
      using (var rasterCodecs = new RasterCodecs()) 
      { 
         var pageCount = rasterCodecs.GetTotalPages(outputDocumentFile1); 
         Console.WriteLine("First job did not skip any pages and produced {0} pages, should be 4", pageCount); 
         pageCount = rasterCodecs.GetTotalPages(outputDocumentFile2); 
         Console.WriteLine("Second job skipped the empty pages and produced {0} pages, should be 3", pageCount); 
      } 
   } 
} 
 
private static void CreateTestDocumentFile(string fileName) 
{ 
   var pageTemplateFile = @"C:\LEADTOOLS22\Resources\Images\Ocr{0}.tif"; 
 
   using (var rasterCodecs = new RasterCodecs()) 
   { 
      rasterCodecs.Options.RasterizeDocument.Load.Resolution = 300; 
 
      CodecsSavePageMode savePageMode = CodecsSavePageMode.Overwrite; 
 
      for (var pageNumber = 1; pageNumber <= 4; pageNumber++) 
      { 
         if (pageNumber != 2) 
         { 
            using (var rasterImage = rasterCodecs.Load(string.Format(pageTemplateFile, pageNumber), 1)) 
            { 
               // Add it to the output document 
               rasterCodecs.Save(rasterImage, fileName, RasterImageFormat.CcittGroup4, 1, 1, 1, -1, savePageMode); 
               savePageMode = CodecsSavePageMode.Append; 
 
               if (pageNumber == 1) 
               { 
                  // Save an empty page (all white) the same size as the previous page 
                  using (var emptyPage = RasterImage.Create( 
                     rasterImage.Width, 
                     rasterImage.Height, 
                     rasterImage.BitsPerPixel, 
                     rasterImage.XResolution, 
                     RasterColor.FromKnownColor(RasterKnownColor.White))) 
                  { 
                     rasterCodecs.Save(emptyPage, fileName, RasterImageFormat.CcittGroup4, 1, 1, 1, -1, savePageMode); 
                  } 
               } 
            } 
         } 
      } 
   } 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.FileOutputStream; 
import java.io.IOException; 
import java.net.URI; 
import java.util.concurrent.Executors; 
import java.util.logging.ConsoleHandler; 
import java.util.logging.Handler; 
import java.util.logging.Level; 
import java.util.logging.Logger; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.*; 
import leadtools.annotations.rendering.AnnJavaRenderingEngine; 
import leadtools.caching.FileCache; 
import leadtools.codecs.*; 
import leadtools.document.DocumentFactory; 
import leadtools.document.DownloadDocumentOptions; 
import leadtools.document.LEADDocument; 
import leadtools.document.LoadDocumentOptions; 
import leadtools.document.LoadFromCacheOptions; 
import leadtools.document.UploadDocumentOptions; 
import leadtools.document.converter.DocumentConverter; 
import leadtools.document.converter.DocumentConverterEmptyPageMode; 
import leadtools.document.converter.DocumentConverterJob; 
import leadtools.document.converter.DocumentConverterJobData; 
import leadtools.document.converter.DocumentConverterJobError; 
import leadtools.document.converter.DocumentConverterJobErrorMode; 
import leadtools.document.converter.DocumentConverterJobStatus; 
import leadtools.document.converter.DocumentConverterJobs; 
import leadtools.document.writer.DocumentFormat; 
import leadtools.document.writer.DocumentWriter; 
import leadtools.ocr.OcrEngine; 
import leadtools.ocr.OcrEngineManager; 
import leadtools.ocr.OcrEngineType; 
 
 
public void documentConverterEmptyPageMode() { 
   String LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String inFile = combine(LEAD_VARS_ImagesDir, "EmptyPageTestInput.tif"); 
   String outFile = combine(LEAD_VARS_ImagesDir, "NoSkipping.tif"); 
   String outFile2 = combine(LEAD_VARS_ImagesDir, "SkippingEmptyPages.tif"); 
 
   createTestDocumentFile(inFile); 
 
   DocumentConverter documentConverter = new DocumentConverter(); 
   documentConverter.getDiagnostics().setEnableTrace(true); 
   // Make sure the options are set to not skip empty pages 
   documentConverter.getOptions().setEmptyPageMode(DocumentConverterEmptyPageMode.NONE); 
 
   // Create a job to convert the input document to the first output file and run it 
   DocumentConverterJobData jobData = DocumentConverterJobs.createJobData(inFile, outFile, 
         RasterImageFormat.CCITT_GROUP4); 
   jobData.setJobName("No Skipping empty pages"); 
   DocumentConverterJob job = documentConverter.getJobs().createJob(jobData); 
   documentConverter.getJobs().runJob(job); 
 
   // Now, tell the document converter to skip empty pagess 
   documentConverter.getOptions().setEmptyPageMode(DocumentConverterEmptyPageMode.SKIP_IGNORE_ANNOTATIONS); 
   // And create a job to convert the input document to the second output file and run it 
   jobData = DocumentConverterJobs.createJobData(inFile, outFile2, RasterImageFormat.CCITT_GROUP4); 
   jobData.setJobName("Skipping empty pages"); 
   job = documentConverter.getJobs().createJob(jobData); 
   documentConverter.getJobs().runJob(job); 
   assertTrue(job.getStatus() == DocumentConverterJobStatus.SUCCESS); 
   System.out.println("Finished, checking number of pages"); 
 
   RasterCodecs codecs = new RasterCodecs(); 
   int pageCount = codecs.getTotalPages(outFile); 
   System.out 
         .println(String.format("First job did not skip any pages and produced %s pages, should be 4", pageCount)); 
   pageCount = codecs.getTotalPages(outFile2); 
   System.out 
         .println(String.format("Second job skipped the empty pages and produced %s pages, should be 3", pageCount)); 
} 
 
public static void createTestDocumentFile(String fileName) { 
   String pageTemplateFile = "C:\\LEADTOOLS23\\Resources\\Images\\Ocr%s.tif"; 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
   CodecsSavePageMode savePageMode = CodecsSavePageMode.OVERWRITE; 
   for (int i = 1; i <= 4; i++) { 
      if (i != 2) { 
         RasterImage rasterImage = codecs.load(String.format(pageTemplateFile, i), 1); 
         codecs.save(rasterImage, fileName, RasterImageFormat.CCITT_GROUP4, 1, 1, 1, -1, savePageMode); 
         savePageMode = CodecsSavePageMode.APPEND; 
 
         if (i == 1) { 
            RasterImage emptyPage = RasterImage.create(rasterImage.getWidth(), rasterImage.getHeight(), 
                  rasterImage.getBitsPerPixel(), rasterImage.getXResolution(), 
                  RasterColor.fromKnownColor(RasterKnownColor.WHITE)); 
            codecs.save(emptyPage, fileName, RasterImageFormat.CCITT_GROUP4, 1, 1, 1, -1, savePageMode); 
         } 
      } 
   } 
} 
Requirements

Target Platforms

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

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