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

发布于 2024-10-19 11:59:10 字数 264 浏览 4 评论 0原文

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

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

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

期待您的回复,

谢谢

I am currently working on an Adobe AIR application that shows the user some graphical data. As this data is more in height to fit the screen height, I've placed it inside a scroller.

Now I want to take a print of this visual data, mostly some charts and lists but I only see a single page containing only the part of the screen that is currently visible to the user. I want to have the entire content inside the scroller to appear on the page.

I tried using both PrintJob and FlexPrintJob but couldn't find a way around. Can anyone please help me by providing an insight, some source code will be greatly appreciated.

Looking forward to your replies,

Thanks

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

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

发布评论

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

评论(1

画中仙 2024-10-26 11:59:10

这显然是 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; 
}

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

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

-乔什

This is apparently a known bug with the Flex printing library and Scroller controls. You can read about my discussions on this here:
http://forums.adobe.com/message/3626759

As a workaround, I did the following:

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; 
}

That I'm doing is moving the object I want to print outside of the scroller, printing it, and then moving it back inside the scroller, so the user is unaware of any change. The user might see a brief flash on the screen while things are re-arranged, but for my case that was acceptable.

Also, the padding was an attempt to add a margin to my printed output. It will not work quite right if you have multiple pages. You may not want to add padding in your particular case.

-Josh

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文