Skip to content

Instantly share code, notes, and snippets.

@mgenov
Created February 10, 2011 10:17
Show Gist options
  • Save mgenov/820247 to your computer and use it in GitHub Desktop.
Save mgenov/820247 to your computer and use it in GitHub Desktop.
iText sample
public class MyClass {
public static void main(String[] args) throws DocumentException, IOException {
Document document = new Document();
document.setPageCount(1);
PdfWriter.getInstance(document,
new FileOutputStream("/home/matrix/SimpleImages.pdf"));
document.open();
URL verdanaUrl = MyClass.class.getResource("verdana.ttf");
BaseFont bf = BaseFont.createFont(verdanaUrl.getPath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
PdfPTable table = new PdfPTable(2); // Code 1
// Code 2
PdfPCell userInfo = new PdfPCell(new Paragraph("Потребител", new Font(bf, 10)));
userInfo.setBackgroundColor(BaseColor.GRAY);
userInfo.setBorder(5);
table.addCell(userInfo);
PdfPCell contractInfo = new PdfPCell(new Paragraph("Клиент",new Font(bf, 10)));
contractInfo.setBackgroundColor(BaseColor.GRAY);
contractInfo.setBorder(5);
table.addCell(contractInfo);
// Code 3
table.addCell("3");
table.addCell("4");
// Code 4
table.addCell("5");
table.addCell("6");
// Code 5
document.add(table);
document.close();
}
}
@raksha-agrawal
Copy link

hello in table I don't want bottom border and top border.how can i remove that border ?
image2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment