- Fixed Header for EquipmentWBlank

- Aligned Tables properly
- Skip Section Title
- Calculated Table Width
- Fixed ChangeBar logic
- Added Text and Debug layers
- Adedd debug output to PDF
- Changed Paginate logic
- Adedd debug output to PDF
- Move GetParagraphHeight
- Added GetTableWidth
- Added ChangeBar Properties
- Added Debug and Text layers
Removed fixed override color for SVG
Removed simple PageBreak
This commit is contained in:
Rich
2010-05-25 16:15:26 +00:00
parent 9cc6174ad1
commit b00005780b
7 changed files with 249 additions and 54 deletions

View File

@@ -57,27 +57,17 @@ 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,"");
//Console.WriteLine("{0},{1},{2}", yTop, width, newYTop);
width -= 16;
yTop = newYTop;
}
}
public static float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width)
private static bool _PdfDebug = true;
public static bool PdfDebug
{
ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin
myColumnText.AddElement(iParagraph);
//myColumnText.UseAscender = true;// Adjusts to the top of the text box.
int status = myColumnText.Go(true); // Check to see if it will fit on the page.
if (ColumnText.HasMoreText(status)) throw(new Exception("Paragraph longer than a page"));
return 792F - myColumnText.YLine; // This gives the height of the Paragraph
}
private static bool _DrawBox = true;
public static bool DrawBox
{
get { return Rtf2Pdf._DrawBox; }
set { Rtf2Pdf._DrawBox = value; }
get { return Rtf2Pdf._PdfDebug; }
set { Rtf2Pdf._PdfDebug = value; }
}
private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0);
public static System.Drawing.PointF Offset
@@ -85,8 +75,11 @@ 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)
public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText)
{
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
float left = x + Offset.X;
float top = y + Offset.Y;
float right = left + width;
@@ -111,14 +104,21 @@ namespace Volian.Print.Library
//Console.WriteLine("Calculated Bottom {0}, YLine {1}", top - textHeight, myColumnText.YLine);
//BoxText(cb, System.Drawing.Color.BurlyWood, left, top, left + width, top - height);
//BoxText(canvas, System.Drawing.Color.CadetBlue, left, top, left + width, top - textHeight);
if(DrawBox)BoxText(cb, System.Drawing.Color.CadetBlue, left, top, left + width, myColumnText.YLine);
if (textLayer != null) cb.EndLayer();
if (PdfDebug)
DrawPdfDebug(cb, System.Drawing.Color.CadetBlue, left, top, left + width, myColumnText.YLine, debugText);
//Console.WriteLine("Lines = {0}", myColumnText.LinesWritten);
return myColumnText.YLine;
}
private static void BoxText(PdfContentByte cb, System.Drawing.Color sysColor, float left, float top, float right, float bottom)
private static void DrawPdfDebug(PdfContentByte cb, System.Drawing.Color sysColor, float left, float top, float right, float bottom, string debugText)
{
float yAdj = 3;
cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer != null) cb.BeginLayer(debugLayer);
cb.SetColorStroke(new Color(sysColor));
cb.SetLineWidth(.1F);
cb.MoveTo(left, top - yAdj);
@@ -127,6 +127,15 @@ namespace Volian.Print.Library
cb.LineTo(left, bottom - yAdj);
cb.LineTo(left, top - yAdj);
cb.Stroke();
ColumnText ct = new ColumnText(cb);
ct.SetSimpleColumn(left, 4 + top - yAdj, right, top - yAdj - 50);
iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2);
Chunk chk = new Chunk(debugText, font);
Phrase ph = new Phrase(chk);
ct.AddElement(ph);
cb.SetColorFill(new Color(sysColor));
ct.Go();
if (debugLayer != null) cb.EndLayer();
cb.RestoreState();
}