Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, November 21, 2017 12:22:32 PM(UTC)
Christopher

Groups: Registered, Tech Support, Administrators
Posts: 89

Was thanked: 4 time(s) in 4 post(s)

The below examples show how to Split a multi-page document using LEADTOOLS.
These examples have been updated to use the LEADTOOLS v20 DLLs.

First, it is important to note that the DLLs needed for splitting the documents will depend on the documents that the application will be working with.
In our application we are working with PDFs and with Tifs so those DLLs are included.

Follow this link to see what you will need: Files To Be Included With Your Application

C#
Code:
using Leadtools;
using Leadtools.Codecs;

namespace simpleSplitDocument
{
    class Program
    {
        static void Main(string[] args)
        {
            //add your license and key files here
            RasterSupport.SetLicense("", "");
            RasterCodecs codecs = new RasterCodecs();

            string multiPageFileName = @"C:\Users\cthompson\Desktop\Leadtools.pdf"; //add file path here
            CodecsImageInfo info = codecs.GetInformation(multiPageFileName, true);

            string outputDir = @"C:\Users\cthompson\Desktop\"; //add output location here

            for (int pageNumber = 1; pageNumber <= info.TotalPages; pageNumber++)
            {
                // Load the next image in the loop 
                RasterImage image = codecs.Load(multiPageFileName, 0, CodecsLoadByteOrder.BgrOrGray, pageNumber, pageNumber);

                // Save the page to a separate file 
                string pageFileName = Path.Combine(outputDir, "Page_" + pageNumber + ".tif");
                codecs.Save(image, pageFileName, RasterImageFormat.Tif, 0);
                image.Dispose();
            }
        }
    }
}


VB
Code:
Imports Leadtools
Imports Leadtools.Codecs

Module Module1
    Sub Main()
        ''add your license And key files here
        RasterSupport.SetLicense("", "")

        Dim outputDir = "C:\Users\cthompson\Desktop\"
        Dim multiPageFileName = "C:\Users\cthompson\Desktop\Ocr_All.tif"

        Dim Codecs As New RasterCodecs()
        Dim info = Codecs.GetInformation(multiPageFileName, True)

        For pageNumber As Integer = 1 To info.TotalPages Step 1
            '' Load the next image in the loop 
            Dim image = Codecs.Load(multiPageFileName, 0, CodecsLoadByteOrder.BgrOrGray, pageNumber, pageNumber)

            '' Save the page to a separate file 
            Dim pageFileName = outputDir + "Page_" + pageNumber.ToString + ".tif"
            Codecs.Save(image, pageFileName, RasterImageFormat.Tif, 0)
            image.Dispose()
        Next


    End Sub

End Module


C#
File Attachment(s):
simpleSplitDocument_20.zip (140kb) downloaded 144 time(s).

VB
File Attachment(s):
simpleSplitDocumentVB_20.zip (1,281kb) downloaded 125 time(s).
Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.080 seconds.