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
}
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
}