Flex 4 动态组件打印错误

发布于 2024-12-05 12:40:54 字数 895 浏览 9 评论 0原文

我有一组动态添加到我的 Flex 4 阶段的组件。

问题一: 将这些对象添加到打印时如何处理这些对象。我无法动态生成对象并附加它们,因为打印管理器不会等待动态数据填充。

我目前使用以下代码来动态处理失败的项目:

public function PrintDashPreview():void{
    var ItemsDrawn:int = 0;
    var printJob:FlexPrintJob = new FlexPrintJob();
    if(printJob.start()){
        for each (var item:Object in GetDashBoardPreviewItems.lastResult.DashboardItem)
        {
            ItemsDrawn ++
            this.addElement(dashPreview["flexShape" + TheID]);
            printJob.addObject(dashPreview["flexShape" + TheID]);
            this.removeElement(dashPreview["flexShape" + TheID]);

        }
        printJob.send()

    Alert.show('Sent: ' + ItemsDrawn + ' items to page for printing.','Print Progress Debug');
    }
}

如何告诉 Flex 获取这些特定项目并将它们添加到打印作业中。

问题 2:

我如何告诉 flex 将每页的每个项目放在另外 2 个项目的下面。

请并感谢您提供的任何帮助。

问候 克雷格·麦克

I have a set of components that are added to my Flex 4 stage dynamically.

Problem 1:
How do I address these objects when adding them to print.I cant generate objects on the fly and append them because then the print manager does not wait for the dynamic data to populate.

I currently use the following code to address items dynamically which fails:

public function PrintDashPreview():void{
    var ItemsDrawn:int = 0;
    var printJob:FlexPrintJob = new FlexPrintJob();
    if(printJob.start()){
        for each (var item:Object in GetDashBoardPreviewItems.lastResult.DashboardItem)
        {
            ItemsDrawn ++
            this.addElement(dashPreview["flexShape" + TheID]);
            printJob.addObject(dashPreview["flexShape" + TheID]);
            this.removeElement(dashPreview["flexShape" + TheID]);

        }
        printJob.send()

    Alert.show('Sent: ' + ItemsDrawn + ' items to page for printing.','Print Progress Debug');
    }
}

How can I tell flex to grab these specific items and add them to the print job.

Problem 2:

How do I tell flex to lay each item out one below the other 2 per page.

Please and thank you for any help you can provide.

Regards
Craig Mc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

oО清风挽发oО 2024-12-12 12:40:54

打印动态内容的方法通常是这样的:

(1) 启动打印作业:

printJob = new FlexPrintJob();
printJob.printAsBitmap = false;
printJob.start();

(2) 获取打印页面尺寸。如果内容溢出,请使用它:

printerPageHeight = printJob.pageHeight;
printerPageWidth = printJob.pageWidth;

(3) 创建所有动态对象并等待相应的 CREATION_COMPLETE 事件:

var componentsToBeInitialized:Number = 0;
var pages:Array = [];
for each (var itemData:Object in dataProvider) {
    var component:UIComponent = new PageComponent();
    someContainerOnTheDisplayList.addChild(component);
    component.data = itemData;
    componentsToBeInitialized ++;
    pages.push(component);
    component.addEventListener(FlexEvent.CREATION_COMPLETE, handlePageCompletion);
}

(4) 等待所有 CREATION_COMPLETE 事件:

function handlePageCompletion(e:Event):void {
    componentsToBeInitialized --;
    if (componentsToBeInitialized == 0)
        printAllPages();
}

(5 ) 打印页面:

function printAllPages():void {
   for each (var printPage:UIComponent in pages) {
   printJob.addObject(printPage);
   }         
   printJob.send();
}

The recipe for printing dynamic content usually goes like this:

(1) Start the printJob:

printJob = new FlexPrintJob();
printJob.printAsBitmap = false;
printJob.start();

(2) Obtain the print page dimensions. Use it if you have overflowing content:

printerPageHeight = printJob.pageHeight;
printerPageWidth = printJob.pageWidth;

(3) Create all of the dynamic objects and wait for the corresponding CREATION_COMPLETE events:

var componentsToBeInitialized:Number = 0;
var pages:Array = [];
for each (var itemData:Object in dataProvider) {
    var component:UIComponent = new PageComponent();
    someContainerOnTheDisplayList.addChild(component);
    component.data = itemData;
    componentsToBeInitialized ++;
    pages.push(component);
    component.addEventListener(FlexEvent.CREATION_COMPLETE, handlePageCompletion);
}

(4) Waiting for all CREATION_COMPLETE events:

function handlePageCompletion(e:Event):void {
    componentsToBeInitialized --;
    if (componentsToBeInitialized == 0)
        printAllPages();
}

(5) Print the pages:

function printAllPages():void {
   for each (var printPage:UIComponent in pages) {
   printJob.addObject(printPage);
   }         
   printJob.send();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文