Override the default font for Demo Mode
Check for null MyFlexGrid before using it. Added Static LineWidth0 method used for drawing borders on the screen Fixed logic to draw borders on the VlnFlexGrid Fixed logic to draw grid borders on the pdf output.
This commit is contained in:
@@ -124,12 +124,12 @@ namespace Volian.Print.Library
|
||||
}
|
||||
public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
|
||||
{
|
||||
ZoomGrid(myColumnText, left, top);
|
||||
//ZoomGrid(myColumnText, left, top);
|
||||
MyCells.ToPdf(myColumnText, left, top);
|
||||
}
|
||||
private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top)
|
||||
{
|
||||
PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top + 4 - Height, left + Width, top + 4);
|
||||
PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4);
|
||||
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), left, top - Height, left + Width, top);
|
||||
}
|
||||
#endregion
|
||||
@@ -192,14 +192,14 @@ namespace Volian.Print.Library
|
||||
else
|
||||
myRTB.Text = str;
|
||||
myRTB.SelectAll();
|
||||
myRTB.SelectionColor = System.Drawing.Color.Black;
|
||||
myRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black);
|
||||
str = myRTB.Rtf;
|
||||
}
|
||||
iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
|
||||
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
|
||||
myPara.MultipliedLeading = 1.2F;
|
||||
myColumnText1.AddElement(myPara);
|
||||
//myColumnText1.Canvas.SetColorFill(iTextSharp.text.BaseColor.RED);
|
||||
//myColumnText1.Canvas.SetColorFill(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
|
||||
float posBefore = myColumnText1.YLine;
|
||||
int status = myColumnText1.Go(true);
|
||||
float posAfter = myColumnText1.YLine;
|
||||
@@ -606,7 +606,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
PdfContentByte cb = myColumnText.Canvas;
|
||||
cb.SaveState();// Save state before drawing borders
|
||||
SetOpacity(cb, .7F); // This line makes the borders transparent for testing
|
||||
//SetOpacity(cb, .7F); // This line makes the borders transparent for testing
|
||||
float xLeft = left + x + XOffset;
|
||||
float yTop = top - y + YOffset;
|
||||
float xRight = left + x + w + XOffset;
|
||||
@@ -630,30 +630,31 @@ namespace Volian.Print.Library
|
||||
{
|
||||
if (LinePattern != GridLinePattern.None)
|
||||
{
|
||||
float direction = (xStart < xEnd) ? 1 : -1;
|
||||
InitializeLineStyle(cb);
|
||||
SetLineColor(cb, r1, c1, side);
|
||||
if (LinePattern == GridLinePattern.Double)
|
||||
{
|
||||
// Top Line
|
||||
float dStart = -DoubleIntersectionRight(startToLeft, startToRight, startAhead);
|
||||
float dEnd = DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * DoubleIntersectionRight(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForDouble, xStart + dStart, y + DoubleLineOffset, xEnd + dEnd, y + DoubleLineOffset);
|
||||
// Bottom Line
|
||||
dStart = -DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
|
||||
dEnd = DoubleIntersectionRight(endToLeft, endToRight, endAhead);
|
||||
dStart = -direction * DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
|
||||
dEnd = direction * DoubleIntersectionRight(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForDouble, xStart + dStart, y - DoubleLineOffset, xEnd + dEnd, y - DoubleLineOffset);
|
||||
}
|
||||
else if (LinePattern != GridLinePattern.Thick)
|
||||
{
|
||||
SetLinePattern(cb, LinePattern);
|
||||
float dStart = -ThinIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = ThinIntersection(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * ThinIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * ThinIntersection(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForThin, xStart + dStart, y, xEnd + dEnd, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dStart = -ThickIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = ThickIntersection(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * ThickIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * ThickIntersection(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForThick, xStart + dStart, y, xEnd + dEnd, y);
|
||||
}
|
||||
cb.Stroke();
|
||||
@@ -665,30 +666,31 @@ namespace Volian.Print.Library
|
||||
{
|
||||
if (LinePattern != GridLinePattern.None)
|
||||
{
|
||||
float direction = (yStart < yEnd) ? 1 : -1;
|
||||
InitializeLineStyle(cb);
|
||||
SetLineColor(cb, r1, c1, side);
|
||||
if (LinePattern == GridLinePattern.Double)
|
||||
{
|
||||
//Left Line
|
||||
float dStart = -DoubleIntersectionRight(startToLeft, startToRight, startAhead);
|
||||
float dEnd = DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * DoubleIntersectionRight(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * DoubleIntersectionLeft(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForDouble, x - DoubleLineOffset, yStart + dStart, x - DoubleLineOffset, yEnd + dEnd);
|
||||
//Right Line
|
||||
dStart = -DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
|
||||
dEnd = DoubleIntersectionRight(endToLeft, endToRight, endAhead);
|
||||
dStart = -direction * DoubleIntersectionLeft(startToLeft, startToRight, startAhead);
|
||||
dEnd = direction * DoubleIntersectionRight(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForDouble, x + DoubleLineOffset, yStart + dStart, x + DoubleLineOffset, yEnd + dEnd);
|
||||
}
|
||||
else if (LinePattern != GridLinePattern.Thick)
|
||||
{
|
||||
SetLinePattern(cb, LinePattern);
|
||||
float dStart = -ThinIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = ThinIntersection(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * ThinIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * ThinIntersection(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForThin, x, yStart + dStart, x, yEnd + dEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
float dStart = -ThickIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = ThickIntersection(endToLeft, endToRight, endAhead);
|
||||
float dStart = -direction * ThickIntersection(startToLeft, startToRight, startAhead);
|
||||
float dEnd = direction * ThickIntersection(endToLeft, endToRight, endAhead);
|
||||
DrawLine(cb, LineThicknessForThick, x, yStart + dStart, x, yEnd + dEnd);
|
||||
}
|
||||
cb.Stroke();
|
||||
@@ -731,7 +733,6 @@ namespace Volian.Print.Library
|
||||
|
|
||||
Line Being Drawn
|
||||
|
||||
|
||||
Case 4: Line being drawn down:
|
||||
|
||||
Line Begin Drawn
|
||||
@@ -791,9 +792,14 @@ namespace Volian.Print.Library
|
||||
if (lineAhead == GridLinePattern.Thick) return ThickOverDouble;
|
||||
return -ThickUnderDouble;
|
||||
}
|
||||
if (lineToLeft == GridLinePattern.Double || lineToRight == GridLinePattern.Double)
|
||||
if ( lineToLeft == GridLinePattern.Double || lineToRight == GridLinePattern.Double)
|
||||
{
|
||||
if (lineAhead == GridLinePattern.Double) return -ThickUnderDouble;
|
||||
if (lineAhead == GridLinePattern.Double)
|
||||
{
|
||||
if (lineToLeft == GridLinePattern.Thick || lineToRight == GridLinePattern.Thick)
|
||||
return ThickOverDouble;
|
||||
return -ThickUnderDouble;
|
||||
}
|
||||
return ThickOverDouble;
|
||||
}
|
||||
if (VlnBorders.LineWidth(lineToLeft) == 1 && VlnBorders.LineWidth(lineToRight) == 1)
|
||||
@@ -821,25 +827,25 @@ namespace Volian.Print.Library
|
||||
private static void SetLineColor(PdfContentByte cb, int row, int col, string side)
|
||||
{
|
||||
iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
|
||||
switch (side)
|
||||
{
|
||||
case "Top":
|
||||
if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue));
|
||||
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
|
||||
break;
|
||||
case "Left":
|
||||
if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red));
|
||||
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
|
||||
break;
|
||||
case "Bottom":
|
||||
if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green));
|
||||
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
|
||||
break;
|
||||
case "Right":
|
||||
if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange));
|
||||
else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
|
||||
break;
|
||||
}
|
||||
//switch (side)
|
||||
//{
|
||||
// case "Top":
|
||||
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue));
|
||||
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
|
||||
// break;
|
||||
// case "Left":
|
||||
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red));
|
||||
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
|
||||
// break;
|
||||
// case "Bottom":
|
||||
// if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green));
|
||||
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan));
|
||||
// break;
|
||||
// case "Right":
|
||||
// if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange));
|
||||
// else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta));
|
||||
// break;
|
||||
//}
|
||||
cb.SetColorStroke(lineColor);
|
||||
}
|
||||
private static void InitializeLineStyle(PdfContentByte cb)
|
||||
@@ -857,7 +863,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom)
|
||||
{
|
||||
PdfDestination dest = new PdfDestination(PdfDestination.FITR, xLeft - 4, yBottom + 4, xRight, yTop + 4);
|
||||
PdfDestination dest = new PdfDestination(PdfDestination.FITR, xLeft - 4, yBottom , xRight, yTop + 4);
|
||||
myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop);
|
||||
}
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user