如何在Flash CS3中动态设置打印页边距
//我可以通过定义一个矩形并为其指定以下尺寸来获得右边距:
var rect1:Rectangle = new Rectangle(0, 0, 792,612);
//当按下打印按钮时,以下代码将使用 rect1 定义的尺寸执行:
prntCover_btn.addEventListener(MouseEvent.CLICK, printCover);
function printCover(evt:MouseEvent):void {
front_mc.visible = false;
var myPrintJob:PrintJob = new PrintJob();
var options:PrintJobOptions = new PrintJobOptions();
options.printAsBitmap = true;
front_mc.scaleX = 1;
front_mc.scaleY = 1;
myPrintJob.start();
myPrintJob.addPage(front_mc, rect1, options);
myPrintJob.send();
}
//USpaper 是 792 = 11.5 英寸宽的纸张。想要使用 A3 尺寸,所以我在 myPrintJob.start(); 行之后执行了此操作
var margin_height:Number = (myPrintJob.paperHeight - myPrintJob.pageHeight)/2;
var margin_width:Number = (myPrintJob.paperWidth - myPrintJob.pageWidth)/2;
这无法将 mc 正确放置在页面上。这是 Adobe 帮助提供的全部内容。还用谷歌搜索并尝试了不同的变体,但没有成功。有人可以帮忙吗?
预先感谢您对此的任何见解。
安妮
//I can get the right margins by defining a rectangle and giving it the following dimensions:
var rect1:Rectangle = new Rectangle(0, 0, 792,612);
//When the print button is pressed the following code executes using the dimensions defined by rect1:
prntCover_btn.addEventListener(MouseEvent.CLICK, printCover);
function printCover(evt:MouseEvent):void {
front_mc.visible = false;
var myPrintJob:PrintJob = new PrintJob();
var options:PrintJobOptions = new PrintJobOptions();
options.printAsBitmap = true;
front_mc.scaleX = 1;
front_mc.scaleY = 1;
myPrintJob.start();
myPrintJob.addPage(front_mc, rect1, options);
myPrintJob.send();
}
//U.S.paper is 792 = 11.5 inch wide paper. Would like to use A3 size so I did this after the line myPrintJob.start();
var margin_height:Number = (myPrintJob.paperHeight - myPrintJob.pageHeight)/2;
var margin_width:Number = (myPrintJob.paperWidth - myPrintJob.pageWidth)/2;
This is not working to place the mc correctly on the page. This is all the Adobe help provides. Also Googled and tried different variations but no success. Can anyone help?
Thanks in advance for any insight into this.
Annie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以稍微澄清一下这个问题,因为有点不清楚您想要实现的目标......如果我理解正确,您可能想在较大的纸张中间打印一些内容。
只有调用
PrintJob.start()
因此您必须在此之后定义printArea
参数。由于printArea
定义了一个相对于要打印的 DisplayObject 的矩形,为了使 DisplayObject 居中,您必须确保 DisplayObject 位于矩形的中心;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 theprintArea
parameter after that. As theprintArea
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;