From 893282d7a283faec0ee8ad29a255613626864c47 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 16 Jun 2010 14:10:02 +0000 Subject: [PATCH] --- PROMS/Volian.Print.Library/Rtf2Pdf.cs | 20 ++++---- PROMS/Volian.Print.Library/vlnBox.cs | 57 +++++++++++++++++++++- PROMS/Volian.Print.Library/vlnChangeBar.cs | 6 +-- PROMS/Volian.Print.Library/vlnHeader.cs | 29 ++--------- PROMS/Volian.Print.Library/vlnMacro.cs | 2 +- 5 files changed, 76 insertions(+), 38 deletions(-) diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index 87a4ba1a..9ceeb7c4 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -56,7 +56,7 @@ namespace Volian.Print.Library { while (yTop > 0) { - float newYTop = TextAt(cb, para, x, yTop - 12F, width, 100,""); + float newYTop = TextAt(cb, para, x, yTop - 12F, width, 100,"",36); //Console.WriteLine("{0},{1},{2}", yTop, width, newYTop); width -= 16; yTop = newYTop; @@ -74,7 +74,7 @@ namespace Volian.Print.Library get { return Rtf2Pdf._Offset; } set { Rtf2Pdf._Offset = value; } } - public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText) + public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) { VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; @@ -83,7 +83,7 @@ namespace Volian.Print.Library float right = left + width; float bottom = top - height; ColumnText myColumnText = new ColumnText(cb); - myColumnText.SetSimpleColumn(left, top, left + width,36); // Bottom margin + myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); myColumnText.AddElement(iParagraph); float pos = myColumnText.YLine; // Save the position to be used if the paragraph fits int status = myColumnText.Go(true); // Check to see if it will fit on the page. @@ -100,16 +100,18 @@ namespace Volian.Print.Library if (iParagraph.Font.BaseFont != null) yDescent = -iParagraph.Font.BaseFont.GetDescentPoint("Almg", iParagraph.Font.Size); if (PdfDebug) - DrawPdfDebug(cb, System.Drawing.Color.CadetBlue, left, top, left + width, myColumnText.YLine, debugText,yDescent); + DrawPdfDebug(cb, left, top, left + width, myColumnText.YLine, debugText,yDescent); return myColumnText.YLine; } - private static void DrawPdfDebug(PdfContentByte cb, System.Drawing.Color sysColor, float left, float top, float right, float bottom, string debugText, float yDescent) + private static void DrawPdfDebug(PdfContentByte cb, float left, float top, float right, float bottom, string debugText, float yDescent) { - // yAdj is dependent on the size of the font and the spacing between lines. - 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; + System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); + // yAdj is dependent on the size of the font and the spacing between lines. + cb.SaveState(); + cb.BeginLayer(debugLayer); cb.SetColorStroke(new Color(sysColor)); cb.SetLineWidth(.1F); cb.MoveTo(left, top - yDescent); @@ -129,7 +131,7 @@ namespace Volian.Print.Library cb.SetColorFill(new Color(sysColor)); ct.Go(); } - if (debugLayer != null) cb.EndLayer(); + cb.EndLayer(); cb.RestoreState(); } } diff --git a/PROMS/Volian.Print.Library/vlnBox.cs b/PROMS/Volian.Print.Library/vlnBox.cs index 48a22ce6..61a7689d 100644 --- a/PROMS/Volian.Print.Library/vlnBox.cs +++ b/PROMS/Volian.Print.Library/vlnBox.cs @@ -18,12 +18,67 @@ namespace Volian.Print.Library get { return _Color; } set { _Color = value; } } - public vlnBox(vlnParagraph paragraph/*, FormatBox box*/) + private Box _MyBox; + + public Box MyBox + { + get { return _MyBox; } + set { _MyBox = value; } + } + public vlnBox() { } + public vlnBox(vlnParagraph paragraph) + { + } + const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . "; + const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . "; public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { + cb.SaveState(); + VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); + MyContentByte = cb; + Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath); + float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier); + float bottom = top - (Height * MyPageHelper.YMultiplier); + float leftmargin = (float)MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin + 3; + float left = leftmargin + (float)(MyBox.Start ?? 0); + float right = leftmargin + (float)MyBox.End; + iTextSharp.text.Color boxColor = new iTextSharp.text.Color(PrintOverride.OverrideBoxColor(System.Drawing.Color.Black)); + cb.SetColorStroke(boxColor); + switch (MyBox.BoxStyle) + { + case BoxThin: + cb.SetLineWidth(.6F); + cb.Rectangle(left, bottom, right - left, Height*MyPageHelper.YMultiplier); + break; + case BoxThick: + float lineThickness = 6; + cb.SetLineWidth(lineThickness); + cb.Rectangle(left, bottom + (lineThickness/2), right - left, (Height - lineThickness)*MyPageHelper.YMultiplier); + break; + default: + // For other than OHLP/HLP. For those not matching the HLP Boxes + throw new Exception("Missing vlnBox handler"); + break; + } + cb.Stroke(); + if (textLayer != null) cb.EndLayer(); + cb.RestoreState(); return yPageStart; } + + private string CharToAsc(string p) + { + StringBuilder sb = new StringBuilder(); + foreach (char c in p) + { + if (c >= ' ' && c < 127) sb.Append(c); + else sb.Append(string.Format("\\x{0:x}", (int)c)); + } + return sb.ToString(); + } } } diff --git a/PROMS/Volian.Print.Library/vlnChangeBar.cs b/PROMS/Volian.Print.Library/vlnChangeBar.cs index 0645024f..164f1291 100644 --- a/PROMS/Volian.Print.Library/vlnChangeBar.cs +++ b/PROMS/Volian.Print.Library/vlnChangeBar.cs @@ -105,7 +105,7 @@ namespace Volian.Print.Library vlnHeader tmp = vph as vlnHeader; // the separator must exist and the previous must have a change bar. - if ((sep != "") && (tmp.HeaderText == sep) && parent.MyItemInfo.MyPrevious != null && parent.MyItemInfo.MyPrevious.HasChangeBar()) + if ((sep != "") && (tmp.Text == sep) && parent.MyItemInfo.MyPrevious != null && parent.MyItemInfo.MyPrevious.HasChangeBar()) { vlnParagraph prev = MyPageHelper.MyParagraphs[parent.MyItemInfo.MyPrevious.ItemID]; float delta = parent.YOffset - prev.YOffset; @@ -131,7 +131,7 @@ namespace Volian.Print.Library float xAdj = 3F; //cb.SetColorStroke(Color.GREEN); // TODO: Should default to black - iTextSharp.text.Color changeBarColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green)); + iTextSharp.text.Color changeBarColor = new iTextSharp.text.Color(PrintOverride.OverrideChangeBarColor(System.Drawing.Color.Black)); cb.SetColorStroke(changeBarColor); cb.SetLineWidth(.5F); cb.MoveTo(XOffset + xAdj, YOffset - yAdj); // combination yStart and YOffset @@ -166,7 +166,7 @@ namespace Volian.Print.Library float w = vlnPrintObject.GetTableWidth(cb, myparagraph); float h = vlnPrintObject.GetParagraphHeight(cb, myparagraph, w); cb.SetColorFill(changeBarColor); - Rtf2Pdf.TextAt(cb, myparagraph, XOffset + xAdj - Rtf2Pdf.Offset.X + 3, yBottom + h - Rtf2Pdf.Offset.Y + 2.7F, w, h, ""); + Rtf2Pdf.TextAt(cb, myparagraph, XOffset + xAdj - Rtf2Pdf.Offset.X + 3, yBottom + h - Rtf2Pdf.Offset.Y + 2.7F, w, h, "", yBottomMargin); lastMsg = vcbm.Message; } } diff --git a/PROMS/Volian.Print.Library/vlnHeader.cs b/PROMS/Volian.Print.Library/vlnHeader.cs index 54154cda..87a50fbc 100644 --- a/PROMS/Volian.Print.Library/vlnHeader.cs +++ b/PROMS/Volian.Print.Library/vlnHeader.cs @@ -8,46 +8,27 @@ using VEPROMS.CSLA.Library; namespace Volian.Print.Library { - public partial class vlnHeader : vlnPrintObject + public partial class vlnHeader: vlnText { public float HeaderWidth { - get { return _WidthAdjust + (_CharsToTwips * HeaderText.Length); } + get { return _WidthAdjust + (_CharsToTwips * Text.Length); } } - private string _HeaderText; - public string HeaderText - { - get { return _HeaderText; } - set { _HeaderText = value; } - } - private VE_Font _MyFont; - public VE_Font MyFont - { - get { return _MyFont; } - set { _MyFont = value; } - } - private ContentAlignment _ContentAlignment; - public ContentAlignment ContentAlignment - { - get { return _ContentAlignment; } - set { _ContentAlignment = value; } - } - public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont, System.Drawing.ContentAlignment ca) + public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont) { MyParent = myParent; MyContentByte = cb; YOffset = yoffset; Width = MyParent.Width; - HeaderText = cleanStr; + Text = cleanStr; Rtf = GetRtf(origStr, vFont); XOffset = xoffset; MyFont = vFont; - ContentAlignment = ca; } public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) { float yLocation = CalculateYOffset(yPageStart, yTopMargin); - Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, HeaderWidth, 100, ""); + Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, HeaderWidth, 100, "", yBottomMargin); return yPageStart; } } diff --git a/PROMS/Volian.Print.Library/vlnMacro.cs b/PROMS/Volian.Print.Library/vlnMacro.cs index ab53adbf..d243ef38 100644 --- a/PROMS/Volian.Print.Library/vlnMacro.cs +++ b/PROMS/Volian.Print.Library/vlnMacro.cs @@ -27,7 +27,7 @@ namespace Volian.Print.Library MyContentByte = cb; float yLocation = CalculateYOffset(yPageStart, yTopMargin); // Adjust the starting point for the Macro if the LPI is 7 - if (MyPageHelper.YMultiplier != 1) yLocation += _SixLinesPerInch - _SevenLinesPerInch; + if (MyPageHelper.YMultiplier != 1) yLocation += SixLinesPerInch - _SevenLinesPerInch; VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; if (textLayer != null) cb.BeginLayer(textLayer);