#1
Posted
:
Tuesday, November 21, 2017 12:22:32 PM(UTC)
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 ApplicationC#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();
}
}
}
}
VBCode: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#VBChris Thompson
Developer Support Engineer
LEAD Technologies, Inc.
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.