如何在Flash CS3中动态设置打印页边距

发布于 2024-08-09 10:51:44 字数 1020 浏览 10 评论 0原文

//我可以通过定义一个矩形并为其指定以下尺寸来获得右边距:

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 正确放置在页面上。这是 Adob​​e 帮助提供的全部内容。还用谷歌搜索并尝试了不同的变体,但没有成功。有人可以帮忙吗?

预先感谢您对此的任何见解。

安妮

//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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自在安然 2024-08-16 10:51:44

您可以稍微澄清一下这个问题,因为有点不清楚您想要实现的目标......如果我理解正确,您可能想在较大的纸张中间打印一些内容。

只有调用 PrintJob.start() 因此您必须在此之后定义 printArea 参数。由于 printArea 定义了一个相对于要打印的 DisplayObject 的矩形,为了使 DisplayObject 居中,您必须确保 DisplayObject 位于矩形的中心;

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();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文