FlexコンポーネントのPDFバージョンを作成しようとしているときにPDFが空白のなのはなぜですか?

StackOverflow https://stackoverflow.com/questions/6060629

  •  15-11-2019
  •  | 
  •  

質問

私はフレックスコンポーネント、内部のコンテンツを持ちます。主にテキストコンポーネント。

VBOXは、PDFに保存できるようにしたいレポートを保持しています。私は alivepdf を使用してこれを実現しますが、Adobe Readerで表示されたときに生成された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
}
.

役に立ちましたか?

解決

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
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top