←Select platform

LoadSvgAsync(RasterCodecs,ILeadStream,int,CodecsLoadSvgOptions) Method

Summary

Asynchronously loads a page from a stream containing an image, document or vector file as SVG.

Syntax
C#

Parameters

rasterCodecs

RasterCodecsobject to perform the operation.

stream

The stream containing the image data to load.

pageNumber

The 1-based page number.

options

The options used for loading SVG. This can benull.

Return Value

ATaskthat represents the asynchronous operation.TResult: The SVG document representation of the page.

Remarks

This topic is part ofRasterCodecssupport for .NETasync/awaitsupport. Refer toRasterCodecs Async Operationsfor more information.

Use this method to load a page from any supported image, document or vector file as SVG (Scalable Vector Graphics). For more information referLoadSvg(string fileName, int pageNumber, CodecsLoadSvgOptionsOptions).

To determine whether a file or stream can be loaded as SVG, useCanLoadSvgAsync.

To load as SVG from a file or stream directly, useLoadSvg.

For more information, refer toWorking With SVG.

Example

This example will load a page from a URL as SVG:

C#
usingLeadtools;usingLeadtools.Codecs;usingLeadtools.ImageProcessing;usingLeadtools.ImageProcessing.Color;usingLeadtools.Svg;publicasyncvoidLoadSvg_AsyncExample(){// For .NET Framework: Add a reference to Leadtools.Async to get the async support as extension methods// For .NET Standard: async support is included.// Address of a document thats supports loading as SVG, for example, a PDF filestringaddress =@"https://demo.leadtools.com/images/pdf/leadtools.pdf";Uri uri =newUri(address);using(RasterCodecs codecs =newRasterCodecs ()){// Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300;// Create an ILeadStream object to the URIusing(ILeadStream leadStream = await LeadStream.Factory.FromUri(uri)){// Load the first page as SVGusing(ISvgDocument svg = await codecs.LoadSvgAsync(leadStream, 1,null)){Console.WriteLine("Loading from {0} is done", uri);// Cast the generic ISvgDocument interface it to SvgDocument so we can use it.SvgDocument svgDocument = svgasSvgDocument;// Show its sizeif(!svgDocument.Bounds.IsValid)svgDocument.CalculateBounds(false);Console.WriteLine("Bounds: {0}", svgDocument.Bounds.Bounds);svgDocument.Dispose();}}}}
Requirements

For .NET Framework: A reference to theLeadtools.Async.dllassembly is required to use this functionality.

For .NET Standard: This functionality is included in theLeadtools.Codecs.dllassembly.

Target Platforms
Leadtools.Codecs Assembly
188金宝搏的网址客服|Support|Contact Us|Intellectual Property Notices
© 1991-2021LEAD Technologies, Inc.All Rights Reserved.