ThinkGeo.com    |     Documentation    |     Premium Support

Convert map extent to pdf

Hi,
I want to print my map extent to pdf.For that i used this method:
private void PrintMapWithPdfCanvas()
{
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
PdfGeoCanvas pdfGeoCanvas = new PdfGeoCanvas();
RectangleShape extent = mapEngine.StaticLayers[“FinalShape”].GetBoundingBox();
//RectangleShape printExtent = ExtentHelper.GetDrawingExtent(Map1.CurrentExtent, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels);
Collection labelsInLayers = new Collection();
foreach (Layer layer in mapEngine.StaticLayers)
{
pdfGeoCanvas.BeginDrawing(page,extent, GeographyUnit.Meter);
layer.Open();
layer.Draw(pdfGeoCanvas, labelsInLayers);
layer.Close();
pdfGeoCanvas.EndDrawing();
}

        string filename = System.IO.Directory.GetCurrentDirectory() + "\\MapSuite PDF Map.pdf";
        document.Save(filename);
    }

but I’m getting error to this line
pdfGeoCanvas.BeginDrawing(page,extent, GeographyUnit.Meter);
It is taking GeoCanvas.BeginDrawing() but i’m using PdfGeoCanvas.
And for this line of code also
layer.Draw(pdfGeoCanvas, labelsInLayers);
I am stuck here.
i just want to make map extent as pdf.
Any help will be appreciated.

Regards,
Mouni_M

Hi Mouni_M,

In fact we have a sample about print for web, and it support print to pdf.

Please refer it and let us know if you met any problem:

I hope that’s helpful.

Regards,

Ethan