1

I have a flex component, a VBox, that has content inside it. Text components mainly.

The VBox is holding a report that I want to be able to save to PDF. I am using AlivePdf to achieve this but the PDF produced is blank when viewed in Adobe reader (latest version).

When I open the PDF in Notepad++ I can see that there is definitely content in there and the file appears to be structured correctly.

This is the method I am using to generate the 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
}
DaveC
  • 552
  • 1
  • 4
  • 20
  • What version of AlivePDF are you using and have you tried with another PDF viewer other than Adobe Reader? – J_A_X May 19 '11 at 15:39

1 Answers1

1

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
}
Jason Towne
  • 8,014
  • 5
  • 54
  • 69
  • I changed the way I built the PDF because I needed the text to be text rather than just an image of text. This would have worked though, thanks for the suggestion – DaveC Jun 22 '11 at 16:00