←Select platform

DropShapes Property

Summary
Gets or sets a value that indicates whether any element that is not text or image in the SVG should be dropped during load.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool DropShapes { get; set; } 
@property (nonatomic, assign) BOOL dropShapes; 
public boolean getDropShapes() 
public void setDropShapes(boolean value) 
public: 
property bool DropShapes { 
   bool get(); 
   void set (    bool ); 
} 
DropShapes # get and set (CodecsLoadSvgOptions) 

Property Value

Value Description
true To drop non-image and non-text elements of the SVG document during load.
false To keep non-image and non-text elements of the SVG document during load, if any. false is the default value.
Remarks

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.

Example
C#
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"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.