从AIR / Flex应用程序打印会导致被发送到打印机的大文件 [英] Printing from AIR/Flex application causes large files being sent to printer

查看:135
本文介绍了从AIR / Flex应用程序打印会导致被发送到打印机的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Adobe AIR(2.0)应用程序,包含一项功能,允许用户打印文档(如工资单)。这些文件原本是PDF格式。由于情况下,我们不能直接显示(使用flash.html.HTMLLoader例如)在AIR应用程序的PDF文件。因此,我们转换PDF文件到主权财富基金(使用用pdf2swf工具,请参阅 http://www.swftools.org/ )。主权财富基金被加载到使用mx.controls.SWFLoader,像这样的应用程序:

I am working on an Adobe AIR (2.0) application that contains a feature to allow users to print documents (such as salary slips). Those documents are originally in PDF format. Due to circumstances we cannot directly display those PDFs in the AIR application (for example using flash.html.HTMLLoader). Therefore we convert the PDFs to SWFs (using the pdf2swf tool, see http://www.swftools.org/). The SWFs are loaded into the application using a mx.controls.SWFLoader, like so:

<mx:SWFLoader
        id="salarySlipImage"
        loaderContext="{someLoaderContext}"
        trustContent="true"
        maintainAspectRatio="true"
        scaleContent="true"
        source="{salarySlip.swf}" />

在这里salarySlip.swf是包含SWF内容的ByteArray。

where salarySlip.swf is a ByteArray containing the SWF's content.

接下来,我们有一个启动FlexPrintJob,像这样的一个按钮:

Next, we have a button that starts a FlexPrintJob, like so:

<mx:Button label="Print" click="print()" />

public function print():void {
    var printJob:FlexPrintJob = new FlexPrintJob();

    if (printJob.start() != true) {
        return;
    }

    printJob.addObject(salarySlipImage, FlexPrintJobScaleType.MATCH_HEIGHT);
    printJob.send();
}

本作品pretty的好(文件滚滚来了打印机,很好看),但我注意到,正在发送到打印机的文件,有时会变得非常大,像> 100MB (!!!),这可能需要相当长的一段时间才能到达打印机,如> 30岁(显然取决于连接到打印机的速度)。原来PDF文件大约150KB和100KB左右主权财富基金。

This works pretty well (documents come rolling out the printer and look good), although I've noticed that the files that are being sent to the printer can sometimes become very big, like > 100MB (!!!), which can take quite some time to reach the printer, like > 30s (obviously depending on the speed of the connection to the printer). The original PDFs are around 150KB and the SWFs around 100KB.

使用mx.printing的Flex的API进行打印时,没有任何人有类似的问题?如果是这样,我怎么能解决这个问题?

Does anyone have similar issues when printing using the mx.printing Flex APIs? If so, how can I fix this?

最好的问候,
鲍勃·

Best regards,
Bob

推荐答案

尝试使用这一点; 它减少了我的大小的PrintJob了很多。 不过我不知道,如果它能够更小..因此,如果任何人有更多的建议,请与我们分享。 printJob.printAsBitmap = FALSE;

Try using this; It reduced my printjobs size a lot. Still i wonder if it can be even smaller.. so if anyone has more suggestions, please share it with us. printJob.printAsBitmap=false;

var printJob:FlexPrintJob = new FlexPrintJob();
printJob.printAsBitmap=false;

if (printJob.start() != true) {
        return;
    }

    printJob.addObject(salarySlipImage, FlexPrintJobScaleType.MATCH_HEIGHT);
    printJob.send();
}

这篇关于从AIR / Flex应用程序打印会导致被发送到打印机的大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