Error processing SSI file
LEADTOOLS (Leadtools assembly)

Show in webframe

AllPages Property








Gets or sets a value that indicates whether to clone all the pages if the source image is multi-page.
Syntax
public bool AllPages {get; set;}
'Declaration
 
Public Property AllPages As Boolean
'Usage
 
Dim instance As CloneCommand
Dim value As Boolean
 
instance.AllPages = value
 
value = instance.AllPages
public bool AllPages {get; set;}
@property (nonatomic, assign) BOOL allPages
public final boolean getAllPages()
public final void setAllPages(boolean value)
            
 <br/>get_AllPages();<br/>set_AllPages(value);<br/>Object.defineProperty('AllPages'); 
public:
property bool AllPages {
   bool get();
   void set (    bool value);
}

Property Value

true to clone all the pages if the source image is multi-page; false, otherwise.
Remarks

If the source image (the image passed to the RasterCommand.Run method) contains multiple pages, then you can use the AllPages property to control whether the CloneCommand will create a copy of the current active page or all the pages in the image.

Note that when the source image has multiple pages and the value of AllPages was set to true, then the RasterCommand.Progress event will fire from 0 to 100 for each page processed. If an overall progress percentage is desired, then you can inspect the RasterImage.Page and RasterImage.PageCount properties of the SourceImage property to calculate this value as shown in the example below.

The default value of this property is false to clone only the current page.

Example

This example will clone a multi-page image and shows the over-all progress value.

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing

Private Sub CloneAllTest()
   Dim codecs As New RasterCodecs()
   ' Create a multi-page image for testing purposes
   Dim image As RasterImage = Nothing
   For i As Integer = 1 To 4
      Dim pageImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "\OCR" + i.ToString() + ".tif"))
      If IsNothing(image) Then
         image = pageImage
      Else
         image.AddPage(pageImage)
         pageImage.Dispose()
      End If
   Next

   Console.WriteLine("Input image has {0} pages", image.PageCount)

   ' Clone all pages
   Dim cloneCmd As New CloneCommand()
   cloneCmd.AllPages = True
   AddHandler cloneCmd.Progress, AddressOf cloneCmd_Progress
   cloneCmd.Run(image)
   RemoveHandler cloneCmd.Progress, AddressOf cloneCmd_Progress

   Dim destinationImage As RasterImage = cloneCmd.DestinationImage
   Console.WriteLine("Cloned image has {0} pages", destinationImage.PageCount)

   destinationImage.Dispose()
   image.Dispose()
   codecs.Dispose()
End Sub

Private Sub cloneCmd_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)
   ' By using the SourceImage property of the CloneCommand we can find out
   ' the progress for the current page as well as the overall
   Dim cmd As CloneCommand = DirectCast(sender, CloneCommand)

   Dim overallPercent As Integer

   If cmd.AllPages AndAlso cmd.SourceImage.PageCount > 1 Then
      ' For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
      ' Use the source image Page property to find out where we are in overall completetion
      overallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) \ cmd.SourceImage.PageCount
   Else
      ' Otherwise, the percent is the same as the current page
      overallPercent = e.Percent
   End If

   Console.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", _
                     cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent)
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;

private void CloneAllTest()
{
   RasterCodecs codecs = new RasterCodecs();
   // Create a multi-page image for testing purposes
   RasterImage image = null;
   for(int i = 1; i <= 4; i++)
   {
      RasterImage pageImage = codecs.Load(Path.Combine(ImagesPath.Path,"OCR" + i.ToString() + ".tif"));
      if(image == null)
         image = pageImage;
      else
      {
         image.AddPage(pageImage);
         pageImage.Dispose();
      }
   }

   Console.WriteLine("Input image has {0} pages", image.PageCount);

   // Clone all pages
   CloneCommand cloneCmd = new CloneCommand();
   cloneCmd.AllPages = true;
   cloneCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);
   cloneCmd.Run(image);
   cloneCmd.Progress -= new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);

   RasterImage destinationImage = cloneCmd.DestinationImage;
   Console.WriteLine("Cloned image has {0} pages", destinationImage.PageCount);

   destinationImage.Dispose();
   image.Dispose();
   codecs.Dispose();
}

