I am trying to create a footer with fixed postions for items patient name, Nhs no , page , mrn and DOB
Similar to what's below, but with a border and centered at the bottom of the page and in the center.
NHS No:123456 Patient Name: This is a test
Page 1 of 3 MRN:1234567
Printed 29 April 2015 DOB: 27/11/2010
My attempted code feels crude , as I was unsure how to construct this within the Spire component. I had to use multiple TextRange fields to apply the format to text items, just seemed that I was doing this wrong.
- Code: Select all
private void wordPrint(Document doc, PatientReportFooter footerInfo)
{
try
{
int i = doc.Sections.Count - 1;
Section lastSection = doc.Sections[0];
//Add Footer
HeaderFooter footer = lastSection.HeadersFooters.Footer;
Paragraph FParagraph = footer.AddParagraph();
//insert page number
TextRange FPatientDetails = FParagraph.AppendText
(footerInfo.getFormattedPatientName() + "\t" + footerInfo.getFormattedDOB() + "\t" +footerInfo.getFormattedMRN()
+ "\t" + footerInfo.getFormattedNHS());
TextRange FPageInfo = FParagraph.AppendText("Page:");
TextRange FPageInfo1 = FParagraph.AppendField("page number", FieldType.FieldPage);
TextRange FPageInfo2 = FParagraph.AppendText(" of ");
TextRange FPageInfo3 = FParagraph.AppendField("number of pages", FieldType.FieldNumPages);
TextRange FPrintedDetails = FParagraph.AppendText("Printed " + DateTime.Now.ToLocalTime());
FPageInfo.CharacterFormat.FontName = "Calibri";
FPageInfo.CharacterFormat.FontSize = 8;
FPageInfo.CharacterFormat.Bold = true;
FPageInfo.CharacterFormat.TextColor = System.Drawing.Color.Black;
FPageInfo1.CharacterFormat.TextColor = System.Drawing.Color.Black;
FPageInfo1.CharacterFormat.FontName = "Calibri";
FPageInfo1.CharacterFormat.FontSize = 8;
FPageInfo1.CharacterFormat.Bold = true;
FPageInfo2.CharacterFormat.FontName = "Calibri";
FPageInfo2.CharacterFormat.FontSize = 8;
FPageInfo2.CharacterFormat.Bold = true;
FPageInfo2.CharacterFormat.TextColor = System.Drawing.Color.Black;
FPageInfo3.CharacterFormat.FontName = "Calibri";
FPageInfo3.CharacterFormat.FontSize = 8;
FPageInfo3.CharacterFormat.Bold = true;
FPageInfo3.CharacterFormat.TextColor = System.Drawing.Color.Black;
FPatientDetails.CharacterFormat.FontName = "Calibri";
FPatientDetails.CharacterFormat.FontSize = 8;
FPatientDetails.CharacterFormat.Bold = true;
FPatientDetails.CharacterFormat.TextColor = System.Drawing.Color.Black;
FPrintedDetails.CharacterFormat.FontName = "Calibri";
FPrintedDetails.CharacterFormat.FontSize = 8;
FPrintedDetails.CharacterFormat.Bold = true;
FPrintedDetails.CharacterFormat.TextColor = System.Drawing.Color.Black;
//Set Footer Paragrah Format
FParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
FParagraph.Format.Borders.BorderType = Spire.Doc.Documents.BorderStyle.Thick;
FParagraph.Format.Borders.Top.Space = 0.15f;
FParagraph.Format.Borders.Color = System.Drawing.Color.Black;
FParagraph.Format.Borders.Space = 4.0f;
using (PrintDialog dialog = new PrintDialog())
{
doc.PrintDialog = dialog;
PrintDocument printDoc = doc.PrintDocument;
printDoc.PrintController = new StandardPrintController();
printDoc.Print();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}