How to dynamically set print page margins in Flash CS3

六月ゝ 毕业季﹏ 提交于 2019-12-04 21:02:49

You could clarify the question a bit because it is a bit unclear what you're trying to achieve... if I understood correctly, you probably want to print something in the middle of a larger paper.

You can get the paper size the user chose only after calling PrintJob.start() so you'll have to define the printArea parameter after that. As the printArea defines a rectangle relative to the DisplayObject being printed, in order to center the DisplayObject you'll have to make sure that the DisplayObject is in the center of the rectangle;

var myPrintJob:PrintJob = new PrintJob();
var options:PrintJobOptions = new PrintJobOptions();
options.printAsBitmap = true;
front_mc.scaleX = 1;
front_mc.scaleY = 1;
myPrintJob.start();

var marginWidth:Number = (myPrintJob.pageWidth - front_mc.width) / 2;
var marginHeight:Number = (myPrintJob.pageHeight- front_mc.height) / 2;
var rect:Rectangle = new Rectangle(-marginWidth, -marginHeight, myPrintJob.pageWidth, myPrintJob.pageHeight);

myPrintJob.addPage(front_mc, rect1, options);
myPrintJob.send();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!