public PlainText(Font font, String[] textLines) { this.font = font; this.fontSize = font.GetSize(); this.textLines = textLines; this.endOfLinePoints = new List<float[]>(); StringBuilder buf = new StringBuilder(); foreach (String str in textLines) { buf.Append(str); buf.Append(' '); } this.altDescription = buf.ToString(); this.actualText = buf.ToString(); }
public PlainText(Font font, String[] textLines) { this.font = font; this.fontSize = font.GetSize(); this.textLines = textLines; StringBuilder buf = new StringBuilder(); foreach (String str in textLines) { buf.Append(str); buf.Append(' '); } this.altDescription = buf.ToString(); this.actualText = buf.ToString(); }
/** * Draws this PlainText on the specified page. * * @param page the page to draw on. * @return x and y coordinates of the bottom right corner of this component. * @throws Exception */ public float[] DrawOn(Page page) { float originalSize = font.GetSize(); font.SetSize(fontSize); float y_text = y + font.GetAscent(); page.AddBMC(StructElem.SPAN, language, Single.space, Single.space); page.SetBrushColor(backgroundColor); leading = font.GetBodyHeight(); float h = font.GetBodyHeight() * textLines.Length; page.FillRect(x, y, w, h); page.SetPenColor(borderColor); page.SetPenWidth(0f); page.DrawRect(x, y, w, h); page.AddEMC(); page.AddBMC(StructElem.SPAN, language, altDescription, actualText); page.SetTextStart(); page.SetTextFont(font); page.SetBrushColor(textColor); page.SetTextLeading(leading); page.SetTextLocation(x, y_text); foreach (String str in textLines) { if (font.skew15) { SetTextSkew(page, 0.26f, x, y_text); } page.Println(str); endOfLinePoints.Add(new float[] { x + font.StringWidth(str), y_text }); y_text += leading; } page.SetTextEnd(); page.AddEMC(); font.SetSize(originalSize); return(new float[] { x + w, y + h }); }
/** * Returns the y coordinate of the destination. * * @return the y coordinate of the destination. */ public float GetDestinationY() { return(y - font.GetSize()); }
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] }); }
private void drawCodeUPC(Page page) { 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 += str[i] - 48; } sum *= 3; for (int i = 1; i < 11; i += 2) { sum += str[i] - 48; } int reminder = sum % 10; int check_digit = (10 - reminder) % 10; str += check_digit.ToString(); x = drawEGuard(page, x, y, m1, h + 8); for (int i = 0; i < 6; i++) { int digit = str[i] - 0x30; // page.DrawString(digit.ToString(), x + 1, y + h + 12); String symbol = tableA[digit].ToString(); int n; for (int j = 0; j < symbol.Length; j++) { 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 = str[i] - 0x30; // page.DrawString(digit.ToString(), x + 1, y + h + 12); String symbol = tableA[digit].ToString(); int n; for (int j = 0; j < symbol.Length; j++) { 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); if (font != null) { String label = str[0] + " " + str[1] + str[2] + str[3] + str[4] + str[5] + " " + str[6] + str[7] + str[8] + str[9] + str[10] + " " + str[11]; float fontSize = font.GetSize(); font.SetSize(10.0); page.DrawString( font, label, x1 + ((x - x1) - font.StringWidth(label)) / 2, y1 + h + font.body_height); font.SetSize(fontSize); } }