2011-02-28 63 views
2

我目前正在使用Adobe AIR应用程序来显示用户一些图形数据。由于这些数据更适合屏幕高度,因此我将它放在滚动条内。Flex 4中的滚动条内打印内容

现在我想打印一下这个可视化数据,主要是一些图表和列表,但我只看到一个页面,其中只包含当前用户可见的部分屏幕。我希望将滚动条内的全部内容显示在页面上。

我尝试使用PrintJob和FlexPrintJob,但无法找到解决办法。任何人都可以通过提供一个洞察力来帮助我,一些源代码将不胜感激。

期待您的回复,

感谢

回答

3

显然这是一个已知的bug与Flex印刷库和滚轮控制。您可以在此阅读这里我的讨论: http://forums.adobe.com/message/3626759

作为一种变通方法,我做了以下内容:

var printer:FlexPrintJob = new FlexPrintJob(); 

// Display the print dialog to the user. If they choose a printer 
// and click "print", this method will return true, and we will 
// spool the job to the printer they selected. If they hit cancel, 
// this method will return false, and we will not attempt to send 
// anything to the printer. 
if(printer.start()){ 
    // Add some padding before spooling the object to the printer. 
    // This will give it a reasonable margin on the printout. 
    itemsToPrintContainer.paddingBottom = 100; 
    itemsToPrintContainer.paddingTop = 100; 
    itemsToPrintContainer.paddingLeft = 100; 
    itemsToPrintContainer.paddingRight = 100; 


    this.removeElement(itemsToPrintContainer); 
    FlexGlobals.topLevelApplication.addElement(itemsToPrintContainer); 
    printer.addObject(itemsToPrintContainer); 
    printer.send(); 
    FlexGlobals.topLevelApplication.removeElement(itemsToPrintContainer); 
    this.addElement(itemsToPrintContainer); 

    // Reset the margins to 0 for display on the screen. 
    itemsToPrintContainer.paddingBottom = 0; 
    itemsToPrintContainer.paddingTop = 0; 
    itemsToPrintContainer.paddingLeft = 0; 
    itemsToPrintContainer.paddingRight = 0; 
} 

,我做正在我想的滚轮之外打印对象,打印它,然后将其移回滚动器内部,以便用户不知道任何更改。用户可能会在屏幕上看到一个简短的闪光,而事情被重新排列,但对于我的情况是可以接受的。

此外,填充是尝试向我的打印输出添加页边空白。如果您有多个页面,它将无法正常工作。你可能不想在你的特定情况下添加填充。

-Josh

+0

为什么这不被标记为答案?这是一个可靠的解决方法。 – JTtheGeek 2011-05-17 00:18:12

+0

好主意 - 这应该被标记为正确的答案。在我的情况下(生成alivepdf)没有必要将容器放到topLevelApplciation。 – 2012-06-17 11:25:06