在尝试创建PDF版本的Flex组件时,为什么PDF空白是为什么?
-
15-11-2019 - |
题
我有一个Flex组件,一个vbox,它内容内容。主要是文本组件。
vbox持有一个报告,我希望能够保存到PDF。我正在使用 Alivepdf 实现这一点,但在Adobe Reader中查看时,PDF产生的PDF是空白的(最新版本版本)。
当我打开Notepad ++中的PDF时,我可以看到那里肯定存在内容,文件似乎是正确的结构。
这是我使用的方法来生成pdf:
private function doPrint(whatToPrint:UIComponent):void
{
var printPDF:PDF = new PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
printPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
printPDF.addPage();
printPDF.addImage( whatToPrint, 0, 0, 0, 0, 'PNG', 100, 1, ResizeMode.FIT_TO_PAGE );
// The string here looks to have produced a valid PDF but it doesn't render correctly
var content:String = printPDF.save(Method.LOCAL);
// Custom save file data in here, removed for clarity of issue
}
. 解决方案
Try this:
private function doPrint(whatToPrint:UIComponent):void
{
var printPDF:PDF = new PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
printPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
whatToPrint.validateNow();
printPDF.addPage();
printPDF.addImage( whatToPrint, 0, 0, 0, 0, 'PNG', 100, 1, ResizeMode.FIT_TO_PAGE );
// The string here looks to have produced a valid PDF but it doesn't render correctly
var content:String = printPDF.save(Method.LOCAL);
// Custom save file data in here, removed for clarity of issue
}
不隶属于 StackOverflow