ThinkGeo.com    |     Documentation    |     Premium Support

Printing to PDF

Hi,
we need a snippet for Printing to PDF using different dpi (100-300) and also rotating the map.
Our main problem is to use different coordinate systems and different sources (PostGIS:25832, Raster: 4326, OSM etc.)

Regards
Hardy

Hi Hardy,

Here is a code snippet from one original project, it’s VB.net but I think it’s helpful, if you have projection please assign it to layer before drawing:

            pdfGeoCanvas.BeginDrawing(pdfPage, pagePrinterLayer.GetBoundingBox(), PageLayout.MapUnit)
        pdfGeoCanvas.Dpi = 100

        Dim labelsInAllLayers As Collection(Of SimpleCandidate) = New Collection(Of SimpleCandidate)()
        For Each printerLayer As PrinterLayer In printerInteractiveOverLay.PrinterLayers
            printerLayer.IsDrawing = True
            If Not (TypeOf printerLayer Is PagePrinterLayer) Then
                printerLayer.Draw(pdfGeoCanvas, labelsInAllLayers)
            End If
            printerLayer.IsDrawing = False
        Next printerLayer

        pdfGeoCanvas.EndDrawing()

Regards,

Ethan