Note: Advice in this article will only work for DotNetBrowser 1.
See the corresponding article for DotNetBrowser 2 here.
By default, each zoom level increases or decreases the zoom by 20%. As a result, you will get 100%, 120%, 144%, and so on when increasing the zoom level by 1.
For positive values, setting zoom level to 2.0 means the page is scaled to 144%, for negative values -2.0 means 1.0 / 1.44 = 69.4%. To set a custom zoom level you should use Browser.ZoomLevel
property.
Converting Zoom Level to/from Zoom Percentage
To convert the zoom percentage to the Browser.ZoomLevel
value you can use the following approach:
C#
double ZoomPercentageToZoomLevel(double zoomPercentage) { return Math.Log(zoomPercentage / 100) / Math.Log(1.2); }
VB.NET
Function ZoomPercentageToZoomLevel(zoomPercentage As Double) As Double return Math.Log(zoomPercentage / 100) / Math.Log(1.2) End Function
To convert the Browser.ZoomLevel
value to the zoom percentage you can use the following code sample:
C#
double ZoomLevelToZoomPercentage(double zoomLevel) { return Math.Pow(1.2, zoomLevel) * 100; }
VB.NET
Function ZoomLevelToZoomPercentage(zoomLevel As Double) As Double return Math.Pow(1.2, zoomLevel) * 100 End Function
1.2
is a Chromium default multiplier (equivalent of 20%)