Changed report format to increase font size, switch to landscape, add page numbers, add colum headings and add date generated.
This commit is contained in:
parent
85771b0dda
commit
9c62cc93eb
@ -33,6 +33,24 @@ namespace Volian.Print.Library
|
|||||||
get { return _FileName; }
|
get { return _FileName; }
|
||||||
set { _FileName = value; }
|
set { _FileName = value; }
|
||||||
}
|
}
|
||||||
|
private PdfPCell _CurrentPageNumberCell = null;
|
||||||
|
private int _CurrentPageNumber = 1;
|
||||||
|
public int CurrentPageNumber
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _CurrentPageNumber;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_CurrentPageNumberCell != null)
|
||||||
|
{
|
||||||
|
_CurrentPageNumber = value;
|
||||||
|
_CurrentPageNumberCell.Phrase.Clear();
|
||||||
|
_CurrentPageNumberCell.Phrase.Add("Page " + value.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private FolderInfo folderInfo;
|
private FolderInfo folderInfo;
|
||||||
private ProcedureInfo procedureInfo;
|
private ProcedureInfo procedureInfo;
|
||||||
private TransitionInfoList transitionInfoList;
|
private TransitionInfoList transitionInfoList;
|
||||||
@ -68,7 +86,7 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
public void BuildTransitionReport()
|
public void BuildTransitionReport()
|
||||||
{
|
{
|
||||||
iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36);
|
iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER.Rotate(), 36, 36, 36, 36);
|
||||||
if (!CreateResultsPDF(document)) return;
|
if (!CreateResultsPDF(document)) return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -137,10 +155,10 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
PdfOutline outline = null;
|
PdfOutline outline = null;
|
||||||
ProcedureInfo lastProcedureInfo = null;
|
ProcedureInfo lastProcedureInfo = null;
|
||||||
private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level)
|
private PdfPTable BuildProcedurePDFTable(Dictionary<int, string> levels, Dictionary<int, iTextSharp.text.Font> fonts, int cols, int paddingBottom, int level, iTextSharp.text.Document doc)
|
||||||
{
|
{
|
||||||
PdfPTable t = new PdfPTable(cols);
|
PdfPTable t = new PdfPTable(cols);
|
||||||
t.HeaderRows = 3;
|
t.HeaderRows = 4;
|
||||||
t.DefaultCell.Padding = 4;
|
t.DefaultCell.Padding = 4;
|
||||||
t.WidthPercentage = 100;
|
t.WidthPercentage = 100;
|
||||||
float[] widths;
|
float[] widths;
|
||||||
@ -157,10 +175,18 @@ namespace Volian.Print.Library
|
|||||||
else
|
else
|
||||||
h.Add("Transition Report");
|
h.Add("Transition Report");
|
||||||
PdfPCell c = new PdfPCell(h);
|
PdfPCell c = new PdfPCell(h);
|
||||||
c.Colspan = cols;
|
c.Colspan = cols-1;
|
||||||
c.HorizontalAlignment = Element.ALIGN_CENTER;
|
c.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||||
|
c.PaddingBottom = paddingBottom;
|
||||||
|
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod);
|
||||||
|
t.AddCell(c);
|
||||||
|
//date generated
|
||||||
|
h = new Phrase();
|
||||||
|
h.Font = fonts[4];
|
||||||
|
h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt"));
|
||||||
|
c = new PdfPCell(h);
|
||||||
|
c.HorizontalAlignment = Element.ALIGN_RIGHT;
|
||||||
c.PaddingBottom = paddingBottom;
|
c.PaddingBottom = paddingBottom;
|
||||||
//c.Border = borders;
|
|
||||||
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod);
|
c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod);
|
||||||
t.AddCell(c);
|
t.AddCell(c);
|
||||||
//procedure title
|
//procedure title
|
||||||
@ -174,12 +200,15 @@ namespace Volian.Print.Library
|
|||||||
lastProcedureInfo = procedureInfo;
|
lastProcedureInfo = procedureInfo;
|
||||||
}
|
}
|
||||||
c = new PdfPCell(h);
|
c = new PdfPCell(h);
|
||||||
c.Colspan = cols;
|
c.Colspan = cols-1;
|
||||||
c.HorizontalAlignment = Element.ALIGN_LEFT;
|
c.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||||
c.PaddingBottom = paddingBottom;
|
c.PaddingBottom = paddingBottom;
|
||||||
//c.Border = borders;
|
|
||||||
c.BackgroundColor = new Color(System.Drawing.Color.Goldenrod);
|
c.BackgroundColor = new Color(System.Drawing.Color.Goldenrod);
|
||||||
t.AddCell(c);
|
t.AddCell(c);
|
||||||
|
//page number
|
||||||
|
_CurrentPageNumberCell = BuildCell(1, string.Format("Page {0}",CurrentPageNumber), fonts[4], new Color(System.Drawing.Color.Goldenrod));
|
||||||
|
_CurrentPageNumberCell.PaddingBottom = paddingBottom;
|
||||||
|
t.AddCell(_CurrentPageNumberCell);
|
||||||
//transition category
|
//transition category
|
||||||
h = new Phrase();
|
h = new Phrase();
|
||||||
h.Font = fonts[3];
|
h.Font = fonts[3];
|
||||||
@ -197,6 +226,31 @@ namespace Volian.Print.Library
|
|||||||
c.PaddingBottom = paddingBottom;
|
c.PaddingBottom = paddingBottom;
|
||||||
c.BackgroundColor = new Color(System.Drawing.Color.Khaki);
|
c.BackgroundColor = new Color(System.Drawing.Color.Khaki);
|
||||||
t.AddCell(c);
|
t.AddCell(c);
|
||||||
|
//add column headers
|
||||||
|
h = new Phrase();
|
||||||
|
h.Font = fonts[4];
|
||||||
|
h.Add("From Procedure Location");
|
||||||
|
c = new PdfPCell(h);
|
||||||
|
c.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||||
|
c.PaddingBottom = paddingBottom;
|
||||||
|
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
|
||||||
|
t.AddCell(c);
|
||||||
|
h = new Phrase();
|
||||||
|
h.Font = fonts[4];
|
||||||
|
h.Add("From Procedure Text");
|
||||||
|
c = new PdfPCell(h);
|
||||||
|
c.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||||
|
c.PaddingBottom = paddingBottom;
|
||||||
|
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
|
||||||
|
t.AddCell(c);
|
||||||
|
h = new Phrase();
|
||||||
|
h.Font = fonts[4];
|
||||||
|
h.Add("To Procedure Location");
|
||||||
|
c = new PdfPCell(h);
|
||||||
|
c.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||||
|
c.PaddingBottom = paddingBottom;
|
||||||
|
c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod);
|
||||||
|
t.AddCell(c);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
PdfContentByte cb;
|
PdfContentByte cb;
|
||||||
@ -210,17 +264,17 @@ namespace Volian.Print.Library
|
|||||||
levels.Add(4, "Outside From Transitions");
|
levels.Add(4, "Outside From Transitions");
|
||||||
levels.Add(5, "Outside To Transitions");
|
levels.Add(5, "Outside To Transitions");
|
||||||
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>();
|
Dictionary<int, iTextSharp.text.Font> fonts = new Dictionary<int, Font>();
|
||||||
fonts.Add(1, pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK));
|
fonts.Add(1, pdf.GetFont("Arial Unicode MS", 12, 0, Color.BLACK));
|
||||||
fonts.Add(2, pdf.GetFont("Arial Unicode MS", 8, 0, Color.BLACK));
|
fonts.Add(2, pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK));
|
||||||
fonts.Add(3, pdf.GetFont("Arial Unicode MS", 6, 0, Color.BLACK));
|
fonts.Add(3, pdf.GetFont("Arial Unicode MS", 8, 0, Color.BLACK));
|
||||||
fonts.Add(4, pdf.GetFont("Arial Unicode MS", 4, 0, Color.BLACK));
|
fonts.Add(4, pdf.GetFont("Arial Unicode MS", 8, 0, Color.BLACK));
|
||||||
int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level
|
int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level
|
||||||
#region buildtable
|
#region buildtable
|
||||||
int cols = 3;
|
int cols = 3;
|
||||||
int paddingBottom = 6;
|
int paddingBottom = 6;
|
||||||
if (folderInfo != null)
|
if (folderInfo != null)
|
||||||
doc.NewPage();
|
doc.NewPage();
|
||||||
PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
|
PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc);
|
||||||
#endregion
|
#endregion
|
||||||
//gather data
|
//gather data
|
||||||
if (transitionInfoList.Count == 0)
|
if (transitionInfoList.Count == 0)
|
||||||
@ -247,7 +301,7 @@ namespace Volian.Print.Library
|
|||||||
doc.Add(t);
|
doc.Add(t);
|
||||||
doc.NewPage();
|
doc.NewPage();
|
||||||
lastLevel = ti.Level;
|
lastLevel = ti.Level;
|
||||||
t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel);
|
t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//add from path
|
//add from path
|
||||||
@ -364,6 +418,7 @@ namespace Volian.Print.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
|
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
|
||||||
|
writer.PageEvent = new MyPageEvent(this);
|
||||||
document.SetMargins(36, 36, 36, 36);
|
document.SetMargins(36, 36, 36, 36);
|
||||||
document.Open();
|
document.Open();
|
||||||
cb = writer.DirectContent;
|
cb = writer.DirectContent;
|
||||||
@ -411,5 +466,29 @@ namespace Volian.Print.Library
|
|||||||
c.Border = 0;
|
c.Border = 0;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
private PdfPCell BuildCell(int colspan, string txt, Font f, iTextSharp.text.Color clr)
|
||||||
|
{
|
||||||
|
Phrase h = new Phrase();
|
||||||
|
h.Font = f;
|
||||||
|
h.Add(txt);
|
||||||
|
PdfPCell c = new PdfPCell(h);
|
||||||
|
c.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT;
|
||||||
|
c.Colspan = colspan;
|
||||||
|
c.BackgroundColor = clr;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class MyPageEvent : PdfPageEventHelper
|
||||||
|
{
|
||||||
|
private PDFTransitionReport _rpt = null;
|
||||||
|
public MyPageEvent(PDFTransitionReport rpt)
|
||||||
|
{
|
||||||
|
_rpt = rpt;
|
||||||
|
}
|
||||||
|
public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
|
||||||
|
{
|
||||||
|
base.OnEndPage(writer, document);
|
||||||
|
_rpt.CurrentPageNumber = writer.PageNumber + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user