import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
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 datatable = new PdfPTable(10);
int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 };
datatable.setWidths(headerwidths);
datatable.setWidthPercentage(100);
datatable.getDefaultCell().setPadding(5);
datatable.getDefaultCell().setBorderWidth(2);
datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
datatable.addCell("User Id");
datatable.addCell("Name\nAddress");
datatable.addCell("Company");
datatable.addCell("Department");
PdfPTable permissions = new PdfPTable(6);
permissions.getDefaultCell().setBorderWidth(2);
permissions.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
permissions.getDefaultCell().setColspan(6);
permissions.addCell("Permissions");
permissions.getDefaultCell().setColspan(1);
permissions.addCell("Admin");
permissions.addCell("Data");
permissions.addCell("Expl");
permissions.addCell("Prod");
permissions.addCell("Proj");
permissions.addCell("Online");
PdfPCell permission = new PdfPCell(permissions);
permission.setColspan(6);
datatable.addCell(permission);
document.add(datatable);
document.close();
}
}
|