public Example_47() { PDF pdf = new PDF(new BufferedStream( new FileStream("Example_47.pdf", FileMode.Create)), Compliance.PDF_UA); Font f1 = new Font(pdf, new FileStream( "fonts/OpenSans/OpenSans-Regular.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); Font f2 = new Font(pdf, new FileStream( // "fonts/OpenSans/OpenSans-Regular.ttf.stream", "fonts/OpenSans/OpenSans-Italic.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); f1.SetSize(14f); f2.SetSize(14f); // f2.SetItalic(true); Page page = new Page(pdf, Letter.PORTRAIT); List <Paragraph> paragraphs = new List <Paragraph>(); Paragraph paragraph = new Paragraph() .Add(new TextLine(f1, "The centres also offer free one-on-one consultations with business advisors who can review your business plan and make recommendations to improve it. The small business centres offer practical resources, from step-by-step info on setting up your business to sample business plans to a range of business-related articles and books in our resource libraries.")) .Add(new TextLine(f2, "This text is blue color and is written using italic font.").SetColor(Color.blue)); paragraphs.Add(paragraph); float height = 82f; Line line = new Line(70f, 150f, 70f, 150f + height); line.DrawOn(page); TextFrame frame = new TextFrame(paragraphs); frame.SetLocation(70f, 150f); frame.SetWidth(500f); frame.SetHeight(height); frame = frame.DrawOn(page); if (frame.GetParagraphs() != null) { frame.SetLocation(70f, 450f); frame.SetWidth(500f); frame.SetHeight(90f); frame = frame.DrawOn(page); } pdf.Close(); }
public Example_47() { PDF pdf = new PDF(new BufferedStream( new FileStream("Example_47.pdf", FileMode.Create))); Font f1 = new Font(pdf, new FileStream( "fonts/OpenSans/OpenSans-Regular.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); f1.SetSize(12f); Font f2 = new Font(pdf, new FileStream( "fonts/OpenSans/OpenSans-Italic.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); f2.SetSize(12f); Image image1 = new Image( pdf, new FileStream("images/AU-map.png", FileMode.Open, FileAccess.Read), ImageType.PNG); image1.ScaleBy(0.50f); Image image2 = new Image( pdf, new FileStream("images/HU-map.png", FileMode.Open, FileAccess.Read), ImageType.PNG); image2.ScaleBy(0.50f); Page page = new Page(pdf, Letter.PORTRAIT); image1.SetLocation(20f, 20f); image1.DrawOn(page); image2.SetLocation( page.GetWidth() - (image2.GetWidth() + 20f), page.GetHeight() - (image2.GetHeight() + 20f)); image2.DrawOn(page); List <TextLine> paragraphs = new List <TextLine>(); StringBuilder buf = new StringBuilder(); StreamReader reader = new StreamReader("data/austria_hungary.txt"); String text = null; while ((text = reader.ReadLine()) != null) { buf.Append(text); buf.Append("\n"); } reader.Close(); String[] textLines = Regex.Split(buf.ToString(), "\n\n"); foreach (String textLine in textLines) { paragraphs.Add(new TextLine(f1, textLine)); } float xPos = 20f; float yPos = 250f; float width = 180f; float height = 315f; TextFrame frame = new TextFrame(paragraphs); frame.SetLocation(xPos, yPos); frame.SetWidth(width); frame.SetHeight(height); frame.SetDrawBorder(true); frame.DrawOn(page); xPos += 200f; if (frame.IsNotEmpty()) { frame.SetLocation(xPos, yPos); frame.SetWidth(width); frame.SetHeight(height); frame.SetDrawBorder(false); frame.DrawOn(page); } xPos += 200f; if (frame.IsNotEmpty()) { frame.SetLocation(xPos, yPos); frame.SetWidth(width); frame.SetHeight(height); frame.SetDrawBorder(true); frame.DrawOn(page); } pdf.Complete(); }