private void cloneCmd_Progress(object sender, RasterCommandProgressEventArgs e)
{
   // By using the SourceImage property of the CloneCommand we can find out
   // the progress for the current page as well as the overall
   CloneCommand cmd = sender as CloneCommand;

   int overallPercent;

   if(cmd.AllPages && cmd.SourceImage.PageCount > 1)
   {
      // For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
      // Use the source image Page property to find out where we are in overall completetion
      overallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) / cmd.SourceImage.PageCount;
   }
   else
   {
      // Otherwise, the percent is the same as the current page
      overallPercent = e.Percent;
   }

   Console.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent);
}
RasterCommandExamples.prototype.CloneAllTest = function () {
    Tools.SetLicense();
    with (Leadtools) {
        with (Leadtools.Codecs) {
            with (Leadtools.ImageProcessing) {
                var codecs = new RasterCodecs();

                // Create a multi-page image for testing purposes
                var image = null;
                var files = ["Assets\\OCR1.tif", "Assets\\OCR2.tif", "Assets\\OCR3.tif", "Assets\\OCR4.tif"];

                promises = files.map(function (srcFileName) {


                    return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
                        return codecs.loadAsync(LeadStreamFactory.create(loadFile))
                    })
                    .then(function (pageImage) {
                        if (image == null) {
                            image = pageImage;
                        }
                        else {
                            image.addPage(pageImage);
                            pageImage.close();
                        }
                    });
                });

                return WinJS.Promise.join(promises).then(function () {
                    console.info("Input image has " + image.pageCount + " pages");

                    // Clone all pages
                    var cloneCmd = new CloneCommand();
                    cloneCmd.allPages = true;
                    cloneCmd.addEventListener("progress", cloneCmd_Progress);
                    cloneCmd.run(image);
                    cloneCmd.removeEventListener("progress", cloneCmd_Progress);

                    var destinationImage = cloneCmd.destinationImage;
                    console.info("Cloned image has " + destinationImage.PageCount + " pages");

                    destinationImage.close();
                    image.close();
                    codecs.close();
                });
            }
        }
    }
}

function cloneCmd_Progress(e) {
    // By using the SourceImage property of the CloneCommand we can find out
    // the progress for the current page as well as the overall
    var cmd = e.target;

    var overallPercent;

    if (cmd.allPages && cmd.sourceImage.pageCount > 1) {
        // For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
        // Use the source image Page property to find out where we are in overall completetion
        overallPercent = ((cmd.sourceImage.page - 1) * 100 + e.percent) / cmd.sourceImage.pageCount;
    }
    else {
        // Otherwise, the percent is the same as the current page
        overallPercent = e.percent;
    }

    console.info("Current page completion: " + cmd.sourceImage.page + " of " + cmd.sourceImage.pageCount + " - " + e.percent + "% - Overall image completion " + overallPercent + "%");
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;

      
public async Task CloneAllTest()
{
   RasterCodecs codecs = new RasterCodecs();
   // Create a multi-page image for testing purposes
   RasterImage image = null;
   for (int i = 1; i <= 4; i++)
   {
      string srcFileName = String.Format(@"Assets\OCR{0}.tif", i);
      StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
      RasterImage pageImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
      if (image == null)
         image = pageImage;
      else
      {
         image.AddPage(pageImage);
         pageImage.Dispose();
      }
   }

   Debug.WriteLine("Input image has {0} pages", image.PageCount);

   // Clone all pages
   CloneCommand cloneCmd = new CloneCommand();
   cloneCmd.AllPages = true;
   cloneCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);
   cloneCmd.Run(image);
   cloneCmd.Progress -= new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);

   RasterImage destinationImage = cloneCmd.DestinationImage;
   Debug.WriteLine("Cloned image has {0} pages", destinationImage.PageCount);

   destinationImage.Dispose();
   image.Dispose();
   codecs.Dispose();
}

