←Select platform

DocumentConverterEmptyPageMode Enumeration

Summary

Controls how empty pages are treated during the conversion.

Syntax
C#
C++/CLI
Java
Python
[SerializableAttribute()] 
[DataContractAttribute()] 
public enum DocumentConverterEmptyPageMode 
public [SerializableAttribute,  
   DataContractAttribute] 
   enum class DocumentConverterEmptyPageMode sealed 
public enum DocumentConverterEmptyPageMode 
class DocumentConverterEmptyPageMode(Enum): 
   None = 0 
   Skip = 1 
   SkipIgnoreAnnotations = 2 
Members

0

None

Empty page will be added to the document and no checking is performed.

1

Skip

Skip empty pages. The page is considered not empty if the annotations container for page contains items.

2

SkipIgnoreAnnotations

Skip empty pages. The page is considered empty even if the annotations container for page contains items.

Remarks

Refer to EmptyPageMode for more information.

Example
C#
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); 
                  } 
               } 
            } 
         } 
      } 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.