Blog

 
1:   using System;
2:   using System.IO;
3:  
4:   using iTextSharp.text;
5:   using iTextSharp.text.pdf;
6:  
7:   namespace iTextSharp.tutorial.Chap02
8:   {
9:       /// <summary>
10:       ///Negative leading
11:       /// </summary>
12:       public class Chap0204
13:       {
14:           public Chap0204()
15:           {
16:               Console.WriteLine("Chapter 2 example 4: Negative leading");
17:           
18:               // step 1: creation of a document-object
19:               Document document new Document();
20:           
21:               try 
22:               {
23:               
24:                   // step 2:
25:                   // we create a writer that listens to the document
26:                   // and directs a PDF-stream to a file
27:                   PdfWriter.GetInstance(documentnew FileStream("Chap0204.pdf"FileMode.Create));
28:               
29:                   // step 3: we open the document
30:                   document.Open();
31:               
32:                   // step 4: we Add a paragraph to the document
33:                   document.Add(new Phrase(16"\n\n\n"));
34:                   document.Add(new Phrase(-16"Hello, this is a very long phrase to show you the somewhat odd effect of a negative leading. You can write from bottom to top. This is not fully supported. It's something between a feature and a bug."));
35:               
36:               }
37:               catch(DocumentException de
38:               {
39:                   Console.Error.WriteLine(de.Message);
40:               }
41:               catch(IOException ioe
42:               {
43:                   Console.Error.WriteLine(ioe.Message);
44:               }
45:           
46:               // step 5: we close the document
47:               document.Close();
48:  
49:           }
50:       }
51:   }