//------------------------------------------------------------------------------------------- private void DrawText(PDFjet.NET.PDF pdf, PDFjet.NET.Page page, string text, int x, int y) { Font f1 = new Font(pdf, "Helvetica"); f1.SetSize(10); PDFjet.NET.TextLine tLine = new TextLine(f1); tLine.SetText(text); tLine.SetPosition(x, y); //tLine.SetURIAction("http://www.weavver.com/accounting/"); tLine.DrawOn(page); }
public float[] DrawTextLine( Page page, float x_text, float y_text, TextLine textLine, bool draw) { Font font = textLine.GetFont(); Font fallbackFont = textLine.GetFallbackFont(); int color = textLine.GetColor(); StringBuilder buf = new StringBuilder(); String[] tokens = Regex.Split(textLine.GetText(), "\\s+"); bool firstTextSegment = true; for (int i = 0; i < tokens.Length; i++) { String token = (i == 0) ? tokens[i] : (" " + tokens[i]); if (font.StringWidth(fallbackFont, token) < (this.w - (x_text - x))) { buf.Append(token); x_text += font.StringWidth(fallbackFont, token); } else { if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } x_text = x + font.StringWidth(fallbackFont, tokens[i]); y_text += leading; buf.Length = 0; buf.Append(tokens[i]); } } if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } return new float[] { x_text, y_text }; }
/// <summary> /// Populate a voter card with the information of a given voter. /// </summary> /// <param name="page">The page containing the card.</param> /// <param name="pdf">The pdf containing the page.</param> /// <param name="xO">The horizontal offset of the card in points.</param> /// <param name="yO">The vertical offset of the card in points.</param> /// <param name="voter">The voter whose information to be populated onto the card.</param> private static void PopulateCard(Page page, PDF pdf, double xO, double yO, VoterDO voter) { // ----- POPULATE: POLLING STATION ----- PollingStationDO ps = voter.PollingStation; var font = new Font(pdf, CoreFont.HELVETICA); font.SetSize(9); var t = new TextLine(font, ps.Name); t.SetPosition(xO + 9 * U, yO + 27.5 * U); t.DrawOn(page); t = new TextLine(font, ps.Address); t.SetPosition(xO + 9 * U, yO + 32 * U); t.DrawOn(page); t = new TextLine(font, "valgfrit"); t.SetPosition(xO + 29 * U, yO + 48.8 * U); t.DrawOn(page); t = new TextLine(font, "02-04861"); t.SetPosition(xO + 29 * U, yO + 58.7 * U); t.DrawOn(page); t = new TextLine(font, "09:00 - 20:00"); t.SetPosition(xO + 29 * U, yO + 68.2 * U); t.DrawOn(page); // ----- POPULATE: VOTER ----- MunicipalityDO mun = voter.PollingStation.Municipality; font = new Font(pdf, CoreFont.COURIER); font.SetSize(10); // Add top voter number 'Vælgernr.' t = new TextLine(font, "02-04861"); t.SetPosition(xO + 102 * U, yO + 12 * U); t.DrawOn(page); // Add sender 'Afsender' t = new TextLine(font, mun.Name); t.SetPosition(xO + 102 * U, yO + 32.5 * U); t.DrawOn(page); t = new TextLine(font, mun.Address); t.SetPosition(xO + 102 * U, yO + 36.5 * U); t.DrawOn(page); t = new TextLine(font, mun.City); t.SetPosition(xO + 102 * U, yO + 40.5 * U); t.DrawOn(page); // Add reciever 'Modtager' t = new TextLine(font, voter.Name); t.SetPosition(xO + 102 * U, yO + 62.5 * U); t.DrawOn(page); t = new TextLine(font, voter.Address); t.SetPosition(xO + 102 * U, yO + 66.5 * U); t.DrawOn(page); t = new TextLine(font, voter.City); t.SetPosition(xO + 102 * U, yO + 70.5 * U); t.DrawOn(page); // Add CPR barcode string barcode = BarCodeHashing.Hash(voter.PrimaryKey.Value).ToString(); var b = new BarCode(BarCode.CODE128, barcode); b.SetPosition(xO + 160 * U, yO + 60 * U); b.DrawOn(page); t = new TextLine(font, barcode); t.SetPosition(xO + 160 * U, yO + 72 * U); t.DrawOn(page); }
/// <summary> /// Generate lines, boxes, watermark and default text of a single voter card. /// </summary> /// <param name="page">The page containing the card.</param> /// <param name="pdf">The pdf containing the page.</param> /// <param name="xO">The horizontal offset of the card in points.</param> /// <param name="yO">The vertical offset of the card in points.</param> private static void GenerateCard(Page page, PDF pdf, double xO, double yO) { // Add watermark. var font = new Font(pdf, CoreFont.HELVETICA_BOLD); font.SetSize(55); var t = new TextLine(font, "FAKE VALGKORT"); var lightBlue = new[] { 0.647, 0.812, 0.957 }; t.SetColor(lightBlue); t.SetPosition(xO + 20 * U, yO + 50 * U); t.DrawOn(page); // Add 'Afstemningssted' box. var b = new Box(xO + 6 * U, yO + 20 * U, 80 * U, 22 * U); b.DrawOn(page); // Add 'Valgbord' box. b = new Box(xO + 6 * U, yO + 44.5 * U, 80 * U, 7 * U); b.DrawOn(page); // Add 'Vælgernr' box. b = new Box(xO + 6 * U, yO + 54 * U, 80 * U, 7 * U); b.DrawOn(page); // Add 'Afstemningstid' box. b = new Box(xO + 6 * U, yO + 63.5 * U, 80 * U, 7 * U); b.DrawOn(page); // Add lines. var l = new Line(xO + 96 * U, yO + 5 * U, xO + 96 * U, yO + 85 * U); l.DrawOn(page); l = new Line(xO + 96 * U, yO + 25 * U, xO + 205 * U, yO + 25 * U); l.DrawOn(page); l = new Line(xO + 96 * U, yO + 45 * U, xO + 205 * U, yO + 45 * U); l.DrawOn(page); l = new Line(xO + 6 * U, yO + 85 * U, xO + 205 * U, yO + 85 * U); l.DrawOn(page); // Add default text. font = new Font(pdf, CoreFont.HELVETICA); font.SetSize(7); t = new TextLine(font, "Afstemningssted:"); t.SetPosition(xO + 7 * U, yO + 23 * U); t.DrawOn(page); t = new TextLine(font, "Vælgernr.:"); t.SetPosition(xO + 7 * U, yO + 58 * U); t.DrawOn(page); t = new TextLine(font, "Afstemningstid:"); t.SetPosition(xO + 7 * U, yO + 68 * U); t.DrawOn(page); t = new TextLine(font, "Afsender:"); t.SetPosition(xO + 98 * U, yO + 29 * U); t.DrawOn(page); t = new TextLine(font, "Modtager:"); t.SetPosition(xO + 98 * U, yO + 49 * U); t.DrawOn(page); font = new Font(pdf, CoreFont.HELVETICA); font.SetSize(9); t = new TextLine(font, "Folketingsvalg"); t.SetPosition(xO + 7 * U, yO + 10 * U); t.DrawOn(page); t = new TextLine(font, "20. november 2001"); t.SetPosition(xO + 7 * U, yO + 14 * U); t.DrawOn(page); t = new TextLine(font, "Valgbord:"); t.SetPosition(xO + 7 * U, yO + 49 * U); t.DrawOn(page); font = new Font(pdf, CoreFont.HELVETICA_OBLIQUE); font.SetSize(7); t = new TextLine(font, "Medbring kortet ved afstemningen"); t.SetPosition(xO + 6.5 * U, yO + 18.5 * U); t.DrawOn(page); }
/** * Adds a text line to this paragraph. * * @param text the text line to add to this paragraph. * @return this paragraph. */ public Paragraph Add(TextLine text) { list.Add(text); return(this); }
private Point DrawParagraphOn( Page page, Paragraph paragraph, bool draw) { List<TextLine> list = new List<TextLine>(); float run_length = 0f; for (int i = 0; i < paragraph.list.Count; i++) { TextLine line = paragraph.list[i]; if (i == 0) { line_height = line.font.body_height + space_between_lines; if (rotate == 0) { y1 += line.font.ascent; } else if (rotate == 90) { x1 += line.font.ascent; } else if (rotate == 270) { x1 -= line.font.ascent; } } String[] tokens = line.str.Split(new Char[] {' ', '\r', '\n', '\t'}); TextLine text = null; for (int j = 0; j < tokens.Length; j++) { String str = tokens[j]; text = new TextLine(line.font, str); text.SetColor(line.GetColor()); text.SetUnderline(line.GetUnderline()); text.SetStrikeout(line.GetStrikeout()); text.SetURIAction(line.GetURIAction()); text.SetGoToAction(line.GetGoToAction()); text.SetFallbackFont(line.GetFallbackFont()); run_length += line.font.StringWidth(line.GetFallbackFont(), str); if (run_length >= w) { DrawLineOfText(page, list, draw); MoveToNextLine(); list.Clear(); list.Add(text); run_length = line.font.StringWidth(line.GetFallbackFont(), str + " "); } else { list.Add(text); run_length += line.font.StringWidth(line.GetFallbackFont(), " "); } } } DrawNonJustifiedLine(page, list, draw); if (lineBetweenParagraphs) { return MoveToNextLine(); } return MoveToNextParagraph(this.space_between_paragraphs); }
public void Add(TextLine text) { list.Add(text); }
private float[] DrawCodeUPC(Page page, float x1, float y1) { float x = x1; float y = y1; float h = m1 * barHeightFactor; // Barcode height when drawn horizontally // Calculate the check digit: // 1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) // together and multiply by three. // 2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) // to the result. // 3. Subtract the result modulo 10 from ten. // 4. The answer modulo 10 is the check digit. int sum = 0; for (int i = 0; i < 11; i += 2) { sum += text[i] - 48; } sum *= 3; for (int i = 1; i < 11; i += 2) { sum += text[i] - 48; } int reminder = sum % 10; int checkDigit = (10 - reminder) % 10; text += checkDigit.ToString(); x = DrawEGuard(page, x, y, m1, h + 8); for (int i = 0; i < 6; i++) { int digit = text[i] - 0x30; // page.DrawString(digit.ToString(), x + 1, y + h + 12); String symbol = tableA[digit].ToString(); for (int j = 0; j < symbol.Length; j++) { int n = symbol[j] - 0x30; if (j % 2 != 0) { DrawVertBar(page, x, y, n * m1, h); } x += n * m1; } } x = DrawMGuard(page, x, y, m1, h + 8); for (int i = 6; i < 12; i++) { int digit = text[i] - 0x30; // page.DrawString(digit.ToString(), x + 1, y + h + 12); String symbol = tableA[digit].ToString(); for (int j = 0; j < symbol.Length; j++) { int n = symbol[j] - 0x30; if (j % 2 == 0) { DrawVertBar(page, x, y, n * m1, h); } x += n * m1; } } x = DrawEGuard(page, x, y, m1, h + 8); float[] xy = new float[] { x, y }; if (font != null) { String label = text[0] + " " + text[1] + text[2] + text[3] + text[4] + text[5] + " " + text[6] + text[7] + text[8] + text[9] + text[10] + " " + text[11]; float fontSize = font.GetSize(); font.SetSize(10f); TextLine textLine = new TextLine(font, label); textLine.SetLocation( x1 + ((x - x1) - font.StringWidth(label)) / 2, y1 + h + font.bodyHeight); xy = textLine.DrawOn(page); xy[0] = Math.Max(x, xy[0]); xy[1] = Math.Max(y, xy[1]); font.SetSize(fontSize); return(new float[] { xy[0], xy[1] + font.descent }); } return(new float[] { xy[0], xy[1] }); }
public TextLine DrawTextLine( Page page, float x_text, float y_text, TextLine textLine, bool draw) { TextLine textLine2 = null; Font font = textLine.GetFont(); Font fallbackFont = textLine.GetFallbackFont(); int color = textLine.GetColor(); StringBuilder buf = new StringBuilder(); String[] tokens = Regex.Split(textLine.GetText(), @"\s+"); bool firstTextSegment = true; for (int i = 0; i < tokens.Length; i++) { String token = (i == 0) ? tokens[i] : (Single.space + tokens[i]); if (font.StringWidth(fallbackFont, token) < (this.w - (x_text - x))) { buf.Append(token); x_text += font.StringWidth(fallbackFont, token); } else { if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text + textLine.GetVerticalOffset()) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } x_text = x + font.StringWidth(fallbackFont, tokens[i]); y_text += leading; buf.Length = 0; buf.Append(tokens[i]); if (y_text + font.GetDescent() > (y + h)) { i++; while (i < tokens.Length) { buf.Append(Single.space); buf.Append(tokens[i]); i++; } textLine2 = new TextLine(font, buf.ToString()); textLine2.SetLocation(x, y_text); return(textLine2); } } } if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text + textLine.GetVerticalOffset()) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } textLine2 = new TextLine(font, ""); textLine2.SetLocation(x_text, y_text); return(textLine2); }
/** * Add a new text line. * * Find the current font, current size and effects (normal, super or subscript) * Set the position of the component to the starting stored as current position * Set the size and offset based on effects * Set the new current position * * @param component the component. */ public void AddComponent(TextLine component) { if (component.GetTextEffect() == Effect.SUPERSCRIPT) { component.GetFont().SetSize(fontSize * superscript_size_factor); component.SetPosition( current[X], current[Y] - fontSize * superscript_position); } else if (component.GetTextEffect() == Effect.SUBSCRIPT) { component.GetFont().SetSize(fontSize * subscript_size_factor); component.SetPosition( current[X], current[Y] + fontSize * subscript_position); } else { component.GetFont().SetSize(fontSize); component.SetPosition(current[X], current[Y]); } current[X] += component.GetWidth(); textLines.Add(component); }
public TextFrame DrawOn(Page page, bool draw) { this.x_text = x; this.y_text = y + font.GetAscent(); Paragraph paragraph = null; for (int i = 0; i < paragraphs.Count; i++) { paragraph = paragraphs[i]; StringBuilder buf = new StringBuilder(); foreach (TextLine textLine in paragraph.list) { buf.Append(textLine.GetText()); buf.Append(Single.space); } int numOfTextLines = paragraph.list.Count; for (int j = 0; j < numOfTextLines; j++) { TextLine textLine = paragraph.list[j]; if (j == 0) { beginParagraphPoints.Add(new float[] { x_text, y_text }); } textLine.SetAltDescription((i == 0) ? buf.ToString() : Single.space); textLine.SetActualText((i == 0) ? buf.ToString() : Single.space); TextLine textLine2 = DrawTextLine(page, x_text, y_text, textLine, draw); if (!textLine2.GetText().Equals("")) { List <Paragraph> theRest = new List <Paragraph>(); Paragraph paragraph2 = new Paragraph(textLine2); j++; while (j < numOfTextLines) { paragraph2.Add(paragraph.list[j]); j++; } theRest.Add(paragraph2); i++; while (i < paragraphs.Count) { theRest.Add(paragraphs[i]); i++; } return(new TextFrame(theRest)); } if (j == (numOfTextLines - 1)) { endParagraphPoints.Add(new float[] { textLine2.x, textLine2.y }); } x_text = textLine2.x; if (textLine.GetTrailingSpace()) { x_text += spaceBetweenTextLines; } y_text = textLine2.y; } x_text = x; y_text += paragraphLeading; } TextFrame textFrame = new TextFrame(null); textFrame.SetLocation(x_text, y_text + font.GetDescent()); return(textFrame); }
private float[] DrawCode39(Page page, float x1, float y1) { text = "*" + text + "*"; float x = x1; float y = y1; float w = m1 * barHeightFactor; // Barcode width when drawn vertically float h = m1 * barHeightFactor; // Barcode height when drawn horizontally float[] xy = new float[] { 0f, 0f }; if (direction == LEFT_TO_RIGHT) { for (int i = 0; i < text.Length; i++) { String code = tableB[text[i]]; if (code == null) { throw new Exception("The input string '" + text + "' contains characters that are invalid in a Code39 barcode."); } for (int j = 0; j < 9; j++) { char ch = code[j]; if (ch == 'w') { x += m1; } else if (ch == 'W') { x += m1 * 3; } else if (ch == 'b') { DrawVertBar(page, x, y, m1, h); x += m1; } else if (ch == 'B') { DrawVertBar(page, x, y, m1 * 3, h); x += m1 * 3; } } x += m1; } if (font != null) { TextLine textLine = new TextLine(font, text); textLine.SetLocation( x1 + ((x - x1) - font.StringWidth(text)) / 2, y1 + h + font.bodyHeight); xy = textLine.DrawOn(page); xy[0] = Math.Max(x, xy[0]); } } else if (direction == TOP_TO_BOTTOM) { for (int i = 0; i < text.Length; i++) { String code = tableB[text[i]]; if (code == null) { throw new Exception("The input string '" + text + "' contains characters that are invalid in a Code39 barcode."); } for (int j = 0; j < 9; j++) { char ch = code[j]; if (ch == 'w') { y += m1; } else if (ch == 'W') { y += 3 * m1; } else if (ch == 'b') { DrawHorzBar(page, x, y, m1, h); y += m1; } else if (ch == 'B') { DrawHorzBar(page, x, y, 3 * m1, h); y += 3 * m1; } } y += m1; } if (font != null) { TextLine textLine = new TextLine(font, text); textLine.SetLocation( x - font.bodyHeight, y1 + ((y - y1) - font.StringWidth(text)) / 2); textLine.SetTextDirection(270); xy = textLine.DrawOn(page); xy[0] = Math.Max(x, xy[0]) + w; xy[1] = Math.Max(y, xy[1]); } } else if (direction == BOTTOM_TO_TOP) { float height = 0.0f; for (int i = 0; i < text.Length; i++) { String code = tableB[text[i]]; if (code == null) { throw new Exception("The input string '" + text + "' contains characters that are invalid in a Code39 barcode."); } for (int j = 0; j < 9; j++) { char ch = code[j]; if (ch == 'w' || ch == 'b') { height += m1; } else if (ch == 'W' || ch == 'B') { height += 3 * m1; } } height += m1; } y += height - m1; for (int i = 0; i < text.Length; i++) { String code = tableB[text[i]]; for (int j = 0; j < 9; j++) { char ch = code[j]; if (ch == 'w') { y -= m1; } else if (ch == 'W') { y -= 3 * m1; } else if (ch == 'b') { DrawHorzBar2(page, x, y, m1, h); y -= m1; } else if (ch == 'B') { DrawHorzBar2(page, x, y, 3 * m1, h); y -= 3 * m1; } } y -= m1; } if (font != null) { y = y1 + (height - m1); TextLine textLine = new TextLine(font, text); textLine.SetLocation( x + w + font.bodyHeight, y - ((y - y1) - font.StringWidth(text)) / 2); textLine.SetTextDirection(90); xy = textLine.DrawOn(page); xy[1] = Math.Max(y, xy[1]); return(new float[] { xy[0], xy[1] + font.descent }); } } return(new float[] { xy[0], xy[1] }); }
private float[] DrawCode128(Page page, float x1, float y1) { float x = x1; float y = y1; float w = m1; float h = m1; if (direction == TOP_TO_BOTTOM) { w *= barHeightFactor; } else if (direction == LEFT_TO_RIGHT) { h *= barHeightFactor; } List <Int32> list = new List <Int32>(); for (int i = 0; i < text.Length; i++) { char symchar = text[i]; if (symchar < 32) { list.Add(GS1_128.SHIFT); list.Add(symchar + 64); } else if (symchar < 128) { list.Add(symchar - 32); } else if (symchar < 256) { list.Add(GS1_128.FNC_4); list.Add(symchar - 160); // 128 + 32 } else { // list.Add(31); // '?' list.Add(256); // This will generate an exception. } if (list.Count == 48) { // Maximum number of data characters is 48 break; } } StringBuilder buf = new StringBuilder(); int checkDigit = GS1_128.START_B; buf.Append((char)checkDigit); for (int i = 0; i < list.Count; i++) { int codeword = list[i]; buf.Append((char)codeword); checkDigit += codeword * (i + 1); } checkDigit %= GS1_128.START_A; buf.Append((char)checkDigit); buf.Append((char)GS1_128.STOP); for (int i = 0; i < buf.Length; i++) { int si = buf[i]; String symbol = GS1_128.TABLE[si].ToString(); for (int j = 0; j < symbol.Length; j++) { int n = symbol[j] - 0x30; if (j % 2 == 0) { if (direction == LEFT_TO_RIGHT) { DrawVertBar(page, x, y, m1 * n, h); } else if (direction == TOP_TO_BOTTOM) { DrawHorzBar(page, x, y, m1 * n, w); } } if (direction == LEFT_TO_RIGHT) { x += n * m1; } else if (direction == TOP_TO_BOTTOM) { y += n * m1; } } } float[] xy = new float[] { x, y }; if (font != null) { if (direction == LEFT_TO_RIGHT) { TextLine textLine = new TextLine(font, text); textLine.SetLocation( x1 + ((x - x1) - font.StringWidth(text)) / 2, y1 + h + font.bodyHeight); xy = textLine.DrawOn(page); xy[0] = Math.Max(x, xy[0]); return(new float[] { xy[0], xy[1] + font.descent }); } else if (direction == TOP_TO_BOTTOM) { TextLine textLine = new TextLine(font, text); textLine.SetLocation( x + w + font.bodyHeight, y - ((y - y1) - font.StringWidth(text)) / 2); textLine.SetTextDirection(90); xy = textLine.DrawOn(page); xy[1] = Math.Max(y, xy[1]); } } return(xy); }
/** * Adds a text line to this paragraph. * * @param text the text line to add to this paragraph. */ public Paragraph Add(TextLine text) { list.Add(text); return this; }
public Paragraph(TextLine text) { this.list = new List <TextLine>(); this.list.Add(text); }
public float[] DrawTextLine( Page page, float x_text, float y_text, TextLine textLine, bool draw) { Font font = textLine.GetFont(); Font fallbackFont = textLine.GetFallbackFont(); int color = textLine.GetColor(); String[] tokens = null; String str = textLine.GetText(); if (StringIsCJK(str)) { tokens = TokenizeCJK(str, this.w); } else { tokens = Regex.Split(textLine.GetText(), @"\s+"); } StringBuilder buf = new StringBuilder(); bool firstTextSegment = true; for (int i = 0; i < tokens.Length; i++) { String token = (i == 0) ? tokens[i] : (Single.space + tokens[i]); if (font.StringWidth(fallbackFont, token) < (this.w - (x_text - x))) { buf.Append(token); x_text += font.StringWidth(fallbackFont, token); } else { if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text + textLine.GetVerticalOffset()) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } x_text = x + font.StringWidth(fallbackFont, tokens[i]); y_text += leading; buf.Length = 0; buf.Append(tokens[i]); } } if (draw) { new TextLine(font, buf.ToString()) .SetFallbackFont(textLine.GetFallbackFont()) .SetLocation(x_text - font.StringWidth(fallbackFont, buf.ToString()), y_text + textLine.GetVerticalOffset()) .SetColor(color) .SetUnderline(textLine.GetUnderline()) .SetStrikeout(textLine.GetStrikeout()) .SetLanguage(textLine.GetLanguage()) .SetAltDescription(firstTextSegment ? textLine.GetAltDescription() : Single.space) .SetActualText(firstTextSegment ? textLine.GetActualText() : Single.space) .DrawOn(page); firstTextSegment = false; } return(new float[] { x_text, y_text }); }