Nested Table Cell : Table Nested « PDF RTF « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Book
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
SCJP
Java » PDF RTF » Table NestedScreenshots 
Nested Table Cell
Nested Table Cell

import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

public class NestedTableCellPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NestedTableCellPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfPTable pageTot = new PdfPTable(1);
      pageTot.getDefaultCell().setPadding(0f);
      pageTot.getDefaultCell().setBorder(Rectangle.NO_BORDER);
      pageTot.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
      pageTot.setWidthPercentage(100f);

      PdfPTable cell = new PdfPTable(1);
      cell.getDefaultCell().setBorder(Rectangle.NO_BORDER);
      cell.getDefaultCell().setPadding(0f);

      PdfPCell info = new PdfPCell(new Phrase("Outside"));
      info.setBorder(Rectangle.NO_BORDER);
      pageTot.addCell(info);

      PdfPCell shipment = new PdfPCell(new Phrase(new Chunk("Cell")));
      shipment.setFixedHeight(100);
      shipment.setPaddingTop(5f);
      shipment.setPaddingBottom(10f);
      shipment.setBorder(Rectangle.BOX);
      shipment.setVerticalAlignment(Element.ALIGN_TOP);
      shipment.setHorizontalAlignment(Element.ALIGN_CENTER);
      cell.addCell(shipment);

      pageTot.addCell(cell);

      document.add(pageTot);
    catch (Exception e) {
      e.printStackTrace();
    }
    document.close();
  }

}

           
       
itext.zip( 1,748 k)
Related examples in the same category
1.Two Nested TablesTwo Nested Tables
2.Nested Tables DemoNested Tables Demo
3.Nested Tables without Point PositionNested Tables without Point Position
w___w__w___.___j_ava_2_s__.__c_o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.