public class CodecsLoadSvgOptions
@interface LTCodecsLoadSvgOptions : NSObject<NSCopying, NSSecureCoding>
public class CodecsSvgLoadOptions
public ref class CodecsLoadSvgOptions
class CodecsLoadSvgOptions:
The CodecsLoadSvgOptions is used with the following methods:
RasterCodecs.LoadSvg(string fileName, int pageNumber, CodecsLoadSvgOptions options)
RasterCodecs.LoadSvg(Stream stream, int pageNumber, CodecsLoadSvgOptions options)
Task<bool> LoadSvgAsync(ILeadStream stream, int pageNumber, CodecsLoadSvgOptions options)
RasterCodecs.LoadSvgAsync(Uri uri, int pageNumber, CodecsLoadSvgOptions options, object userState)
For more information, refer to Working With SVG.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
public void CodecsLoadSvgOptionsExample()
{
// The source PDF file
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf");
// SVG sort callback handler
SvgSortElementsCallback sortCallback = (callabackDocument, info, userData) =>
{
// Is it text?
SvgTextData textData = info.TextData;
if (textData != null)
{
// Yes, print it to the console
Console.Write(textData.Text + " ");
// See if its end of line
var len = textData.Text.Length;
if ((textData.CharacterFlags[len - 1] & SvgTextCharacterFlags.EndOfLine) == SvgTextCharacterFlags.EndOfLine)
Debug.WriteLine(" ");
}
return true;
};
using (var codecs = new RasterCodecs())
{
// Set 300 as the default value for loading document files
codecs.Options.RasterizeDocument.Load.Resolution = 300;
// get the number of pages
int pageCount = codecs.GetTotalPages(srcFileName);
for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++)
{
// Load this page as SVG, we are interested in the text only so
// we will ask LEADTOOLS to skip other elements
CodecsLoadSvgOptions loadSvgOptions = new CodecsLoadSvgOptions();
loadSvgOptions.DropText = false;
loadSvgOptions.DropImages = true;
loadSvgOptions.DropShapes = true;
using (SvgDocument svgDocument = codecs.LoadSvg(srcFileName, pageNumber, loadSvgOptions) as SvgDocument)
{
// Sort requires a flat document, so check for that
if (!svgDocument.IsFlat)
svgDocument.Flat(null);
if (!svgDocument.Bounds.IsValid)
svgDocument.CalculateBounds(false);
SvgSortOptions sortOptions = new SvgSortOptions();
sortOptions.ExtractText = SvgExtractText.Word;
sortOptions.SortFlags = SvgSortFlags.Default;
Debug.WriteLine("Text for page {0}", pageNumber);
svgDocument.SortElements(sortOptions, sortCallback, null);
Debug.WriteLine("-------------");
}
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document