Hi, Vincent
Here is one workaround for you.
First off, call the method of GetBitMap of Map control and then you will get the returned image with feature data of FeatureLayer and Makers.
And then draw this image on the PdfDocument using PdfGeoCanvas.
We made one simple sample depend on the “UsePdfExtension” installed sample for you. Please refer to it.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web.UI;
using PdfSharp;
using PdfSharp.Pdf;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WebEdition;
namespace CSSamples.Samples.Extending_MapSuite
{
public partial class UsePdfExtension : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Map1.MapUnit = GeographyUnit.DecimalDegree;
Map1.CurrentExtent = new RectangleShape(-111.7875, 92.0859375, 148.36875, -93.5390625);
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
EcwRasterLayer worldImageLayer = new EcwRasterLayer(MapPath("~/SampleData/world/World.ecw"));
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.EndCap = DrawingLineCap.Round;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer usStatesLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/USA/STATES.SHP"));
usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.State2;
usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
usStatesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer worldCapitalsLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/capital.shp"));
worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City4;
worldCapitalsLayer.DrawingMarginPercentage = 80;
worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer worldCapitalsLabelsLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/capital.shp"));
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital1("city_name");
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.StartCap = DrawingLineCap.Round;
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.EndCap = DrawingLineCap.Round;
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.SuppressPartialLabels = true;
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.StaticOverlay.Layers.Add("WorldImageLayer", worldImageLayer);
Map1.StaticOverlay.Layers.Add("WorldLayer", worldLayer);
Map1.StaticOverlay.Layers.Add("USStatesLayer", usStatesLayer);
Map1.StaticOverlay.Layers.Add("WorldCapitals", worldCapitalsLayer);
Map1.StaticOverlay.Layers.Add("WorldCapitalsLabels", worldCapitalsLabelsLayer);
SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay("MarkerOverlay");
Marker marker = new Marker(-94.558, 39.078, new WebImage("../../theme/default/img/marker_gold.gif", 21, 25, -10.5f, -25f));
marker.Popup.ContentHtml = "ContentHTML";
marker.Popup.AutoSize = true;
marker.IsVisible = true;
markerOverlay.Markers.Add(marker);
Map1.CustomOverlays.Add(markerOverlay);
}
}
protected void btnToPdf_Click(object sender, EventArgs e)
{
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
if (rdlOptions.SelectedItem.Text == "Landscape")
{
page.Orientation = PageOrientation.Landscape;
}
PdfGeoCanvas pdfGeoCanvas = new PdfGeoCanvas();
RectangleShape printExtent = ExtentHelper.GetDrawingExtent(Map1.CurrentExtent, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels);
pdfGeoCanvas.BeginDrawing(page, printExtent, GeographyUnit.DecimalDegree);
Bitmap bitmap = Map1.GetBitmap();
MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Png);
PointShape centerPoint = pdfGeoCanvas.CurrentWorldExtent.GetCenterPoint();
pdfGeoCanvas.DrawWorldImageWithoutScaling(new GeoImage(stream), centerPoint.X, centerPoint.Y, DrawingLevel.LabelLevel);
pdfGeoCanvas.EndDrawing();
string filename = @"c:\temp\MapSuite PDF Map.pdf";
document.Save(filename);
OpenPdfFile(filename);
}
private static void OpenPdfFile(string filename)
{
try
{
Process.Start(filename);
}
catch (Win32Exception ex)
{
if (ex.Message == "No application is associated with the specified file for this operation")
{
//string message = "You can't open Pdf file, the reason maybe you don't install Adobe Reader\r\n\r\n" + ex.ToString();
//MessageBox.Show(message, "Open Pdf file failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
ProcessStartInfo psi = new ProcessStartInfo(@"C:\WINDOWS\system32\rundll32.exe");
psi.Arguments = @" C:\WINDOWS\system32\shell32.dll, OpenAs_RunDLL " + filename;
Process.Start(psi);
}
}
}
}
}
For the text on the marker, and I remember that you used the InMemoryFeatureLayer to display the text of marker, so you just need to put it in the StaticOverlay or other overlays on the top of other FeatureLayers.
Thanks,
Khalil