This commit is contained in:
2010-06-16 14:10:02 +00:00
parent e0df82c11d
commit 893282d7a2
5 changed files with 76 additions and 38 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);