←Select platform

Bounds Property

Summary
Gets or sets the physical bounds, in pixels, of this SVG document.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public LeadRectD Bounds { get; set; } 
@property (nonatomic, assign) LeadRectD bounds; 
public LeadRectD getBounds() 
public void setBounds(LeadRectD bounds) 
public: 
property LeadRectD Bounds { 
   LeadRectD get(); 
   void set (    LeadRectD ); 
} 
Bounds # get and set (SvgBounds) 

Property Value

The physical bounds, in pixels, of this SVG document.

Remarks

This property is set to the calculated bounds in physical units (pixels) by SvgDocument.CalculateBounds.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.Forms.DocumentWriters; 
using Leadtools.Svg; 
 
using Leadtools.Document.Writer; 
 
public void SvgDocumentExample() 
{ 
   // input directory 
   string inDir = LEAD_VARS.ImagesDir; 
   // output directory 
   string outDir = Path.Combine(LEAD_VARS.ImagesDir, "svgpages"); 
   if (!Directory.Exists(outDir)) 
      Directory.CreateDirectory(outDir); 
 
   using (var codecs = new RasterCodecs()) 
   { 
      // Set 300 as the default value for loading document files 
      codecs.Options.RasterizeDocument.Load.Resolution = 300; 
 
      codecs.ThrowExceptionsOnInvalidImages = false; 
 
      // Get all the files from input directory 
      foreach (var srcFileName in Directory.EnumerateFiles(inDir)) 
      { 
         Console.WriteLine("Checking {0}", srcFileName); 
         using (var info = codecs.GetInformation(srcFileName, false)) 
         { 
            // We can load as SVG if its document or vector (skipping SVG files themselves) 
            if (info.Format != RasterImageFormat.Unknown && // valid format 
               info.Format != RasterImageFormat.Svg && // not svg 
               (info.Document.IsDocumentFile || // a document 
               info.Vector.IsVectorFile)) // or vector 
            { 
               // try to load the first page as SVG 
               try 
               { 
                  using (SvgDocument svgDocument = codecs.LoadSvg(srcFileName, 1, null) as SvgDocument) 
                  { 
                     // Save it to disk 
                     string name = Path.GetFileName(srcFileName).Replace(".", "-"); 
                     name = Path.ChangeExtension(name, "svg"); 
                     string dstFileName = Path.Combine(outDir, name); 
                     Console.WriteLine("Saving to {0}", dstFileName); 
                     svgDocument.SaveToFile(dstFileName, null); 
                  } 
               } 
               catch (Exception ex) 
               { 
                  Console.WriteLine(ex.Message); 
               } 
            } 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Svg Assembly

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