Java Tutorial/PDF/List — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 05:21, 1 июня 2010
Содержание
Add more space to list
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
List list1 = new List(List.UNORDERED, 30);
list1.add(new ListItem("A"));
list1.add(new ListItem("B"));
list1.add(new ListItem("C"));
document.add(list1);
document.close();
}
}
Alphabetical List
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
List list1 = new List(List.ORDERED, List.ALPHABETICAL, 20);
list1.add(new ListItem("A"));
list1.add(new ListItem("B"));
list1.add(new ListItem("C"));
document.add(list1);
document.close();
}
}
Create an Ordered list
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
List list1 = new List(List.ORDERED, 20);
list1.add(new ListItem("A"));
list1.add(new ListItem("B"));
list1.add(new ListItem("C"));
document.add(list1);
document.close();
}
}
Create an Unordered list
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
List list1 = new List(List.UNORDERED, 20);
list1.add(new ListItem("A"));
list1.add(new ListItem("B"));
list1.add(new ListItem("C"));
document.add(list1);
document.close();
}
}
Custom list symbol
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
List list1 = new List(List.UNORDERED, 30);
list1.setListSymbol(new Chunk("*"));
list1.add(new ListItem("A"));
list1.add(new ListItem("B"));
list1.add(new ListItem("C"));
document.add(list1);
document.close();
}
}
Greek List
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.GreekList;
import com.lowagie.text.ListItem;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
GreekList greeklist = new GreekList(20);
greeklist.setGreekLower(true);
greeklist.add(new ListItem("A"));
greeklist.add(new ListItem("B"));
document.add(greeklist);
document.close();
}
}
RomanList, lower case
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.ListItem;
import com.lowagie.text.Phrase;
import com.lowagie.text.RomanList;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
RomanList romanlist = new RomanList(20);
romanlist.setRomanLower(true);
romanlist.add(new ListItem("A"));
romanlist.add(new ListItem("B"));
document.add(romanlist);
document.close();
}
}
Upper case RomanList
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.ListItem;
import com.lowagie.text.RomanList;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
RomanList romanlist = new RomanList(20);
romanlist.setRomanLower(false);
romanlist.add(new ListItem("A"));
romanlist.add(new ListItem("B"));
document.add(romanlist);
document.close();
}
}
ZapfDingbatsList
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.ListItem;
import com.lowagie.text.ZapfDingbatsList;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
ZapfDingbatsList zapfdingbatslist = new ZapfDingbatsList(42, 15);
zapfdingbatslist.add(new ListItem("A"));
zapfdingbatslist.add(new ListItem("B"));
document.add(zapfdingbatslist);
document.close();
}
}
zapfdingbatsnumberlist
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.ListItem;
import com.lowagie.text.ZapfDingbatsNumberList;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
ZapfDingbatsNumberList zapfdingbatsnumberlist;
zapfdingbatsnumberlist = new ZapfDingbatsNumberList(0, 15);
zapfdingbatsnumberlist.add(new ListItem("A"));
zapfdingbatsnumberlist.add(new ListItem("B"));
document.add(zapfdingbatsnumberlist);
document.close();
}
}