Gets a value that indicates whether the specified format supports multi-page save operation.
public static bool FormatSupportsMultipageSave(Leadtools.RasterImageFormat format)
Public Shared Function FormatSupportsMultipageSave( _ByVal format As Leadtools.RasterImageFormat _) As Boolean
public static bool FormatSupportsMultipageSave(Leadtools.RasterImageFormat format)
function Leadtools.Codecs.RasterCodecs.FormatSupportsMultipageSave(format)
public:static bool FormatSupportsMultipageSave(Leadtools.RasterImageFormat format)
format
Format to check.
true if the image file format specified by format supports multi-page save operations.
This example will try to save a multi-page file to disk, if the format supports multi-page files, then it will create a single output file, otherwise, multiple files (for each page) will be created.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;private static void SaveMultiPageFile(RasterCodecs rasterCodecs, RasterImage multiPageImage, string outputFile, RasterImageFormat format){// Check if the image has multi-ple pages and the format supports multi-pageif (multiPageImage.PageCount > 1 && RasterCodecs.FormatSupportsMultipageSave(format)){// Yes, just save the filerasterCodecs.Save(multiPageImage, outputFile, format, 0, 1, -1, 1, CodecsSavePageMode.Overwrite);}else{// No, we need to save each page in a separate fileint originalPageNumber = multiPageImage.Page;for (int pageNumber = 1; pageNumber <= multiPageImage.PageCount; pageNumber++){// Get the new file namestring name = Path.GetFileNameWithoutExtension(outputFile) + "_page" + pageNumber.ToString();name = Path.ChangeExtension(name, Path.GetExtension(outputFile));string pageFile = Path.Combine(Path.GetDirectoryName(outputFile), name);// Save this pagemultiPageImage.Page = pageNumber;rasterCodecs.Save(multiPageImage, pageFile, format, 0);}multiPageImage.Page = originalPageNumber;}}public static void FormatSupportsMultipageSaveExample(){string inDir = LeadtoolsExamples.Common.ImagesPath.Path;string outDir = Path.Combine(inDir, @"FormatSupportsMultipageSave");if (!Directory.Exists(outDir))Directory.CreateDirectory(outDir);using (RasterCodecs rasterCodecs = new RasterCodecs()){// Create a multi-page imageusing (RasterImage multiPageImage = GetMultipageImage(rasterCodecs, inDir)){// Save the image as TIF, this should create a single fileSaveMultiPageFile(rasterCodecs, multiPageImage, Path.Combine(outDir, "out.tif"), RasterImageFormat.Tif);// Save the image as PNG, this should create multiple files (one for each page)SaveMultiPageFile(rasterCodecs, multiPageImage, Path.Combine(outDir, "out.png"), RasterImageFormat.Png);}}}private static RasterImage GetMultipageImage(RasterCodecs rasterCodecs, string inDir){// Create a multi-page image from some known LEADTOOLS imagesRasterImage multiPageImage = null;for (int imageNumber = 1; imageNumber <= 4; imageNumber++){string fileName = Path.Combine(inDir, "Ocr" + imageNumber.ToString() + ".tif");RasterImage pageImage = rasterCodecs.Load(fileName, 1);if (multiPageImage == null){multiPageImage = pageImage;}else{multiPageImage.AddPage(pageImage);pageImage.Dispose();}}return multiPageImage;}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPrivate Shared Sub SaveMultiPageFile(rasterCodecs As RasterCodecs, multiPageImage As RasterImage, outputFile As String, format As RasterImageFormat)' Check if the image has multi-ple pages and the format supports multi-pageIf multiPageImage.PageCount > 1 AndAlso rasterCodecs.FormatSupportsMultipageSave(format) Then' Yes, just save the filerasterCodecs.Save(multiPageImage, outputFile, format, 0, 1, -1, 1, CodecsSavePageMode.Overwrite)Else' No, we need to save each page in a separate fileDim originalPageNumber As Integer = multiPageImage.PageFor pageNumber As Integer = 1 To multiPageImage.PageCount' Get the new file nameDim name As String = Path.GetFileNameWithoutExtension(outputFile) + "_page" + pageNumber.ToString()name = Path.ChangeExtension(name, Path.GetExtension(outputFile))Dim pageFile As String = Path.Combine(Path.GetDirectoryName(outputFile), name)' Save this pagemultiPageImage.Page = pageNumberrasterCodecs.Save(multiPageImage, pageFile, format, 0)NextmultiPageImage.Page = originalPageNumberEnd IfEnd SubPublic Shared Sub FormatSupportsMultipageSaveExample()Dim inDir As String = LEAD_VARS.ImagesDirDim outDir As String = Path.Combine(inDir, "FormatSupportsMultipageSave")If Not Directory.Exists(outDir) ThenDirectory.CreateDirectory(outDir)End IfUsing rasterCodecs As New RasterCodecs()' Create a multi-page imageUsing multiPageImage As RasterImage = GetMultipageImage(rasterCodecs, inDir)' Save the image as TIF, this should create a single fileSaveMultiPageFile(rasterCodecs, multiPageImage, Path.Combine(outDir, "out.tif"), RasterImageFormat.Tif)' Save the image as PNG, this should create multiple files (one for each page)SaveMultiPageFile(rasterCodecs, multiPageImage, Path.Combine(outDir, "out.png"), RasterImageFormat.Png)End UsingEnd UsingEnd SubPrivate Shared Function GetMultipageImage(rasterCodecs As RasterCodecs, inDir As String) As RasterImage' Create a multi-page image from some known LEADTOOLS imagesDim multiPageImage As RasterImage = NothingFor imageNumber As Integer = 1 To 4Dim fileName As String = Path.Combine(inDir, "Ocr" + imageNumber.ToString() + ".tif")Dim pageImage As RasterImage = rasterCodecs.Load(fileName, 1)If IsNothing(multiPageImage) ThenmultiPageImage = pageImageElsemultiPageImage.AddPage(pageImage)pageImage.Dispose()End IfNextReturn multiPageImageEnd FunctionPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
|
Products |
Support |
Feedback: FormatSupportsMultipageSave Method - Leadtools.Codecs |
Introduction |
Help Version 19.0.2017.6.16
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.