This module exports front_screenshot, which includes the methods detailed below, plus bundled builds of HTML2Canvas and Canvg
Sets the default options.
Parameters
options
FSOptions The options
Returns FSOptions options with default properties set
The options that can be passed to every method. Not all of them are needed nor used on every function
Type: Object
Properties
quality
Number? level of quality (higher is better) of the image to generateselector
string? Cash/jQuery selector on which to operate e.g. 'svg', '.canvg'adjust_styles
boolean? if true, sets the styles for typical c3 graphicsuseCORS
boolean? tell html2canvas to try to use CORS on external URLsallowTaint
boolean? either to allow or not tainted objectslogging
Boolean? if true, log the results of html2canvas or canvgclone
boolean? if true, clone the node either to adjust styles or to capture with html2canvasignoreMouse
boolean? if true, canvg will ignore mouse eventsignoreAnimation
boolean? if true, canvg will ignore svg animationshideSVG
boolean? if true, hide the svg selector after canvg has converted it to image or canvas
Adjust common C3 styles to avoid distorted images. This function won't modify
elements with class keepstyle
not its children
Parameters
jqContainer
(Cash | jQuery | HTMLElement) The SVG element on which to apply the modificationsopts
FSOptions The options, in particular, it will check ifclone
is true
Returns (Cash | jQuery) a clone of the original svg element with modified styles
Wrapper around html2canvas to accept either a DOMNode or a Cash/jQuery selector
Parameters
jqContainer
(HTMLElement | Cash | jQuery) The elementoptions
FSOptions The options
Returns HTMLCanvasElement Canvas element
Takes a jQuery container, finds its contained SVG, transforms it into a canvas
Parameters
jqContainer
(HTMLElement | Cash | jQuery) container of an SVG element to transform into canvasoptions
FSOptions options to pass to canvg
Returns Promise<HTMLCanvasElement> a promise that unfolds to a Canvas element
Takes a jQuery container, finds its contained SVG, transforms it into an image
Parameters
jqContainer
(HTMLElement | Cash | jQuery) container of an SVG element to transform into imageoptions
FSOptions? options
Returns Promise<HTMLImageElement> a promise than resolves to an Image element
hiddenClone
Creates a hidden clone of a Cash/jQuery selector and appends it to the screen (allows to capture sections that are hidden due to scrolling behavior)
Parameters
jqContainer
(HTMLElement | Cash | jQuery) The Cash/jQuery selector of the original container
Returns HTMLElement the DOM node of the clone
Given a jQuery container, takes a screenshot of it and returns it as an HTMLCanvasElement (it can capture the container contents even if they are hidden due to overlay hidden, auto or scroll CSS properties)
Parameters
jqContainer
(HTMLElement | Cash | jQuery) Cash/jQuery selector of the element to transform into canvasoptions
FSOptions? options to pass to canvg and html2canvas
Returns Promise<HTMLCanvasElement> a promise that unfolds to a HTMLCanvasElement
Transforms all contents of selector
nodes found in jqContainer
from SVG to images with classname .temporary_element
. Original SVG element is hidden
Parameters
jqContainer
(HTMLElement | Cash | jQuery) Cash/jQuery selector that contains N nodes with the specified selectorselector
string a CSS selector like.className
or#id
Transforms all contents of selector
nodes found in jqContainer
from SVG to canvases with classname .temporary_element
. Original SVG element is hidden
Parameters
jqContainer
(HTMLElement | Cash | jQuery) Cash/jQuery selector that contains N nodes with the specified selectorselector
string a CSS selector like.className
or#id
Removes all childs from selector
nodes found in jqContainer
removing elements with classname .temporary_element
and showing the original SVG
Parameters
jqContainer
(HTMLElement | Cash | jQuery) Cash/jQuery selector that contains N nodes with the specified selectorselector
string a CSS selector like.className
or#id