Skip to content

Commit

Permalink
Add support for margins
Browse files Browse the repository at this point in the history
  • Loading branch information
frederiksen committed Oct 25, 2015
1 parent f54d912 commit 32f4f69
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Reports/UserDefinedReport/Sample/UserDefinedReport.xml
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<userdefinedreport description="User Defined Report Sample" width="8.27" height="11.69">
<userdefinedreport description="User Defined Report Sample" width="8.27" height="11.69" leftmargin="10" rightmargin="10" topmargin="10" bottommargin="10">
</userdefinedreport>
29 changes: 28 additions & 1 deletion src/Reports/UserDefinedReport/Template.cs
Expand Up @@ -44,7 +44,7 @@ public string Description
{
}

return "User Defined Report";
return "User Defined Report (currently undefined)";
}
}

Expand Down Expand Up @@ -81,6 +81,33 @@ public Margins Margins
{
get
{
try
{
var fileName = FileName(string.Format("UserDefinedReport.xml"));
if (File.Exists(fileName))
{
var doc = new XmlDocument();
doc.Load(fileName);
var root = doc.DocumentElement;
var leftmargin = root.Attributes["leftmargin"].Value;
var rightmargin = root.Attributes["rightmargin"].Value;
var topmargin = root.Attributes["topmargin"].Value;
var bottommargin = root.Attributes["bottommargin"].Value;
if (leftmargin != null && rightmargin != null && topmargin != null && bottommargin != null)
{
return new Margins(
Convert.ToInt32(leftmargin),
Convert.ToInt32(rightmargin),
Convert.ToInt32(topmargin),
Convert.ToInt32(bottommargin)
);
}
}
}
catch (Exception exception)
{
}

return new Margins(0, 0, 0, 0);
}
}
Expand Down

0 comments on commit 32f4f69

Please sign in to comment.