Hai Mike,
Check this statement.
var bitmap : BitmapData = new BitmapData
( target.width,target.height );
check whether ur receiving component has initialized or not and also
check the target WIDTH and HEIGHT,
if the component height n width is zero the u'll get this error :
ArgumentError: Error #2015: invalid BitmapData. at
flash.display::BitmapData().
Thanks,
Regards,
RIA
On May 7, 4:21 am, Mike Rdz <[email protected]> wrote:
> Hey people,
>
> I'm working in a particular project, where I must export the
> information that I got from the DB into a <mx:Panel> with a chart and
> a datagrid, and well as I got the project the developer export that as
> an image.
> So I'm trying to workaround a little detail.
> The panel get's so big due to the information that I have on the
> report, so the image becomes bigger, and the exportation won't work!!
>
> I'm adding you my code in here, what I'm trying and why.
> /* This is the beginning of the class with the first method */
> public static function exportPDF
> (pnlRankIndiceCalidad:Panel, jspFile:String,
> marca:String, dirOper:String,
> mesDesde:String, anoDesde:String,
> mesHasta:String, anoHasta:String, nomArchivo:String,
> metodo:Number):void
> {
>
> var myPDF:PDF;
> var metodoStr:String = null;
>
> myPDF = new PDF (Orientation.LANDSCAPE, Unit.MM,
> Size.LEGAL);
> myPDF.addPage();
> // Here comes more code...
>
> // pnlRankIndiceCalidad is the panel where I
> have both objects Datagrid and Chart
> if( pnlRankIndiceCalidad.height > 2800 ) {
>
> var repeticiones : int =
> pnlRankIndiceCalidad.height / 2800;
> /*
> At this line is exactly where the code is sending me the exception
> that I'm talking about down you'll find the code that obtenBitmapData
> function has
> */
> var bd : BitmapData = obtenBitmapData(
> UIComponent
> ( pnlRankIndiceCalidad ) );
>
> var pixeles : ByteArray = bd.getPixels( new
> Rectangle( 0, 0,
> bd.width, bd.height ) );
> pixeles.position = 0;
> var repeticion : Number = 0;
> var posicionInicio : Number = 0;
> var posicionFin : Number = 2800;
> while ( repeticion <= repeticiones ) {
>
> var copiaImagen:BitmapData = new
> BitmapData( 1040, 2800, true );
> Alert.show("Start at position: " +
> posicionInicio + " end in: " +
> posicionFin);
> for( var i:uint=posicionInicio ; i <
> posicionFin ; i++ )
> {
> for( var j:uint=0; j<1040; j++ )
> {
> copiaImagen.setPixel( j, i,
> pixeles.readUnsignedInt() );
> }
> }
>
> var imagen: Bitmap = new Bitmap(
> copiaImagen );
> imagen.width = 1040;
> imagen.height = 2800;
> myPDF.addPage();
> myPDF.addImage( imagen,10,10,250,172
> );
>
> repeticion++;
> posicionInicio = posicionFin;
> posicionFin += posicionFin;
>
> }
> }
> else {
>
> myPDF.addImage(pnlRankIndiceCalidad, 50, 35,
> 250, 172);
> }
> /*
> Here come more code that's working just well
> */
>
> /*
> This function is the one that's in charge of the transformation of the
> UIComponent into a BitmapData.
> */
> private static function obtenBitmapData( target : UIComponent
> ) :
> BitmapData {
>
> var bitmap : BitmapData = new BitmapData(
> target.width,
> target.height );
> var m : Matrix = new Matrix();
> bitmap.draw( target, m );
> return bitmap;
> }
>
> The exception that this code is sending is the follow
> ArgumentError: Error #2015: invalid BitmapData.
> at flash.display::BitmapData()
> at
> com.posadas.linc.reportes.rankingIndicesCalidad::RankingIndicesCalidadPDFExporter
> $/obtenBitmapData()[/media/disk/desarrollo/posadas/LincPosadas/
> src_flex/com/posadas/linc/reportes/rankingIndicesCalidad/
> RankingIndicesCalidadPDFExporter.as:81]
> at
> com.posadas.linc.reportes.rankingIndicesCalidad::RankingIndicesCalidadPDFExporter
> $/exportPDF()[/media/disk/desarrollo/posadas/LincPosadas/src_flex/com/
> posadas/linc/reportes/rankingIndicesCalidad/
> RankingIndicesCalidadPDFExporter.as:58]
>
> The first reference on the stacktrace is the function
> "obtenBitmapData" and the second one is where that function is
> called!!
>
> Please help me out to understand or help me to fix this details.
> What I'm pretending right now, is that is the image is too big to fit
> on one page, cut it in ByteArray object and create one by one, at the
> same time that gets added to the PDF object.
>
> BTW the API that I'm using for this is the AlivePDF
>
> Any help will be really great!!
> Thanks in advance to all!!
>
> Have a great day!
>
> Regards,
> Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---