Pourquoi le fichier PDF est-il en train de créer une version PDF d'un composant Flex?
-
15-11-2019 - |
Question
J'ai un composant Flex, une Vbox, qui contient du contenu à l'intérieur.Composants de texte principalement.
La Vbox détient un rapport que je souhaite pouvoir enregistrer sur PDF.J'utilise alivepdf pour y parvenir, mais le PDF produit est vide lors de la visualisation dans Adobe Reader (DernierVersion).
Lorsque j'ouvre le PDF dans le bloc-notes ++, je peux voir qu'il existe définitivement du contenu et le fichier semble être structuré correctement.
C'est la méthode que j'utilise pour générer le 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
}
La solution
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
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow