public Example_05() { FileStream fos = new FileStream("Example_05.pdf", FileMode.Create); BufferedStream bos = new BufferedStream(fos); PDF pdf = new PDF(bos); pdf.setCompressor(Compressor.ORIGINAL_ZLIB); // Before you enable this flag please read README.ZLIB.TXT // in the 'optional' directory. // If PDF/A is not required use Helvetica, TimesRoman or Courier Font f1 = new Font(pdf, "Helvetica"); Page page = new Page(pdf, Letter.PORTRAIT); TextLine text = new TextLine(f1); text.SetPosition(300.0, 300.0); for (int i = 0; i < 360; i += 15) { text.SetTextDirection(i); text.SetUnderline(true); // text.SetStrikeLine(true); text.SetText(" Hello, World -- " + i + " degrees."); text.DrawOn(page); } text = new TextLine(f1, "WAVE AWAY"); text.SetPosition(70.0, 50.0); text.DrawOn(page); f1.SetKernPairs(true); text.SetPosition(70.0, 70.0); text.DrawOn(page); f1.SetKernPairs(false); text.SetPosition(70.0, 90.0); text.DrawOn(page); f1.SetSize(8); text = new TextLine(f1, "-- font.SetKernPairs(false);"); text.SetPosition(150.0, 50.0); text.DrawOn(page); text.SetPosition(150.0, 90.0); text.DrawOn(page); text = new TextLine(f1, "-- font.SetKernPairs(true);"); text.SetPosition(150.0, 70.0); text.DrawOn(page); Point point = new Point(300.0, 300.0); point.SetShape(Point.CIRCLE); point.SetFillShape(true); point.SetColor(RGB.BLUE); point.SetRadius(37.0); point.DrawOn(page); point.SetRadius(25.0); point.SetColor(RGB.WHITE); point.DrawOn(page); pdf.Flush(); bos.Close(); }
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)); }
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); }