%%PageItemTitle%%

VectorDraw Web Library

JsPropertiesExtractor Send comments on this topic.
printToImageData Method
See Also  Example
vdWebLibrary Namespace > vdrawObj Class : printToImageData Method
windowFlag
Defines what part of the displayed drawing will be selected for printing. Possible parameters are PRINT_WINDOW_FLAG_EXTENTS, PRINT_WINDOW_FLAG_VIEW, PRINT_WINDOW_FLAG_ORIGINAL.
ScaleFlag
Defines the scale of the area that will be printed on the paper. Possible parameters are PRINT_SCALE_FLAG_FIT, PRINT_SCALE_FLAG_ORIGINAL.
papersizeHINCH
A two sized array defining the width and height of the paper to be used for the print job in hundreds of inches.
MarginHINCH
A number defining the printer's margin on every side of the paper in hundreds of inches.
bkcolor
A four sized array defining the background's color. The first element if for Red, second for Green, third for Blue and fourth for Alpha.
frameWidth
The width of the border defining the paper size in the resulted image data, in pixels.If it is greater than zero(0) then a border will be drawn around the paper with forground color.
resolution
The resolution to be used for the image export. It overrides the printer's resolution.
Returns an array of data that can be used in an image in order to help the user print the drawing using the given parameters.

Syntax

JScript 
public function printToImageData( 
   windowFlag : int,
   ScaleFlag : int,
   papersizeHINCH : Object,
   MarginHINCH : Object,
   bkcolor : Object,
   frameWidth : int,
   resolution : int
) : String;

Parameters

windowFlag
Defines what part of the displayed drawing will be selected for printing. Possible parameters are PRINT_WINDOW_FLAG_EXTENTS, PRINT_WINDOW_FLAG_VIEW, PRINT_WINDOW_FLAG_ORIGINAL.
ScaleFlag
Defines the scale of the area that will be printed on the paper. Possible parameters are PRINT_SCALE_FLAG_FIT, PRINT_SCALE_FLAG_ORIGINAL.
papersizeHINCH
A two sized array defining the width and height of the paper to be used for the print job in hundreds of inches.
MarginHINCH
A number defining the printer's margin on every side of the paper in hundreds of inches.
bkcolor
A four sized array defining the background's color. The first element if for Red, second for Green, third for Blue and fourth for Alpha.
frameWidth
The width of the border defining the paper size in the resulted image data, in pixels.If it is greater than zero(0) then a border will be drawn around the paper with forground color.
resolution
The resolution to be used for the image export. It overrides the printer's resolution.

Return Value

An array of image data in string format.

Example

See also our print dialog example on http://vdraw.com/javascript-examples/print-dialog/
C#Copy Code
var dataUrl = vdcanvas.printToImageData(vdConst.PRINT_WINDOW_FLAG_VIEW, vdConst.PRINT_SCALE_FLAG_FIT, new Array(830, 1170), 10, Array(255, 255, 255, 255), 2); 
  var windowContent = '<!DOCTYPE html>'; 
  windowContent += '<html>' 
  windowContent += '<head><title>Print canvas</title></head>'; 
  windowContent += '<body>' 
  windowContent += '<img src="' + dataUrl + '">'; 
  windowContent += '</body>'; 
  windowContent += '</html>'; 
  var printWin = window.open('', '', 'width=830,height=600,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes'); 
  printWin.document.open(); 
  printWin.document.write(windowContent); 
  printWin.document.close(); 
  printWin.focus();

See Also