Printing tables to pdf along with map

3015
19
10-03-2013 08:45 PM
IrisGreen
New Contributor
Hello Everyone,

I need to print tables generated using a query along with the Map in "pdf" format such that they are auto arranged in the white
space on the map.
I am looking for any suggestion using flex which can help me do this.


Thanks in Advance.


Iris
Tags (2)
0 Kudos
19 Replies
MGSethe
New Contributor II
I ran a quick test and it is possible using alivePDF, just add your legend as a component to the map and you can use the addimage property in alivePDf to add the legend as an image to the report.


Hello Aaron

Thanks for the quick reply, I tried it and I am not winning, could you please share the code you have if you do not mind?
I am referring to the code that have the Legend.

Thanking you in advance
0 Kudos
AaronNash1
Occasional Contributor II
attached is a text file of the project I was working on, its a simple PDF report. just shows that it can be done.
0 Kudos
MGSethe
New Contributor II
Thanks a million times. It did the trick
0 Kudos
LefterisKoumis
Occasional Contributor III
oops didn't see this until just now. sorry no, its the clients. but if you have specific questions i can probably whip up generic cf code.


Thank you Paul.  I am interested to see how you posted the legend. Any generic code to share, I'd appreciate it. Thanks.
0 Kudos
PaulHastings1
Occasional Contributor
our suite of apps parses the layers in each map service the apps will use via rest calls (an admin app that sets which users/groups can use which map services/tools, etc). that includes the legends. that's all stored in a sql server table & this reporting tool simply pulls that data out of the table & adds it to the PDF.

the map template is from arcMap. i get a PDF of that blank template & measure out the available space for the legend, etc. using a PDF tool (foxit for example)--mainly because the designers either don't know or won't say the space available for each piece of the template. those become constants. the legend,etc. tables are built in server memory & measured against the available space.if they fit, they go in, if not they get added to a supplemental page (next iteration will measure rows & fit as many as possible instead of this binary approach).

if you can read coldfusion, i'll try to get a generic example together.
0 Kudos
LefterisKoumis
Occasional Contributor III
our suite of apps parses the layers in each map service the apps will use via rest calls (an admin app that sets which users/groups can use which map services/tools, etc). that includes the legends. that's all stored in a sql server table & this reporting tool simply pulls that data out of the table & adds it to the PDF.

the map template is from arcMap. i get a PDF of that blank template & measure out the available space for the legend, etc. using a PDF tool (foxit for example)--mainly because the designers either don't know or won't say the space available for each piece of the template. those become constants. the legend,etc. tables are built in server memory & measured against the available space.if they fit, they go in, if not they get added to a supplemental page (next iteration will measure rows & fit as many as possible instead of this binary approach).

if you can read coldfusion, i'll try to get a generic example together.


Thank you for your reply, Paul. It it very interesting the approach you described and open up to me new possibilities. I have a license of CF 9, and I was using it for web apps but since then I turned my attention to ASP.NET. Based on your reply, it seems that you also have a license for the Foxit PDF SDK to implement in your solution.  If you provide a generic example it will be very helpful. Thanks.
0 Kudos
PaulHastings1
Occasional Contributor
no, as i said, we're using coldfusion & the iText version that comes w/it, server side. foxit that i used to measure the template bits is the free version. nothing special about it.
0 Kudos
LefterisKoumis
Occasional Contributor III
attached is the code I used in my application. Any questions let me know


Aaron, thank you for posting the code for printing the display features in a pdf.

For the report.pdf, I assume that you used a spark datagrid. Could you please post the code for printing to pdf the datagrid as displayed in the report.pdf? Thanks.
0 Kudos
AaronNash1
Occasional Contributor II
here is some code for just printing a table

