import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document(PageSize.A4.rotate());
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfPTable table = new PdfPTable(4);
table.setWidthPercentage(100);
PdfPCell cell;
cell = new PdfPCell(new Paragraph("t"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("d"));
cell.setBorder(Rectangle.NO_BORDER);
cell.setBackgroundColor(Color.red);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("r"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("b"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("G:"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("0.25"));
cell.setBorder(Rectangle.NO_BORDER);
cell.setGrayFill(0.25f);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("0.5"));
cell.setBorder(Rectangle.NO_BORDER);
cell.setGrayFill(0.5f);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("0.75"));
cell.setBorder(Rectangle.NO_BORDER);
cell.setGrayFill(0.75f);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(":"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("a"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("b"));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("o"));
cell.setBorderWidth(6f);
cell.setBorderColor(Color.orange);
table.addCell(cell);
document.add(table);
document.close();
}
}
|