using System.Runtime.InteropServices; [DllImport("gdi32.dll")] private static extern int GetDeviceCaps(IntPtr hdc, int Index); public static double MillimetersToPixels(double mm) { System.Windows.Forms.Panel p = new System.Windows.Forms.Panel(); System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(p.Handle); IntPtr hdc = g.GetHdc(); int width = GetDeviceCaps(hdc, 4); int pixels = GetDeviceCaps(hdc, 8); g.ReleaseHdc(hdc); return (pixels / width) * mm; }