|
Rank: Newbie Groups: Member
Joined: 8/12/2016 Posts: 6
|
We just upgraded to the latest release of 2016.1.68 and we are experiencing issues with the headers and footers all being displayed on the first page, instead of each respective page. This did not occur before, is there any insight available on this?
Thanks, James
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please explain how you create header and footer, we can then go from there.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/12/2016 Posts: 6
|
Hello, Thanks for the fast response, here is the code we have to create the header and footer template, and build the main section out.
Code: C#
public static void BuildReportHeaderFooter(HtmlToPdfOptions options, Guid siteId, bool reportIsConfidential, Uri sourceUri)
{
var headerLeftHtml = BuildHfSection("HeaderLeft", siteId, reportIsConfidential, sourceUri);
var headerRightHtml = BuildHfSection("HeaderRight", siteId, reportIsConfidential, sourceUri);
const string template =
"<div style=\"color: #303030; font-family: '{0}', sans-serif; font-size: {1};\"><div style='float: left;'>{2}</div><div style='float: right;'>{3}</div></div>";
var family = FixFontFamily(SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.ReportFontFamily));
var size = FixFontSize(SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.ReportFontSize));
if (!(string.IsNullOrEmpty(headerLeftHtml) && string.IsNullOrEmpty(headerRightHtml)))
options.HeaderHtmlFormat = string.Format(template, family, size, headerLeftHtml, headerRightHtml);
var footerLeftHtml = BuildHfSection("FooterLeft", siteId, reportIsConfidential, sourceUri);
var footerRightHtml = BuildHfSection("FooterRight", siteId, reportIsConfidential, sourceUri);
if (!(string.IsNullOrEmpty(footerLeftHtml) && string.IsNullOrEmpty(footerRightHtml)))
options.FooterHtmlFormat = string.Format(template, family, size, footerLeftHtml, footerRightHtml);
}
Code: C#
public static string BuildHfSection(string section, Guid siteId, bool reportIsConfidential, Uri sourceUri)
{
var sectionHTML = string.Empty;
switch (SiteSettingsOds.GetSiteSetting("Report" + section))
{
case "OrganizationName":
if (Convert.ToBoolean(SiteSettingsOds.GetSiteSetting("Report" + section + "ShowImage")))
{
var imageRelativePath = SiteSettingsOds.GetSiteSetting("Report" + section + "ImagePath");
imageRelativePath = imageRelativePath.Replace("/Planning Web Site", "/planning");
var imageFullPath = ConvertRelativeUrlToAbsoluteUrl(imageRelativePath);
var height = ServiceContext.CurrentInstitutionRequest != null
? GetHeight(imageFullPath)
: ImageHeight(MapPath(imageRelativePath));
sectionHTML = string.Format(
"<table><tr><td><img src='{0}' alt='' /></td><td>{1}<!--IMAGE_HEIGHT:{2}:--></td></tr></table>",
imageFullPath,
SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.SchoolName),
height);
}
else
sectionHTML = SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.SchoolName);
break;
case "DateTime":
var organizationTz = TimeZoneInfo.FindSystemTimeZoneById(CAA_Helper.GetSiteTimeZoneName());
var localizedDt = TimeZoneInfo.ConvertTime(DateTime.Now, organizationTz);
sectionHTML = localizedDt.ToShortDateString() + " " + localizedDt.ToShortTimeString();
break;
case "Confidential":
if (Convert.ToBoolean(SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.ReportsAllowConfidential))
&& reportIsConfidential)
sectionHTML = SiteSettingsOds.GetSiteSetting(siteId, SiteSettingKeys.ReportsConfidentialMessage);
break;
case "PageNumber":
sectionHTML = PrintHelper.GetPageNumberFormatString(section);
break;
case "Custom":
if (Convert.ToBoolean(SiteSettingsOds.GetSiteSetting("Report" + section + "ShowImage")))
{
var imageRelativePath = SiteSettingsOds.GetSiteSetting("Report" + section + "ImagePath");
imageRelativePath = imageRelativePath.Replace("/Planning Web Site", "/planning");
var imageFullPath = ConvertRelativeUrlToAbsoluteUrl(imageRelativePath);
var height = ServiceContext.CurrentInstitutionRequest != null
? GetHeight(imageFullPath)
: ImageHeight(MapPath(imageRelativePath));
sectionHTML = string.Format(
"<table><tr><td><img src='{0}' alt='' /></td><td>{1}<!--IMAGE_HEIGHT:{2}:--></td></tr></table>",
imageFullPath,
SiteSettingsOds.GetSiteSetting("Report" + section + "Custom"),
height);
}
else
sectionHTML = SiteSettingsOds.GetSiteSetting("Report" + section + "Custom");
break;
}
return sectionHTML;
}
|
|
Rank: Newbie Groups: Member
Joined: 8/12/2016 Posts: 6
|
eo_support wrote:Hi,
Please explain how you create header and footer, we can then go from there.
Thanks!
Code: C#
Pdf Options
FooterHtmlFormat
"<div style=\"color: #303030; font-family: 'Arial', sans-serif; font-size: 12;\"><div style='float: left;'>(Simple Footer Left)</div><div style='float: right;'>(Simple Footer Right)</div></div>"
HeaderHtmlFormat
"<div style=\"color: #303030; font-family: 'Arial', sans-serif; font-size: 12;\"><div style='float: left;'>[Simple Header Left]</div><div style='float: right;'>[Simple Header Right]</div></div>"
Also based on the code, these are the formats in the pdf options after the code is run. Thanks, James
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Please give an explicit height of your header and footer HTML. When you use float:left and float:right, the outter DIV has zero height. And that can cause problems with spreading header/footer to other pages. So for example, you can change it to something like this:
Code: HTML/ASPX
<div style="color: #303030; font-family: 'Arial', sans-serif; font-size: 12;height:20px">
<div style='float: left;'>(Simple Footer Left)</div>
<div style='float: right;'>(Simple Footer Right)</div>
</div>
Note the added height:20px CSS attribute for the outer DIV. Please let us know if this works for you. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/12/2016 Posts: 6
|
eo_support wrote:Hi, Please give an explicit height of your header and footer HTML. When you use float:left and float:right, the outter DIV has zero height. And that can cause problems with spreading header/footer to other pages. So for example, you can change it to something like this:
Code: HTML/ASPX
<div style="color: #303030; font-family: 'Arial', sans-serif; font-size: 12;height:20px">
<div style='float: left;'>(Simple Footer Left)</div>
<div style='float: right;'>(Simple Footer Right)</div>
</div>
Note the added height:20px CSS attribute for the outer DIV. Please let us know if this works for you. Thanks! Hello, thank you so much for your solution. This is having a very positive impact and they are now in separate pages as I would normally expect. Thanks once again! - James
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Glad to hear that it works! Please feel free to let us know if there is anything else.
|
|