¿Por qué el PDF en blanco está tratando de crear una versión PDF de un componente FLEX?

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

  •  15-11-2019
  •  | 
  •  

Pregunta

Tengo un componente flexible, una vbox, que tiene contenido dentro de él.Componentes de texto principalmente.

La VBox está sosteniendo un informe que quiero poder ahorrar en PDF.Estoy usando vivopdf para lograr esto, pero el PDF producido está en blanco cuando se ve en Adobe Reader (más recienteversión).

Cuando abro el PDF en Notepad ++ puedo ver que definitivamente hay contenido allí y el archivo parece estar estructurado correctamente.

Este es el método que estoy usando para generar el 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
}

¿Fue útil?

Solución

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
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top