Printing in raster with a given scale

To do a raster printing using a given scale, so that the (scaled) world distances correspond to the distances on paper, you need to use an orthographic camera, then call the Viewport.GetBitmapSizeToPrintInWorldUnits() and use the returned size in the viewportLayout.RenderToBitmap().



// Sets an orthographic camera 
viewportLayout1.Camera.ProjectionMode = projectionType.Orthographic;

// Defines a circle with 80 units radius 
viewportLayout1.Entities.Add(new Circle(0, 0, 0, 80));

// Opens the PrintPreview dialog 
PrintPreviewDialog ppDlg = new PrintPreviewDialog(); 

ppDlg.Document = printDocument1; 

// Sets the property to true to have the drawing correctly centered on the page
printDocument1.OriginAtMargins = true; 

catch (Exception ex) 


private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    RectangleF printable = e.MarginBounds;  

    // Since PrintDocument.OriginAtMargins = True, sets top-Left corner to (0,0)  
    printable.X = 0;  
    printable.Y = 0;  

    // Defines a margin  
    int marginFromBorder = 5;

    RectangleF printRect1 = new RectangleF(printable.Left, printable.Top, printable.Width - 20, 200);

    // Gets the size of the bitmap  
    var size = viewportLayout1.Viewports[0].GetBitmapSizeToPrintInWorldUnits(e.Graphics.PageUnit, 
        linearUnitsType.Inches,  // Specifies that the model is in inches

        0.01 // Specifies a 1:100 scale

    // Gets the bitmap of the appropriate size  
    Bitmap bmp1 = viewportLayout1.RenderToBitmap(size, false, false);

    // Draws the bitmap  
    e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;  
    e.Graphics.DrawImage(bmp1, (int)(printRect1.Left + (printRect1.Width - size.Width) / 2), (int)(printRect1.Top + (printRect1.Height - size.Height) / 2), size.Width, size.Height);



The circle is printed on paper with a 0.8 inches radius (or 20.32mm), corresponding to 80 inches in scale 1:100.


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • This is good, given I can get the image in the view.  Now my wall is 900 ft long, and I want to print at every 120 ft.  So I have to zoom in the window to get 120 ft, then print as shown above.  I can't zoom in the zoom function to 1" = 20 ft  (1 = 120).  I can roughly scale it to fit and that is about it.

  • This is helpful.

    I am using the "DraftingViewportLayout" component.  It does not have the GetBitmapSizeToPrintInWorldUnits() method.  How do I get the BitmapSize from there.

    Thank you.

  • Hi Robert,


    that method has been introduced in build 8.0.295.

    Please update your Eyeshot version.


Please sign in to leave a comment.