Gets or sets a value that indicates whether the image elements of the SVG should be dropped during load.
public bool DropImages {get; set;} Public Property DropImages As Boolean public bool DropImages {get; set;} @property (nonatomic, assign) BOOL dropImages public boolean getDropImages()public void setDropImages(boolean value)
get_DropImages();set_DropImages(value);Object.defineProperty('DropImages');
true if image elements of the SVG should be dropped during load, otherwise; false. Default value is false.
Creating an SVG document with text only is desired in certain scenarios. For example, if the application loads SVG document to parse the text values and store them in an external database for text search purposes, then setting the value of DropImages and DropShapes to true while leaving DropText as false will speed up the loading operation and elements not required will be discarded. This is especially useful if the original SVG document contains image elements which may use a lot of memory and disk space.
This example will parse the text found in a PDF document and write it to the console.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;public static void CodecsLoadSvgOptionsExample(){// The source PDF filestring srcFileName = Path.Combine(ImagesPath.Path, "Leadtools.pdf");// SVG sort callback handlerSvgSortElementsCallback sortCallback = (callabackDocument, info, userData) =>{// Is it text?SvgTextData textData = info.TextData;if (textData != null){// Yes, print it to the consoleConsole.Write(textData.Text + " ");// See if its end of linevar len = textData.Text.Length;if ((textData.CharacterFlags[len - 1] & SvgTextCharacterFlags.EndOfLine) == SvgTextCharacterFlags.EndOfLine)Console.WriteLine();}return true;};using (var codecs = new RasterCodecs()){// Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300;// get the number of pagesint 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 elementsCodecsLoadSvgOptions 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 thatif (!svgDocument.IsFlat)svgDocument.Flat(null);if (!svgDocument.Bounds.IsValid)svgDocument.CalculateBounds(false);SvgSortOptions sortOptions = new SvgSortOptions();sortOptions.ExtractText = SvgExtractText.Word;sortOptions.SortFlags = SvgSortFlags.Default;Console.WriteLine("Text for page {0}", pageNumber);svgDocument.SortElements(sortOptions, sortCallback, null);Console.WriteLine("-------------");}}}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPublic Shared Sub CodecsLoadSvgOptionsExample()' The source PDF fileDim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")' SVG sort callback handlerDim sortCallback As SvgSortElementsCallback =Function(document As SvgDocument, info As SvgElementInfo, userData As Object) As Boolean' Is it text?Dim textData As SvgTextData = info.TextDataIf Not IsNothing(textData) Then' Yes, print it to the consoleConsole.Write(textData.Text + " ")' See if its end of lineDim len As Integer = textData.Text.LengthIf (textData.CharacterFlags(len - 1) And SvgTextCharacterFlags.EndOfLine) = SvgTextCharacterFlags.EndOfLine ThenConsole.WriteLine()End IfEnd IfReturn TrueEnd FunctionUsing codecs As New RasterCodecs()' Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300' get the number of pagesDim pageCount As Integer = codecs.GetTotalPages(srcFileName)For pageNumber As Integer = 1 To pageCount' Load this page as SVG, we are interested in the text only so' we will ask LEADTOOLS to skip other elementsDim loadSvgOptions As New CodecsLoadSvgOptions()loadSvgOptions.DropText = FalseloadSvgOptions.DropImages = TrueloadSvgOptions.DropShapes = TrueUsing svgDocument As SvgDocument = DirectCast(codecs.LoadSvg(srcFileName, pageNumber, Nothing), SvgDocument)' Sort requires a flat document, so check for thatIf Not svgDocument.IsFlat ThensvgDocument.Flat(Nothing)End IfIf Not svgDocument.Bounds.IsValid ThensvgDocument.CalculateBounds(False)End IfDim sortOptions As New SvgSortOptions()sortOptions.ExtractText = SvgExtractText.WordsortOptions.SortFlags = SvgSortFlags.DefaultConsole.WriteLine("Text for page {0}", pageNumber)svgDocument.SortElements(sortOptions, sortCallback, Nothing)Console.WriteLine("-------------")End UsingNextEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
|
Products |
Support |
Feedback: DropImages Property - 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.