Introduction Interfaces Buy Support More ActiveX Site Home

ActivePrinter --- Sample: Picture and Clip Path


JavaScript Codes
Open printer. You must replace the printer name with that of your printer
var PRN=new ActiveXObject("ActivePrinter.Printer");
PRN.OpenPrinter("Adobe PDF", 1, true);
PRN.BeginPrint("photo");
PRN.BeginPage();

Layout
var pw=PRN.GetPageWidth();
var ph=PRN.GetPageHeight();
var margin=30;

Get a heart shape from the "Webdings" font
var pts=PRN.CreatePoints();
pts.GetFontPoints(89, 1, "Webdings");
var r=(ph-margin*2)/pts.GetWidth();
pts.Scale(r, r);
pts.AlignTo(pw/2, ph/2, 9);

Open a picture file
var path=PRN.FileDlg(true, "Image Files|*.jpg;*.tiff||");
var img=PRN.LoadImage(path);

Use the heart outline as clip path and draw the picture
PRN.SelectClipPath(pts);
img.Draw(pw/2, ph/2, 9);
PRN.SelectClipPath();

Stroke the outline
var pen=PRN.CreatePen();
pen.SetColor("255, 0, 255");
pen.SetStyle("dot");
pen.SetWidth(2);
pen.Draw(pts, "C");
PRN.EndPage();
PRN.EndPrint();