public void cloneCmd_Progress(object sender, RasterCommandProgressEventArgs e)
{
   // By using the SourceImage property of the CloneCommand we can find out
   // the progress for the current page as well as the overall
   CloneCommand cmd = sender as CloneCommand;

   int overallPercent;

   if (cmd.AllPages && cmd.SourceImage.PageCount > 1)
   {
      // For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
      // Use the source image Page property to find out where we are in overall completetion
      overallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) / cmd.SourceImage.PageCount;
   }
   else
   {
      // Otherwise, the percent is the same as the current page
      overallPercent = e.Percent;
   }

   Debug.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent);
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;

private void CloneAllTest(RasterImage image1, RasterImage image2, RasterImage image3, RasterImage image4)
{
   // Create a multi-page image for testing purposes
   RasterImage image = null;
   image = image1;
   image.AddPage(image2);
   image.AddPage(image3);
   image.AddPage(image4);
   Debug.WriteLine("Input image has {0} pages", image.PageCount);

   // Clone all pages
   CloneCommand cloneCmd = new CloneCommand();
   cloneCmd.AllPages = true;
   cloneCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);
   cloneCmd.Run(image);
   cloneCmd.Progress -= new EventHandler<RasterCommandProgressEventArgs>(cloneCmd_Progress);

   RasterImage destinationImage = cloneCmd.DestinationImage;
   Debug.WriteLine("Cloned image has {0} pages", destinationImage.PageCount);

   destinationImage.Dispose();
   image.Dispose();
   image1.Dispose();
   image2.Dispose();
   image3.Dispose();
   image4.Dispose();
}

private void cloneCmd_Progress(object sender, RasterCommandProgressEventArgs e)
{
   // By using the SourceImage property of the CloneCommand we can find out
   // the progress for the current page as well as the overall
   CloneCommand cmd = sender as CloneCommand;

   int overallPercent;

   if(cmd.AllPages && cmd.SourceImage.PageCount > 1)
   {
      // For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
      // Use the source image Page property to find out where we are in overall completetion
      overallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) / cmd.SourceImage.PageCount;
   }
   else
   {
      // Otherwise, the percent is the same as the current page
      overallPercent = e.Percent;
   }

   Debug.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent);
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media

Private Sub CloneAllTest(ByVal image1 As RasterImage, ByVal image2 As RasterImage, ByVal image3 As RasterImage, ByVal image4 As RasterImage)
   ' Create a multi-page image for testing purposes
   Dim image As RasterImage = Nothing
   image = image1
   image.AddPage(image2)
   image.AddPage(image3)
   image.AddPage(image4)
   Debug.WriteLine("Input image has {0} pages", image.PageCount)

   ' Clone all pages
   Dim cloneCmd As CloneCommand = New CloneCommand()
   cloneCmd.AllPages = True
   AddHandler cloneCmd.Progress, AddressOf cloneCmd_Progress
   cloneCmd.Run(image)
   RemoveHandler cloneCmd.Progress, AddressOf cloneCmd_Progress

   Dim destinationImage As RasterImage = cloneCmd.DestinationImage
   Debug.WriteLine("Cloned image has {0} pages", destinationImage.PageCount)

   destinationImage.Dispose()
   image.Dispose()
   image1.Dispose()
   image2.Dispose()
   image3.Dispose()
   image4.Dispose()
End Sub

Private Sub cloneCmd_Progress(ByVal sender As Object, ByVal e As RasterCommandProgressEventArgs)
   ' By using the SourceImage property of the CloneCommand we can find out
   ' the progress for the current page as well as the overall
   Dim cmd As CloneCommand = TryCast(sender, CloneCommand)

   Dim overallPercent As Integer

   If cmd.AllPages AndAlso cmd.SourceImage.PageCount > 1 Then
      ' For multiple-pages, the command will fire the Progress event from 0 to 100 for each page
      ' Use the source image Page property to find out where we are in overall completetion
      overallPercent = ((cmd.SourceImage.Page - 1) * 100 + e.Percent) / cmd.SourceImage.PageCount
   Else
      ' Otherwise, the percent is the same as the current page
      overallPercent = e.Percent
   End If

   Debug.WriteLine("Current page completion: {0} of {1} - {2}% - Overall image completion {3}%", cmd.SourceImage.Page, cmd.SourceImage.PageCount, e.Percent, overallPercent)
End Sub
Requirements

Target Platforms

See Also

Reference

CloneCommand Class
CloneCommand Members

Error processing SSI file