Sfoglia il codice sorgente

Chnaged 15 to 20 multiplier in margins and page size so that margins and page size are effectively set/retrieved in points (pts). This is a breaking change potentially, but otherwise it is not clear what the units are for page width, height, and margins.

master
fitdev@hotmail.com 10 anni fa
parent
commit
5125cb1d59
1 ha cambiato i file con 32 aggiunte e 14 eliminazioni
  1. 32
    14
      DocX/DocX.cs

+ 32
- 14
DocX/DocX.cs Vedi File

{ {
float f; float f;
if (float.TryParse(top.Value, out f)) if (float.TryParse(top.Value, out f))
return (int)(f / 15.0f);
return (int)(f / 20.0f);
} }
} }
} }
XAttribute top = pgMar.Attribute(xName); XAttribute top = pgMar.Attribute(xName);
if (top != null) if (top != null)
{ {
top.SetValue(value * 15);
top.SetValue(value * 20);
} }
} }
} }
} }
} }
public float MarginTop
/// <summary>
/// Top margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float MarginTop
{ {
get get
{ {
} }
} }
public float MarginBottom
/// <summary>
/// Bottom margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float MarginBottom
{ {
get get
{ {
} }
} }
public float MarginLeft
/// <summary>
/// Left margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float MarginLeft
{ {
get get
{ {
} }
} }
public float MarginRight
/// <summary>
/// Right margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float MarginRight
{ {
get get
{ {
} }
} }
public float PageWidth
/// <summary>
/// Page width value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float PageWidth
{ {
get get
{ {
{ {
float f; float f;
if (float.TryParse(w.Value, out f)) if (float.TryParse(w.Value, out f))
return (int)(f / 15.0f);
return (int)(f / 20.0f);
} }
} }
} }
return (int)(11906.0f / 15.0f);
return (12240.0f / 20.0f);
} }
set set
if (pgSz != null) if (pgSz != null)
{ {
pgSz.SetAttributeValue(XName.Get("w", DocX.w.NamespaceName), value * 15);
pgSz.SetAttributeValue(XName.Get("w", DocX.w.NamespaceName), value * 20);
} }
} }
} }
} }
} }
public float PageHeight
/// <summary>
/// Page height value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point.
/// </summary>
public float PageHeight
{ {
get get
{ {
{ {
float f; float f;
if (float.TryParse(w.Value, out f)) if (float.TryParse(w.Value, out f))
return (int)(f / 15.0f);
return (int)(f / 20.0f);
} }
} }
} }
return (int)(16838.0f / 15.0f);
return (15840.0f / 20.0f);
} }
set set
if (pgSz != null) if (pgSz != null)
{ {
pgSz.SetAttributeValue(XName.Get("h", DocX.w.NamespaceName), value * 15);
pgSz.SetAttributeValue(XName.Get("h", DocX.w.NamespaceName), value * 20);
} }
} }
} }

Loading…
Annulla
Salva