public PdfAngledBox(PdfRect rect, PdfAngle angle, PdfAlign v_align, PdfBorder borders = null, PdfBoxLayout box_layout = null) : base(borders, box_layout) { Rectangle = rect; Angle = angle; VAlign = v_align; }
public PdfTextLine(string text_line, int text_scale, PdfFont font, PdfAlign h_align, PdfColor color = null) { TextLine = text_line; TextScale = text_scale; HAlign = h_align; Color = color; _font = font; }
public PdfAutoBox(PdfXY upper_left, PdfGrow grow_direction, PdfAlign v_align, PdfArea area, PdfArea max_area = null, PdfBorder borders = null, PdfBoxLayout box_layout = null) : base(borders, box_layout) { UpperLeft = upper_left; GrowDirection = grow_direction; VAlign = v_align; Area = area; MaxArea = max_area ?? new PdfArea(max_box_size, max_box_size); }
public PdfTextLine(string text_line, int text_scale, string typeface, PdfAlign h_align, bool bold = false, bool italic = false, PdfColor color = null) { TextLine = text_line; TextScale = text_scale; HAlign = h_align; Color = color; _typeface = typeface; _bold = bold; _italic = italic; }
public PdfTextIn(PdfFontMetrics metrics, string font_name, int codepage, int text_scale, string text, PdfAlign h_align, PdfColor color, bool kerning = false) { Metrics = metrics; FontName = font_name; CodePage = codepage; TextScale = text_scale; Text = text; HAlign = h_align; Color = color; Kerning = kerning; }
public PdfTextOut(PdfAlign h_align, string font_name, int text_scale, double width, double y, double word_spacing, int codepage, PdfColor color, string text) { HAlign = h_align; FontName = font_name; TextScale = text_scale; Width = width; Y = y; WordSpacing = word_spacing; CodePage = codepage; Color = color; Text = text; }
public static double CalcVAlign(PdfAlign align, double range, double content) { switch (align) { case PdfAlign.Middle: return(RoundDouble((range - content) / 2f)); case PdfAlign.Near: return(range - content); default: return(0); } }
public int GetElementAlignmentHorizontal(PdfAlign pdfAlign) { switch (pdfAlign) { case PdfAlign.Center: return(Element.ALIGN_CENTER); case PdfAlign.Left: return(Element.ALIGN_LEFT); case PdfAlign.Right: return(Element.ALIGN_RIGHT); case PdfAlign.Justified: return(Element.ALIGN_JUSTIFIED); default: return(Element.ALIGN_CENTER); } }
public PdfPTable AddPdfTable(int numColumns, float[] colunmSpace, PdfAlign align = PdfAlign.Center) { if (numColumns != colunmSpace.Count()) { new Exception(errorMsg3); } var pTable = new PdfPTable(numColumns) { WidthPercentage = widthPercentage, HorizontalAlignment = GetElementAlignmentHorizontal(align) }; pTable.SetWidths(colunmSpace); return(pTable); }
public PdfPCell AddCellHeader(object value, PdfAlign align = PdfAlign.Center, bool isFirstRow = false, bool inBold = false) { if (value == null) { throw new Exception(errorMsg2); } Font font = FontFactory.GetFont(fontName, eigthSingle, (inBold) ? 1 : 0); return(new PdfPCell(new Phrase(value.ToString(), font)) { HorizontalAlignment = GetElementAlignmentHorizontal(align), VerticalAlignment = Element.ALIGN_MIDDLE, Border = PdfPCell.NO_BORDER, BorderWidthBottom = 1, BorderColorBottom = isFirstRow ? BaseColor.WHITE : BaseColor.ORANGE, BackgroundColor = BaseColor.WHITE, ExtraParagraphSpace = 0 }); }
public static (PdfTextOut[], double width, double height) TextCoordinates(double width, IEnumerable <PdfTextIn> lines) { var result = new List <PdfTextOut>(); var lines_width = new List <(PdfTextIn text_in, string text, int width, bool broken)>(); double block_width_points = 0; double block_height_points = 0; // calcular largura e altura de todas as linhas foreach (PdfTextIn line in lines) { // iterar linhas depois da quebra int box_width_units = PointsToUnits(line.TextScale, width); foreach (var line_width in line.Metrics.LineBreak(line.Text, box_width_units, line.Kerning)) { block_width_points = Math.Max(block_width_points, UnitsToPoints(line.TextScale, line_width.width)); block_height_points += UnitsToPoints(line.TextScale, line.Metrics.LineHeight); lines_width.Add((line, line_width.text, line_width.width, line_width.broken)); } } // posição vertical inicial double margin_y_points = 0; // calcular posição horizontal de cada linha da última à primeira foreach (var tuple in lines_width.ToArray().Reverse()) { if (tuple.text != null) // não é uma linha em branco { // largura da linha double line_w_points = UnitsToPoints(tuple.text_in.TextScale, tuple.width); // posição vertical da linha double line_y_points = margin_y_points - UnitsToPoints(tuple.text_in.TextScale, tuple.text_in.Metrics.FontBBox.LLy); // contar espaços entre as palavras (para cálculo do alinhamento justificado) int spaces = tuple.broken && tuple.text_in.HAlign == PdfAlign.Justify ? tuple.text.Count(x => x == char_space) : 0; // se alinhamento justificado, reverter para alinhamento à esquerda (cálculo é feito aqui) PdfAlign new_align = tuple.text_in.HAlign == PdfAlign.Justify ? PdfAlign.Near : tuple.text_in.HAlign; // calcular pixels entre as palavras double word_spacing = spaces > 0 ? (width - line_w_points) / spaces : 0; // produzir resultado result.Add(new PdfTextOut( h_align: new_align, font_name: tuple.text_in.FontName, text_scale: tuple.text_in.TextScale, width: line_w_points, y: line_y_points, word_spacing: word_spacing, codepage: tuple.text_in.CodePage, color: tuple.text_in.Color, text: tuple.text)); } // displace bottom margin margin_y_points += UnitsToPoints(tuple.text_in.TextScale, tuple.text_in.Metrics.LineHeight); } return(result.ToArray(), block_width_points, block_height_points); }
public PdfAutoBox(PdfRect rectangle, PdfAlign v_align, PdfBorder borders = null, PdfBoxLayout box_layout = null) : this(rectangle.UpperLeft, PdfGrow.None, v_align, rectangle.Area, null, borders, box_layout) { }
protected override double CalcTextX(PdfAlign h_align, double line_width) { return(Util.CalcHAlign(h_align, CalcMaxTextWidth(), line_width)); }
protected abstract double CalcTextX(PdfAlign h_align, double line_width);