Asynchronously loads a page from a stream containing an image, document or vector file as SVG.
publicstatic任务<ISvgDocument> LoadSvgAsync(
thisRasterCodecsrasterCodecs,
ILeadStreamstream,
intpageNumber,
CodecsLoadSvgOptionsoptions
)
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.
ATask
that represents the asynchronous operation.TResult
: The SVG document representation of the page.
This topic is part ofRasterCodecs
support for .NETasync/await
support. 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.
This example will load a page from a URL as SVG:
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 file
stringaddress =@"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 files
codecs.Options.RasterizeDocument.Load.Resolution = 300;
// Create an ILeadStream object to the URI
using(ILeadStream leadStream = await LeadStream.Factory.FromUri(uri))
{
// Load the first page as SVG
using(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 size
if(!svgDocument.Bounds.IsValid)
svgDocument.CalculateBounds(false);
Console.WriteLine("Bounds: {0}", svgDocument.Bounds.Bounds);
svgDocument.Dispose();
}
}
}
}
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 PlatformsHelp Collections
Raster.NET|CAPI|C++ Class Library|HTML5 JavaScript
Document.NET|CAPI|C++ Class Library|HTML5 JavaScript
Medical.NET|CAPI|C++ Class Library|HTML5 JavaScript
Medical Web Viewer.NET
188宝金博怎么下载
Media Foundation.NET|CAPI|Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
CAPI/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
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.