本文介绍了如何在Flash CS3中动态设置打印页边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var rect1:Rectangle 

//我可以通过定义一个矩形并给出以下维度来获得正确的边距: = new Rectangle(0,0,792,612);

//当按下打印按钮时,下面的代码使用rect1定义的尺寸执行: p>

  prntCover_btn.addEventListener(MouseEvent.CLICK,printCover); 

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

}

//美国纸是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提供的所有帮助。也谷歌和尝试不同的变化,但没有成功。谁能帮忙?

在此先感谢您对此的深入了解。

Annie 解决方案

有点不清楚你想要达到什么目标...如果我理解正确,你可能想要在一个更大的纸上打印一些东西。



你可以获取用户仅调用,所以你必须在这之后定义 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();


//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

解决方案

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

这篇关于如何在Flash CS3中动态设置打印页边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:19