diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 42eeefee..c39b25c0 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -14,6 +14,18 @@ namespace Volian.Print.Library public class VlnSvgPageHelper:SvgPageHelper { + private vlnText _TopMessage; + public vlnText TopMessage + { + get { return _TopMessage; } + set { _TopMessage = value; } + } + private vlnText _BottomMessage; + public vlnText BottomMessage + { + get { return _BottomMessage; } + set { _BottomMessage = value; } + } //vlnParagraphs _MyParagraphs = new vlnParagraphs(null); //public vlnParagraphs MyParagraphs //{ @@ -36,12 +48,26 @@ namespace Volian.Print.Library { base.OnEndPage(writer, document); DrawChangeBars(writer.DirectContent); + DrawMessages(writer.DirectContent); //DrawBackground(writer.DirectContentUnder); //DrawPageList(writer.DirectContent); //DrawWatermark(writer.DirectContentUnder); //DrawZoomOMatic(writer.DirectContent); //CurrentPageNumber++; } + private void DrawMessages(PdfContentByte cb) + { + if (TopMessage != null) + { + TopMessage.ToPdf(cb, 0, 0, 0); + TopMessage = null; // Only output it once. + } + if (BottomMessage != null) + { + BottomMessage.ToPdf(cb, 0, 0, 0); + BottomMessage = null; // Only output it once. + } + } private void DrawChangeBars(PdfContentByte cb) { foreach (vlnChangeBar vcb in MyChangeBars) @@ -195,16 +221,16 @@ namespace Volian.Print.Library if (cb.MyParent.MyItemInfo.MyHLS.ItemID != vcb.MyParent.MyItemInfo.MyHLS.ItemID) return false; // cb.Yoffset is within range of vcb: if (cb.YOffset <= vcb.YOffset && - cb.YOffset >= (vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true; + cb.YOffset >= (vcb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch)) return true; // cb.YChangeBarBottom is within range of vcb: - if ((cb.YChangeBarBottomExtend-vlnPrintObject._SixLinesPerInch) <= vcb.YOffset && - cb.YChangeBarBottomExtend >= (vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true; + if ((cb.YChangeBarBottomExtend-vlnPrintObject.SixLinesPerInch) <= vcb.YOffset && + cb.YChangeBarBottomExtend >= (vcb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch)) return true; // vcb.Yoffset is within range of cb: if (vcb.YOffset <= cb.YOffset && - vcb.YOffset >= (cb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true; + vcb.YOffset >= (cb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch)) return true; // vcb.YChangeBarBottom is within range of cb: - if ((vcb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch) <= cb.YOffset && - vcb.YChangeBarBottomExtend >= (cb.YChangeBarBottomExtend - vlnPrintObject._SixLinesPerInch)) return true; + if ((vcb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch) <= cb.YOffset && + vcb.YChangeBarBottomExtend >= (cb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch)) return true; return false; } public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection) diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index 715ef97d..7fb0143c 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -32,7 +32,12 @@ namespace Volian.Print.Library protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3. protected static float _WidthAdjustBox = 6; protected static float _CharsToTwips = 6; // assumes 12 char per inch - internal static float _SixLinesPerInch = 12; // twips + private static float _SixLinesPerInch = 12; // twips + public static float SixLinesPerInch + { + get { return vlnPrintObject._SixLinesPerInch; } + set { vlnPrintObject._SixLinesPerInch = value; } + } protected static float _SevenLinesPerInch = 10.1F;//72F / 7F; protected float _XOffset; @@ -196,7 +201,8 @@ namespace Volian.Print.Library StringBuilder rtfSB = new StringBuilder(); //DisplayText vlntxt = new DisplayText(text.TrimStart(" ".ToCharArray()), vFont, false); DisplayText vlntxt = new DisplayText(text, vFont, false); - rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont)); + //rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont)); + rtfSB.Append(AddFontTable(vFont.WindowsFont)); rtfSB.Append(vlntxt.StartText); rtfSB.Append("}"); return rtfSB.ToString(); @@ -266,19 +272,20 @@ namespace Volian.Print.Library } public void DebugPdf(PdfContentByte cb, float left, float top) { - cb.SaveState(); VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; - if (debugLayer != null) cb.BeginLayer(debugLayer); + if (debugLayer == null) return; + cb.SaveState(); + cb.BeginLayer(debugLayer); ColumnText ct = new ColumnText(cb); ct.SetSimpleColumn(left, top, left+50, top - 50); iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2); Chunk chk = new Chunk(DebugId.ToString(), font); Phrase ph = new Phrase(chk); ct.AddElement(ph); - cb.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.CadetBlue)); + cb.SetColorFill(new iTextSharp.text.Color(PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray))); ct.Go(); - if (debugLayer != null) cb.EndLayer(); + cb.EndLayer(); cb.RestoreState(); } } diff --git a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs index ca8f1d97..a63c45e9 100644 --- a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs +++ b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs @@ -34,7 +34,7 @@ namespace Volian.Print.Library { MyContentByte = cb; float yLocation = CalculateYOffset(yPageStart, yTopMargin); - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, ""); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin); return yPageStart; } } diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index 15d639ec..c295513a 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -8,16 +8,12 @@ using VEPROMS.CSLA.Library; namespace Volian.Print.Library { - public partial class vlnTab : vlnPrintObject + public partial class vlnTab : vlnText { - public float TabWidth - { - get { return _CharsToTwips * TabText.Length; } - } - private float? _TabAlign; /// /// Used to Align Tabs for numeric tabs that can go to 2 digits /// + private float? _TabAlign; public float TabAlign // Offset to Last printable character { get @@ -25,13 +21,13 @@ namespace Volian.Print.Library if (_TabAlign == null) { _TabAlign = 0; - if (_TabText != null) + if (Text != null) { - while (_TabText[(int)_TabAlign] == ' ') + while (Text[(int)_TabAlign] == ' ') _TabAlign++; - if ("0123456789".Contains(_TabText[(int)_TabAlign].ToString())) + if ("0123456789".Contains(Text[(int)_TabAlign].ToString())) { - while ("0123456789".Contains(_TabText[(int)_TabAlign].ToString())) + while ("0123456789".Contains(Text[(int)_TabAlign].ToString())) _TabAlign++; _TabAlign--; } @@ -48,38 +44,28 @@ namespace Volian.Print.Library if (_TabOffset == null) { _TabOffset = 0; - if (_TabText != null) - while (_TabText[(int)_TabOffset] == ' ') + if (Text != null) + while (Text[(int)_TabOffset] == ' ') _TabOffset++; } return (float)_TabOffset * _CharsToTwips; } } - private string _TabText; - public string TabText - { - get { return _TabText; } - set { _TabText = value; } - } - private VE_Font _MyFont; - public VE_Font MyFont - { - get { return _MyFont; } - set { _MyFont = value; } - } - public vlnTab(PdfContentByte cb, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont) + public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont) { MyContentByte = cb; + MyParent = myparent; YOffset = yoffset; - TabText = cleanTab; + Text = cleanTab; + Width = _CharsToTwips * Text.Length; Rtf = GetRtf(origTab, vFont); - XOffset = xoffset - TabWidth; + XOffset = xoffset - Width; MyFont = vFont; } public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = CalculateYOffset(yPageStart, yTopMargin); - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, TabWidth, 100, ""); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin); return yPageStart; } } diff --git a/PROMS/Volian.Print.Library/vlnText.cs b/PROMS/Volian.Print.Library/vlnText.cs new file mode 100644 index 00000000..961664e9 --- /dev/null +++ b/PROMS/Volian.Print.Library/vlnText.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using iTextSharp.text.pdf; +using iTextSharp.text; +using VEPROMS.CSLA.Library; + +namespace Volian.Print.Library +{ + public partial class vlnText : vlnPrintObject + { + //public float Width + //{ + // get { return _CharsToTwips * Text.Length; } + //} + private string _Text; + public string Text + { + get { return _Text; } + set { _Text = value; } + } + private VE_Font _MyFont; + public VE_Font MyFont + { + get { return _MyFont; } + set { _MyFont = value; } + } + public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont) + { + MyContentByte = cb; + MyParent = myparent; + YOffset = yoffset; + Text = cleanText; + Rtf = GetRtf(origText, vFont); + XOffset = xoffset; // -Width; + MyFont = vFont; + Width = _CharsToTwips * (Text.Length + 2); + } + public vlnText() + { + } + public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + { + float yLocation = CalculateYOffset(yPageStart, yTopMargin); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, YOffset, Width, 100, "", yBottomMargin); + return yPageStart; + } + } +}