MapPrinterLayer not printing to scale

Hi Summer,



Thanks for you reply and also thanks for the sample project in the attachment. The solution of increasing the page dimensions solves the problem of scale but creates a new problem for me. When I use that solution all PrinterLayer objects shift to the right by the amount of HardMarginX, in my case 0.13 inches. The also shift down by the amount of HardMarginY.



My workaround is to create the RectangleShape that represents the drawing area using the original page size (850 X 1100 in this case). I then shift all the printer layers to the left by HardMarginX and up by  HardMarginY before printing. Following the print, the PrinterLayers are returned to their original positions.



In this way I am hopeful all printer devices will produce the desired results. Here is the code I am using.




01.Dim oPrintDocument As New PrintDocument()
02.With oPrintDocument
03.   .PrinterSettings = oPrinterSettings
04.   .DefaultPageSettings.Landscape = True
05.   If oPagePrinterLayer.Orientation = PrinterOrientation.Portrait Then
06.      .DefaultPageSettings.Landscape = False
07.   End If
08.   .DefaultPageSettings.PaperSize = New PaperSize("AnsiA", CInt(850), CInt(1100))
09.End With
10. 
11.Dim oRect As RectangleShape
12.Dim oNewUpperLeft As PointShape
13.Dim oNewLowerRight As PointShape
14.Dim oNewRect As RectangleShape
15. 
16.Dim oPrinterCanvas As PrinterGeoCanvas = New PrinterGeoCanvas()
17. 
18.‘***** Create a rectangle to represent the drawing area for the document
19.oPrinterCanvas.DrawingArea = New Rectangle(0, 0, 850, 1100)
20. 
21.’***** Start the drawing process
22.oPrinterCanvas.BeginDrawing(oPrintDocument, oPagePrinterLayer.GetBoundingBox(), PageLayout.MapUnit)
23. 
24.‘***** Loop through all of the PrintingLayers in the PrinterInteractiveOverlay 
25.’***** and print all of the except for the PagePrinterLayer                
26.Dim labelsInAllLayers As Collection(Of SimpleCandidate) = New Collection(Of SimpleCandidate)()
27.For Each oPrinterLayer As PrinterLayer In oPrinterOverLay.PrinterLayers
28.   oPrinterLayer.IsDrawing = True
29.   If Not (TypeOf oPrinterLayer Is PagePrinterLayer) Then
30.      oPrinterLayer.Open()
31.      '***** Shift the PrinterLayer to the right and up by HardMarginX and HardMarginY
32.      oRect = (oPrinterLayer.GetPosition(PrintingUnit.Inch))
33.      oNewUpperLeft = New PointShape(oRect.UpperLeftPoint.X - 0.13, oRect.UpperLeftPoint.Y + 0.06)
34.      oNewLowerRight = New PointShape(oRect.LowerRightPoint.X - 0.13, oRect.LowerRightPoint.Y + 0.06)
35.      oNewRect = (New RectangleShape(oNewUpperLeft, oNewLowerRight))
36.      oPrinterLayer.SetPosition(oNewRect, PrintingUnit.Inch)
37.      oPrinterLayer.Draw(oPrinterCanvas, labelsInAllLayers)
38.      oPrinterLayer.SetPosition(oRect, PrintingUnit.Inch)
39.   End If
40.   oPrinterLayer.IsDrawing = False
41.Next oPrinterLayer
42. 
43.oPrinterCanvas.EndDrawing()

This seems to be getting the job done for me.



Thanks,



Steve