Select to view content in your preferred language

Printing in SL 2.0 comparsion

7295
59
10-04-2010 05:27 AM
LakshmananVenkatesan
Frequent Contributor
Dear All:

We have developed Print functionality in Web application using ESRI SL 1.2, ArcGIS 9.3.1. Client application willl send all visible layers, graphics (poly,line and point) as string , text symbols as string to server side and recreate a map document and construct geometry from string and generate a image and display in web page.

If we have say 100 lines as graphics, string which we generate is very big and unable to process( or send via http). Server side is done using GP Tool. Question is we have planned to move to ArcGIS 10 and SL 2.0.

What are all advantages in print functionality using ArcGIS 10 and SL 2.0  (MS SL 4.0) or rather how easy to print the map with graphics and other options ?

Please throw light on this
0 Kudos
59 Replies
ErikEngstrom
Frequent Contributor
Dom,
I am using a new project and re-downloaded your code. It must be the newer version. When building in my project, I'm getting two errors:

The type or namespace name 'MapPages' could not be found (are you missing a using directive or an assembly reference?)
I'm also getting this for 'MapUnit' in MapPrinter.cs

Where do I specify these? My XAML code looks like this now:
<ESRI_ArcGIS_Client_Samples_MapPrinting:MapPrinterDialog x:Name="printPreviewMap" HorizontalAlignment="Right" Margin="0,192,-28,0" Grid.Row="2" Style="{StaticResource PrintPreviewStyle}" VerticalAlignment="Top">
   <ESRI_ArcGIS_Client_Samples_MapPrinting:MapPrinter x:Name="printMap" Map="{Binding ElementName=MyMap, Mode=OneWay}" Style="{StaticResource MapPrinterStyle}" PrintExtent="{Binding Extent.Extent, ElementName=MyMap, Mode=TwoWay}" Title="{StaticResource Title}"  d:LayoutOverrides="Width"/>  
</ESRI_ArcGIS_Client_Samples_MapPrinting:MapPrinterDialog>


I have references to:
MapPrintingControls.csproj
System.Windows.Controls.Toolkit
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Likely an issue in the MapPrintingControls references. Check that all the ESRI dlls are resolved and are pointing to the right version of your Silverlight API.
Then try to build the MapPrintingControls project alone, then ..... no idea.
0 Kudos
JannalynPontello
Deactivated User
Dominique,

I'm having trouble getting the print control to work in my application. I compiled your code and added the dll to my application and referenced it. I copied all of usercontrols.resources, the code for the MapPrinter Dialog Panel, and the cs code for SelectionChanged and PageChanged. Then I added a toggle button to my toolbar to open and close the print dialog. I can run your sample with no errors, but my code has issues. I don't get any errors when I build the app, but I get Framework errors in the browser. Am I missing something?

Thanks,
Jannalyn
0 Kudos
SamuelDantas
Emerging Contributor
Hello Dominique,

I'm trying to change the layout of the printing page with a ComboBox:

<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                <TextBlock Text="Tipo de folha:" Margin="5,0,5,0" VerticalAlignment="Center"></TextBlock>
                <ComboBox x:Name="cbxPaperType" Width="110" Height="25" VerticalAlignment="Center">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction 
                 Command="{Binding PaperTypeCommand}" 
                 CommandParameter="{Binding ElementName=cbxPaperType}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ComboBox.Items>
                        <ComboBoxItem IsSelected="True">A4</ComboBoxItem>
                        <ComboBoxItem>A3, A2, A1, A0</ComboBoxItem>
                    </ComboBox.Items>
                </ComboBox>
            </StackPanel>


Using the following command method to change:

private void PaperType(object param)
{
            if (param == null)
            {
                return;
            }

            ComboBox cbx = param as ComboBox;

            ResourceDictionary dict = new ResourceDictionary();
            Uri uri = new Uri("/MapPrintingControls;component/MapPrinter.xaml", UriKind.Relative);
            dict.Source = uri;

            if (cbx.SelectedIndex == 0)
            {
                ControlTemplate ct = (ControlTemplate)dict["MapPrinter_A4"];
                Template = ct;

                printMap.Width = 771;
                printMap.Height = 1122;

                Width = 793;
                Height = 1122;

                UpdateLayout();
                            
            }
}


It changes the template correctly but I can't move the map. Looks like it is losing an event handler.

Can you help me?
Thanks a lot.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Did you get a recent version of the print sample?

I remember that the first version of the MapPrinterDialog was using a scrollviewer, so the management of the map events for panning/zooming was a little bit tricky.
Then I replaced with a ViewBox which should work better. Check that your version includes this line:
<Viewbox>
  <ContentPresenter Content="{TemplateBinding MapPrinter}" MinHeight="200" />
</Viewbox>


That said, I am not sure it explains your issue, but at this time no other idea....
0 Kudos
JannalynPontello
Deactivated User
Is there a way to restrict a service from appearing in the legend? I have an image service and a graphics layer that I don't want to show, but I'm not sure how to reference only the dynamic data source in the xaml (or if it's even possible). I'd appreciate any suggestions.

Thanks,
Jannalyn
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Is there a way to restrict a service from appearing in the legend? I have an image service and a graphics layer that I don't want to show

Yes. Two options to define the services appearing in the legend :
- set the LayerIds legend property in XAML : LayerIds="MyDynamicService1, MyImageService, ....."
- by code : hook up an handler to event Legend.Refreshed and, in this handler, remove the legend items you don't want. Sample removing legend items for all graphicslayers:

private void Legend_Refreshed(object sender, ESRI.ArcGIS.Client.Toolkit.Legend.RefreshedEventArgs e)
{
    Legend legend = sender as Legend;
    if (legend != null && e.LayerItem.Layer is GraphicsLayer)
        legend.LayerItems.Remove(e.LayerItem);
}


Note that, this is working the same way for a legend defined in the main map and a legend defined in a mapprinter template.
0 Kudos
JannalynPontello
Deactivated User
That did it. Thanks for making a great printing project and helping us newbies along the way.

Jannalyn
0 Kudos
DavidHollema
Deactivated User
I was getting the HRESULT E_FAIL error too and it was due solely to mismatched ESRI dlls.  My app is compiled against 2.2 and the print sample dlls were at 2.1.  Both are in the same VS solution.  Simply changing the references for the print sample project to target 2.2 fixed the issue.  No thanks to Blend's error messaging quagmire.

Dave

Sorry I have no clue.

Check that there is no mismatch in the dlls you referenced (MapPrintingControls and your app should reference the same ArcGIS client dlls).

If you just compile the sample solution (MapPrinting + MapPrintingControls), is it working?
0 Kudos
DannyHaipola
Deactivated User
Dominique,
In my application I have made the changes that necessary to set the IsActive property when the user clicks the button. "This is done by using the IsActive property of the MapPrinter. The map is cloned for printing when the IsActive property is set to true (and the cloned map is freed when IsActive is set to false)." The result is that the print dialog window does indeed refresh on opening and closing; however, when the user opens the print dialog the second and every subsequent time the print contains only print window outline but no map (the print dialog looks right).
Have tired several methods of setting the IsActive true/false same outcome.
Would appreciate any input.
0 Kudos