apache-flex - 在 Flex 4 中打印滚动条内的内容

标签 apache-flex printing flex4 air adobe

我目前正在开发一个 Adob​​e AIR 应用程序,该应用程序向用户显示一些图形数据。由于此数据的高度更适合屏幕高度,因此我将其放置在滚动条内。

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

我尝试同时使用 PrintJob 和 FlexPrintJob,但找不到解决方法。任何人都可以通过提供见解来帮助我,一些源代码将不胜感激。

期待您的回复

谢谢

最佳答案

这显然是 Flex 打印库和 Scroller 控件的一个已知错误。您可以在这里阅读我对此的讨论: 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; 
}

我正在做的是将要打印的对象移动到滚动条之外,打印它,然后将其移回到滚动条内,因此用户不会意识到任何变化。当内容重新排列时,用户可能会在屏幕上看到短暂的闪烁,但对于我的情况来说,这是可以接受的。

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

-乔什

关于apache-flex - 在 Flex 4 中打印滚动条内的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5146009/

相关文章:

apache-flex - Flex DataGrid Flex中的Align复选框

apache-flex - 如何从Flash加载flex swf?

apache-flex - ActionScript 对象的深度通用序列化

c# - 监听套接字 udp 和 http 连接的服务器代码

c# - 打印不规则线条的条码

c++ - 通过循环设计用于搜索文件的另一个函数从文件中打印出信息 - C++

apache-flex - 寻找用于音频播放的简单Flex组件

javascript - 使用 Javascript 在 Chrome 中打印图像

ant - 在 Flash Builder 4 中使用 Ant 任务

apache-flex - Flex 4 滚轮