I couldn't find a converter so I created one (actually 2 because top and bottom use int and left and right UInt32):
Thanks again and cheers
/// <summary>
/// Converts millimeters to int
/// </summary>
/// <param name="mm">millimeters</param>
/// <returns>int</returns>
private int mmToInt(int mm)
{
double multiplier = 5.67;
double _int = Convert.ToDouble(mm) * multiplier;
return Convert.ToInt32(Math.Round(_int));
}
/// <summary>
/// Converts millimeters to UInt32
/// </summary>
/// <param name="mm">millimeters</param>
/// <returns>UInt32</returns>
private UInt32 mmToUInt32(int mm)
{
return Convert.ToUInt32(mmToInt(mm));
}
And how I use it, like in advienr post (without gutter, header, footer):PageMargin pageMargin = new PageMargin() { Top = mmToInt(475), Right = mmToUInt32(200), Bottom = mmToInt(50), Left = mmToUInt32(230) };
I guess (my humble suggestion) it would be easier/a bit more elegant to have e.g. a "unit" property in the PageMargin object and let the developer use integers for top, right, bottom, left, header, footer, gutter, like this:PageMargin pageMargin = new PageMargin() { Unit = UnitMetric.Millimeter, Top = 475, Right = 200, Bottom = 50, Left = 230 };
My converter works (for me) but as said before would be cool to support inches, points, etc. (the units supported by OpenXML). Would be cool if you consider this as one of the future improvements...Thanks again and cheers