我有一个flex组件,一个VBox,里面有内容。主要是文本组件。
VBox 正在保存一个我希望能够保存为 PDF 的报告。我正在使用AlivePdf来实现这一点,但是在Adobe阅读器(最新版本)中查看时生成的PDF是空白的。
当我在记事本++中打开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
}
试试这个:
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
}