node-i2djs
  • Introduction to node-i2djs
  • Getting Started
    • Installation
    • Quick Start CanvasLayer
    • Quick Start Canvas PDF Layer
    • Examples
  • API Reference
    • canvasLayer
    • canvasPdfLayer
    • Element API
    • Textures
    • Path
    • Join Action
  • Guide
    • Element types
    • Data Join-Actions
    • Canvas: Textures & Sprite animation
    • Canvas: Clipping, Masking, Pattern
Powered by GitBook
On this page
  • Layer API:
  • Layer Methods:
  • PageInstance API:
  1. API Reference

canvasPdfLayer

Layer API:

#.canvasPdfLayer( contextObject, height, width);

canvasPdfLayer API return rendering instance of Canvas-2D context. It accepts multiple parameters as specified below.

Example:

var pdfLayerInstance = canvasPdfLayer(contextAttrObject, height, width);
  • contextAttrObject - Canvas context attributes, which will be passed to the getContext method.

  • height: height of the PDF page

  • width: width of the PDF page

Layer Methods:

Layer.addPage()

Layer.exportPdf()

Layer.data()

PageInstance API:

pageInstance.setLayerId( String ) - For setting ID attribute to the Layer Dom element.

pageInstance.setClear( function ) - To set clear callback method. Accepts function as an input, which gets invoked on every refresh Cycle before render begins. The clear function gets context as an argument.

renderer_.setClear(function (ctx) {
		ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
		ctx.fillRect(0, 0, renderer_.width, renderer_.height);
	});

pageInstance.SetPixelRation( Int ); - To set device Pixel ratio.

pageInstance.SetSize( width, height ); - Optional - To set the Size of the canvas layer. If not, the parent container size will be inherited by the layer.

pageInstance.getPixels( x, y, width, height ); - To fetch pixels from the specified rectangle area of the canvas layer. It returns the ImageData object.

pageInstance.putPixels( imageData, x, y ); - To paint pixels to the canvas. It accepts ImageData along with position x, y as an argument.

pageInstance.clear( ); - To clear the canvas. It can be invoked in some special cases to clear the canvas.

pageInstance.setContext( prop, value ); - To set properties to the canvas context.

pageInstance.update( ); - To manually trigger the Layer update. In the case of the default behaviour, all the changes from VDOM will be applied to the DOM as a part of the refresh cycle.

pageInstance.destroy( ); - To remove layer instance. It removes the DOM element along with the vDOM. and Also unbinds all the event listeners is any.

PreviouscanvasLayerNextElement API

Last updated 2 years ago