1

我有一个 flex 组件,一个 VBox,里面有内容。主要是文本组件。

VBox 正在保存我希望能够保存为 PDF 的报告。我正在使用AlivePdf来实现这一点,但是在 Adob​​e 阅读器(最新版本)中查看时生成的 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
}
4

1 回答 1

1

试试这个:

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
}
于 2011-05-19T15:59:58.723 回答