public function generatePDF2():void
{
     var myCoreFont1:IFont = new CoreFont ( FontFamily.ARIAL );
     
     myPDF = new PDF(Orientation.PORTRAIT, Unit.MM, Size.TABLOID);
     myPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
     myPDF.addPage();
     myPDF.setFont(myCoreFont1, 12);
     myPDF.addText('List of Development Services Projects - Status', 11, 10);
     myPDF.setFont(myCoreFont1, 8);
     myPDF.addText('Printed:' + dateFormatter.format(now.toLocaleDateString()), 180, 10);
     var gridColumnOwner1:GridColumn = new GridColumn("Project Name", "Name", 90, Align.LEFT, Align.LEFT);  
     var gridColumnOwner2:GridColumn = new GridColumn("Condition", "Color", 18, Align.LEFT, Align.LEFT);
     var gridColumnAddress:GridColumn = new GridColumn("Status", "Status", 20, Align.LEFT, Align.LEFT);
     var gridColumnMailCity:GridColumn = new GridColumn("Next Step", "Cur_Status", 20, Align.LEFT, Align.LEFT);
     
     var gridColumnMailStat:GridColumn = new GridColumn("Department", "DS_Department", 35, Align.LEFT, Align.LEFT);
     var gridColumnManager:GridColumn = new GridColumn("Project Manager", "Manager", 35, Align.LEFT, Align.LEFT);
     var gridColumnCost:GridColumn = new GridColumn("Project Assistant", "Assistant", 35, Align.LEFT, Align.LEFT);
     
     
     myPDF.setFont(myCoreFont1, 8);
     myPDF.textStyle ( new RGBColor ( 0x000000 ), 1 );
                                        //resultsGrid is the name of the datagrid
     var grid:Grid = new Grid (resultsGrid.dataProvider.toArray(), 0, 0, new RGBColor (0xC0C0C0), 
      new RGBColor (0xCCCCCC), true , new RGBColor(0x000000), 1, Joint.ROUND);
     
     var columns:Array = new Array (gridColumnOwner1,gridColumnOwner2, gridColumnAddress, gridColumnMailCity, gridColumnMailStat, gridColumnManager, gridColumnCost);
     grid.columns = columns;
     myPDF.addGrid(grid, 1, 6);
     //export to pdf web service
     myPDF.save(Method.REMOTE, "name of server",Download.INLINE,"myPDF.pdf");
}
0 Kudos
LefterisKoumis
Occasional Contributor III
here is some code for just printing a table

public function generatePDF2():void
{
     var myCoreFont1:IFont = new CoreFont ( FontFamily.ARIAL );
     
     myPDF = new PDF(Orientation.PORTRAIT, Unit.MM, Size.TABLOID);
     myPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
     myPDF.addPage();
     myPDF.setFont(myCoreFont1, 12);
     myPDF.addText('List of Development Services Projects - Status', 11, 10);
     myPDF.setFont(myCoreFont1, 8);
     myPDF.addText('Printed:' + dateFormatter.format(now.toLocaleDateString()), 180, 10);
     var gridColumnOwner1:GridColumn = new GridColumn("Project Name", "Name", 90, Align.LEFT, Align.LEFT);  
     var gridColumnOwner2:GridColumn = new GridColumn("Condition", "Color", 18, Align.LEFT, Align.LEFT);
     var gridColumnAddress:GridColumn = new GridColumn("Status", "Status", 20, Align.LEFT, Align.LEFT);
     var gridColumnMailCity:GridColumn = new GridColumn("Next Step", "Cur_Status", 20, Align.LEFT, Align.LEFT);
     
     var gridColumnMailStat:GridColumn = new GridColumn("Department", "DS_Department", 35, Align.LEFT, Align.LEFT);
     var gridColumnManager:GridColumn = new GridColumn("Project Manager", "Manager", 35, Align.LEFT, Align.LEFT);
     var gridColumnCost:GridColumn = new GridColumn("Project Assistant", "Assistant", 35, Align.LEFT, Align.LEFT);
     
     
     myPDF.setFont(myCoreFont1, 8);
     myPDF.textStyle ( new RGBColor ( 0x000000 ), 1 );
                                        //resultsGrid is the name of the datagrid
     var grid:Grid = new Grid (resultsGrid.dataProvider.toArray(), 0, 0, new RGBColor (0xC0C0C0), 
      new RGBColor (0xCCCCCC), true , new RGBColor(0x000000), 1, Joint.ROUND);
     
     var columns:Array = new Array (gridColumnOwner1,gridColumnOwner2, gridColumnAddress, gridColumnMailCity, gridColumnMailStat, gridColumnManager, gridColumnCost);
     grid.columns = columns;
     myPDF.addGrid(grid, 1, 6);
     //export to pdf web service
     myPDF.save(Method.REMOTE, "name of server",Download.INLINE,"myPDF.pdf");
}


Thank you.  I got a bit of work to do. The layers and the attributes are pre-selected by the user before the datagrids are printed out.
0 Kudos