getSvgBackImageElement Method

Summary

Gets an HTML Element representing the raster image for this page.

Syntax

JavaScript Syntax
DocumentPage.prototype.getSvgBackImageElement = function(backColor, imageLoader) 
TypeScript Syntax
getSvgBackImageElement(backColor: string, imageLoader: ImageLoader): JQueryPromise<any>; 

Parameters

backColor

Color to use to fill the background of the image.

imageLoader

An optional ImageLoader instance to use instead of the internally-created one.

Return Value

A Promise object that may resolve successfully to an HTML Element. If IsSvgSupported is false, the request and Promise object will fail. If the SVG for this page contains no background images, the request and Promise object will return a 1x1 transparent GIF image.

Remarks

To only get the URL instead of loading the image, see GetSvgBackImageUrl.

Not all document types support this method; if IsSvgSupported is false, an error will be returned from the service. Otherwise, a new image is created and filled with backColor (if its not a transparent color). Then, the SVG data containing only the image elements is rendered on the surface of this image. The resulting raster image is the same size as the DocumentPage.

If the SVG page has no image elements, a transparent 1x1 GIF image is returned in order to send minimal data while keeping the request a success. The user can check the naturalWidth and naturalHeight values for the result to verify that this has occurred: each should be 1. If working with the ImageViewer, the user may wish to check for these values before adding to the BackImage property, so as to not have a transparent background for no reason. Internal loading through BackImageUrl does this same check.

This method can work in conjunction with GetSvgUrl or GetSvgElement to return the background images for an SVG as a separate raster image while keeping any text or other objects as SVG. This method is used in the LEADTOOLS Document Viewer.

If the value of ImageScale is a value greater than 1, then the result image will have a size that is equal to Size / ImageScale.

This method takes an optional imageLoader parameter for additional image load configuration. If an ImageLoader is provided, Run will not be called and it is the responsibility of the application to call it when needed. If an ImageLoader is not supplied, one is created internally and Run is called before this method exits. See Documents Image Loading for more information.

This request can pass arbitrary user data through ServiceUserData.

Refer to Image Loading Using LEADTOOLS Documents Library and Document Loading Using LEADTOOLS Documents Library for more information.

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Documents Assembly