Select to view content in your preferred language

AlivePDF addGrid to print grid results

663
1
06-18-2012 07:48 AM
EricGardecki
Deactivated User
Can anyone help me figure out how to get this working? (I'm a coding noob btw)   I'm trying to use the addGrid method to print the grid results from the eSearch widget.  I got the addImage method to work but it leaves much to be desired.  I'd like to get addGrid working so that I can try tweaking it to see if it'll suffice or not but I can't get it do anything at this point.  When I hit the print button, nothing happens.

So what I've done is add a button to the SearchWidgetFloatDG.mxml of the eSearch widget which calls a function with the addGrid method.  I think my problem lies in what grid/array/dataprovider/or whatever I need to add.  I may also be missing parts....such as I'm unsure if I need to be adding columns or not or if that is part of the grid already.  I've been trying to use "resultsGrid" but no luck.

What I have done has been based on pieces of code I've found online.  I haven't been able to find any examples that fit what I'm trying to do here.

I'm using AlivePDF version 1.4.  I couldn't get anything, including addImage, to work on 1.5.

Here's the code I have in there currently, which doesn't work, but I'm changing it constantly.   Anyone have something like this already working or can see what I may be doing wrong?   FYI, there are probably some extra variables and imports from assorted things i've tried over the past many days of trying to get this to work.

import org.alivepdf.colors.RGBColor;
   import org.alivepdf.data.Grid;
   import org.alivepdf.data.GridColumn;
   import org.alivepdf.display.Display;
   import org.alivepdf.drawing.Joint;
   import org.alivepdf.fonts.*;
   import org.alivepdf.images.ImageFormat;
   import org.alivepdf.images.ResizeMode;
   import org.alivepdf.layout.*;
   import org.alivepdf.layout.Layout;
   import org.alivepdf.layout.Orientation;
   import org.alivepdf.layout.Size;
   import org.alivepdf.layout.Unit;
   import org.alivepdf.pdf.PDF;
   import org.alivepdf.saving.Download;
   import org.alivepdf.saving.Method;
   
   import spark.components.Button;
   
   import widgets.eSearch.SearchWidget;
   import widgets.eSearch.skins.PopUpRendererSkin;
     
   private var urlString:String;
   private var pdfBinary:ByteArray;
   private var method:String
   private var mygrid:org.alivepdf.data.Grid;


private function doPrint(event:Event):void{
    var printPDF:PDF = new PDF( Orientation.LANDSCAPE, Unit.INCHES, Size.LETTER );
    //var mygrid:Grid = new Grid ( resultsGrid.dataProvider.toArray(), 100,100, null,null,null,true,null,1 );
    mygrid = new org.alivepdf.data.Grid(resultsGrid.dataProvider.toArray(), 100, 100, null, null, null, true, null, 1);
    mygrid.columns = dgHyperColumns();
    printPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
    printPDF.addPage();
    //printPDF.addImage( resultsGrid, 0, 0, 0, 0, 'PNG', 100, 1,ResizeMode.FIT_TO_PAGE);
    printPDF.addGrid(mygrid,50,50,false);
    printPDF.save( Method.REMOTE, "http://map.exetertownship.com/createpdf/Default.aspx", Download.INLINE, "results.pdf" );
   }


<s:Button label="Print" id="_Print" click="doPrint(event)" skinClass="widgets.eSearch.skins.ExportButtonSkin" visible="true" includeInLayout="true"/>


thanks!
Tags (2)
0 Kudos
1 Reply
EricGardecki
Deactivated User
nothing?

I think my issue may just be not knowing what "data" and "columns" to use here:

Grid(data:Array, width:Number, height:Number, headerColor:IColor, cellColor:IColor = null, useAlternativeRowColor:Boolean = false, alternativeCellColor:IColor = null, borderColor:IColor = null, borderAlpha:Number = 1, headerHeight:int = 5, rowHeight:int = 5, joints:String = 0 j, columns:Array = null)

Robert?  What is the name of the data and columns in your widget?  I have gone through it over and over and I just can't decipher what to use.  What I have used (resultsGrid, dgHyperColumns, dgColArr, etc) did not work.

I continue to have nothing happen at all when I click on my print button.  But if I remove the addGrid method and use addImage I get a result.  I just don't know what this means.
0 Kudos