public CalculatePdfFormat(TextStyleDecorator textDecorator, iTextSharp.text.Font font) { if (textDecorator == null) { throw new ArgumentNullException("textDecorator"); } if (font == null) { throw new ArgumentNullException("font"); } this.textDecorator = textDecorator; this.Leading = font.Size; this.CalculateFormat(); }
public PdfFormat(TextStyleDecorator textDecorator, iTextSharp.text.Font font) { if (textDecorator == null) { throw new ArgumentNullException("textDecorator"); } if (font == null) { throw new ArgumentNullException("font"); } this.font = font; this.textDecorator = textDecorator; this.height = UnitConverter.FromPixel(this.textDecorator.DisplayRectangle.Height).Point; this.CalculateFormat(); }
public static int PdfAlignment(TextStyleDecorator textDecorator) { int retVal = 0; switch (textDecorator.ContentAlignment) { //Top case ContentAlignment.TopLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.TopCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.TopRight: retVal = PdfContentByte.ALIGN_RIGHT; break; // Middle case ContentAlignment.MiddleLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.MiddleCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.MiddleRight: retVal = PdfContentByte.ALIGN_RIGHT; break; //Bottom case ContentAlignment.BottomLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.BottomCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.BottomRight: retVal = PdfContentByte.ALIGN_RIGHT; break; } return(retVal); }
private static iTextSharp.text.Font CreateFontFromFactory(TextStyleDecorator styleDecorator) { iTextSharp.text.Font font = null; if (styleDecorator.Font.Unit == GraphicsUnit.Point) { font = FontFactory.GetFont(styleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, styleDecorator.Font.Size, (int)styleDecorator.Font.Style, styleDecorator.PdfForeColor); } else { font = FontFactory.GetFont(styleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, UnitConverter.FromPixel(styleDecorator.Font.Size).Point, (int)styleDecorator.Font.Style, styleDecorator.PdfForeColor); } return font; }
private static iTextSharp.text.Font CreateFontFromFactory(TextStyleDecorator styleDecorator) { iTextSharp.text.Font font = null; if (styleDecorator.Font.Unit == GraphicsUnit.Point) { font = FontFactory.GetFont(styleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, styleDecorator.Font.Size, (int)styleDecorator.Font.Style, styleDecorator.PdfForeColor); } else { font = FontFactory.GetFont(styleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, UnitConverter.FromPixel(styleDecorator.Font.Size).Point, (int)styleDecorator.Font.Style, styleDecorator.PdfForeColor); } return(font); }
protected TextStyleDecorator CreateItemStyle () { TextStyleDecorator style = new TextStyleDecorator(); style.BackColor = this.BackColor; style.ForeColor = this.ForeColor; style.Font = this.Font; style.Location = this.Location; style.Size = this.Size; style.DrawBorder = this.DrawBorder; style.StringFormat = this.stringFormat; style.StringTrimming = this.stringTrimming; style.ContentAlignment = this.contentAlignment; style.FormatString = this.formatString; style.DataType = this.dataType; return style; }
Pen CreateWpfPen(TextStyleDecorator styleDecorator) { Pen myPen = new Pen(); myPen.Brush = ConvertBrush(styleDecorator.ForeColor); myPen.Thickness = 1.5; return myPen; }
void CreateUnderline(TextBlock textBlock,TextStyleDecorator styleDecorator) { TextDecoration underLine = new TextDecoration(); Pen p = CreateWpfPen(styleDecorator); underLine.Pen = p ; underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; textBlock.TextDecorations.Add(underLine); }
void CreateStrikeout (TextBlock textBlock, TextStyleDecorator styleDecorator) { TextDecoration strikeOut = new TextDecoration(); strikeOut.Location = TextDecorationLocation.Strikethrough; Pen p = CreateWpfPen(styleDecorator); strikeOut.Pen = p ; strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended; textBlock.TextDecorations.Add(strikeOut); }
void SetFont(TextBlock textBlock, TextStyleDecorator styleDecorator) { textBlock.FontFamily = new FontFamily(styleDecorator.Font.FontFamily.Name); var b = styleDecorator.Font.Size; textBlock.FontSize = b * 96/72; if (styleDecorator.Font.Bold) { textBlock.FontWeight = FontWeights.Bold; } if (styleDecorator.Font.Underline) { CreateUnderline(textBlock,styleDecorator); } if (styleDecorator.Font.Italic) { textBlock.FontStyle = System.Windows.FontStyles.Italic ; } if (styleDecorator.Font.Strikeout) { CreateStrikeout(textBlock,styleDecorator); } }
private void SetContendAlignment(TextBlock textBlock,TextStyleDecorator decorator) { switch (decorator.ContentAlignment) { case ContentAlignment.TopLeft: textBlock.VerticalAlignment = VerticalAlignment.Top; textBlock.TextAlignment = TextAlignment.Left; break; case ContentAlignment.TopCenter: textBlock.VerticalAlignment = VerticalAlignment.Top; textBlock.TextAlignment = TextAlignment.Center; break; case ContentAlignment.TopRight: textBlock.VerticalAlignment = VerticalAlignment.Top; textBlock.TextAlignment = TextAlignment.Right; break; // Middle case ContentAlignment.MiddleLeft: textBlock.VerticalAlignment = VerticalAlignment.Center; textBlock.TextAlignment = TextAlignment.Left; break; case ContentAlignment.MiddleCenter: textBlock.VerticalAlignment = VerticalAlignment.Center; textBlock.TextAlignment = TextAlignment.Center; break; case ContentAlignment.MiddleRight: textBlock.VerticalAlignment = VerticalAlignment.Center; textBlock.TextAlignment = TextAlignment.Right; break; //Bottom case ContentAlignment.BottomLeft: textBlock.VerticalAlignment = VerticalAlignment.Bottom; textBlock.TextAlignment = TextAlignment.Left; break; case ContentAlignment.BottomCenter: textBlock.VerticalAlignment = VerticalAlignment.Bottom; textBlock.TextAlignment = TextAlignment.Center; break; case ContentAlignment.BottomRight: textBlock.VerticalAlignment = VerticalAlignment.Bottom; textBlock.TextAlignment = TextAlignment.Right; break; } }
public CalculatePdfFormat (TextStyleDecorator textDecorator,iTextSharp.text.Font font) { if (textDecorator == null) { throw new ArgumentNullException ("textDecorator"); } if (font == null) { throw new ArgumentNullException("font"); } this.textDecorator = textDecorator; this.Leading = font.Size; this.CalculateFormat(); }
public static int PdfAlignment(TextStyleDecorator textDecorator) { int retVal = 0; switch (textDecorator.ContentAlignment) { //Top case ContentAlignment.TopLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.TopCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.TopRight: retVal = PdfContentByte.ALIGN_RIGHT; break; // Middle case ContentAlignment.MiddleLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.MiddleCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.MiddleRight: retVal = PdfContentByte.ALIGN_RIGHT; break; //Bottom case ContentAlignment.BottomLeft: retVal = PdfContentByte.ALIGN_LEFT; break; case ContentAlignment.BottomCenter: retVal = PdfContentByte.ALIGN_CENTER; break; case ContentAlignment.BottomRight: retVal = PdfContentByte.ALIGN_RIGHT; break; } return retVal; }
public PdfFormat (TextStyleDecorator textDecorator,iTextSharp.text.Font font) { if (textDecorator == null) { throw new ArgumentNullException ("textDecorator"); } if (font == null) { throw new ArgumentNullException("font"); } this.font = font; this.textDecorator = textDecorator; this.height = UnitConverter.FromPixel(this.textDecorator.DisplayRectangle.Height).Point; this.CalculateFormat(); }