<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FPDF%2FTable</id>
		<title>Java Tutorial/PDF/Table - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FPDF%2FTable"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/PDF/Table&amp;action=history"/>
		<updated>2026-04-07T22:09:58Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/PDF/Table&amp;diff=5538&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/PDF/Table&amp;diff=5538&amp;oldid=prev"/>
				<updated>2010-06-01T05:21:28Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:21, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/PDF/Table&amp;diff=5537&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/PDF/Table&amp;diff=5537&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Add table cell to table ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.DocumentException;&lt;br /&gt;
import com.lowagie.text.Element;&lt;br /&gt;
import com.lowagie.text.Font;&lt;br /&gt;
import com.lowagie.text.FontFactory;&lt;br /&gt;
import com.lowagie.text.PageSize;&lt;br /&gt;
import com.lowagie.text.Phrase;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document(PageSize.A4.rotate());&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable datatable = new PdfPTable(10);&lt;br /&gt;
    int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 };&lt;br /&gt;
    datatable.setWidths(headerwidths);&lt;br /&gt;
    datatable.setWidthPercentage(100);&lt;br /&gt;
    datatable.getDefaultCell().setPadding(5);&lt;br /&gt;
    datatable.setHeaderRows(2);&lt;br /&gt;
    datatable.getDefaultCell().setBorderWidth(1);&lt;br /&gt;
    for (int i = 1; i &amp;lt; 30; i++) {&lt;br /&gt;
      datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);&lt;br /&gt;
      datatable.addCell(&amp;quot;myUserId&amp;quot;);&lt;br /&gt;
      datatable.addCell(&amp;quot;long long name&amp;quot;);&lt;br /&gt;
      datatable.addCell(&amp;quot;No Name Company&amp;quot;);&lt;br /&gt;
      datatable.addCell(&amp;quot;D&amp;quot; + i);&lt;br /&gt;
      datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);&lt;br /&gt;
      for (int j = 0; j &amp;lt; 6; j++)&lt;br /&gt;
        datatable.addCell(Math.random() &amp;gt; .5 ? &amp;quot;Yes&amp;quot; : &amp;quot;No&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    datatable.setSplitLate(false);&lt;br /&gt;
    document.add(datatable);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Generates a PDF file with a table ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(3);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Paragraph(&amp;quot;header&amp;quot;));&lt;br /&gt;
    table.addCell(cell);&lt;br /&gt;
    table.addCell(&amp;quot;1.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;1.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.2&amp;quot;);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Nested Pdf Table ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(4);&lt;br /&gt;
    PdfPTable nested1 = new PdfPTable(2);&lt;br /&gt;
    nested1.addCell(&amp;quot;1.1&amp;quot;);&lt;br /&gt;
    nested1.addCell(&amp;quot;1.2&amp;quot;);&lt;br /&gt;
    PdfPTable nested2 = new PdfPTable(1);&lt;br /&gt;
    nested2.addCell(&amp;quot;20.1&amp;quot;);&lt;br /&gt;
    nested2.addCell(&amp;quot;20.2&amp;quot;);&lt;br /&gt;
    for (int k = 0; k &amp;lt; 24; ++k) {&lt;br /&gt;
      if (k == 1) {&lt;br /&gt;
        table.addCell(nested1);&lt;br /&gt;
      } else if (k == 20) {&lt;br /&gt;
        table.addCell(new PdfPCell(nested2));&lt;br /&gt;
      } else {&lt;br /&gt;
        table.addCell(&amp;quot;cell &amp;quot; + k);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Pdf Table Split Vertically ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(10);&lt;br /&gt;
    for (int k = 1; k &amp;lt;= 100; ++k) {&lt;br /&gt;
      table.addCell(&amp;quot;number &amp;quot; + k);&lt;br /&gt;
    }&lt;br /&gt;
    table.setTotalWidth(800);&lt;br /&gt;
    table.writeSelectedRows(0, 5, 0, -1, 50, 650, writer.getDirectContent());&lt;br /&gt;
    document.newPage();&lt;br /&gt;
    table.writeSelectedRows(5, -1, 0, -1, 50, 650, writer.getDirectContent());&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Pdf Table with Absolute Width ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(3);&lt;br /&gt;
    table.setTotalWidth(216f);&lt;br /&gt;
    table.setLockedWidth(true);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Paragraph(&amp;quot;header with colspan 3&amp;quot;));&lt;br /&gt;
    cell.setColspan(3);&lt;br /&gt;
    table.addCell(cell);&lt;br /&gt;
    table.addCell(&amp;quot;1.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;1.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.2&amp;quot;);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Pdf Table Without Borders ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(3);&lt;br /&gt;
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Paragraph(&amp;quot;header with colspan 3&amp;quot;));&lt;br /&gt;
    cell.setColspan(3);&lt;br /&gt;
    table.addCell(cell);&lt;br /&gt;
    table.addCell(&amp;quot;1.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;1.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2.2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3.2&amp;quot;);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}//&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Set Spacing Before/After a table ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(3);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Paragraph(&amp;quot;header with colspan 3&amp;quot;));&lt;br /&gt;
    cell.setColspan(3);&lt;br /&gt;
    table.addCell(cell);&lt;br /&gt;
    table.addCell(&amp;quot;2&amp;quot;);&lt;br /&gt;
    table.setSpacingBefore(15f);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    table.setSpacingAfter(10f);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Skip header ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(2);&lt;br /&gt;
    table.setWidthPercentage(100);&lt;br /&gt;
    table.setHeaderRows(1);&lt;br /&gt;
    PdfPCell h1 = new PdfPCell(new Paragraph(&amp;quot;Header 1&amp;quot;));&lt;br /&gt;
    h1.setGrayFill(0.7f);&lt;br /&gt;
    table.addCell(h1);&lt;br /&gt;
    PdfPCell h2 = new PdfPCell(new Paragraph(&amp;quot;Header 2&amp;quot;));&lt;br /&gt;
    h2.setGrayFill(0.7f);&lt;br /&gt;
    table.addCell(h2);&lt;br /&gt;
    PdfPCell cell;&lt;br /&gt;
    for (int row = 1; row &amp;lt;= 2000; row++) {&lt;br /&gt;
      document.add(table);&lt;br /&gt;
      table.deleteBodyRows();&lt;br /&gt;
      table.setSkipFirstHeader(true);&lt;br /&gt;
      cell = new PdfPCell(new Paragraph(String.valueOf(row)));&lt;br /&gt;
      table.addCell(cell);&lt;br /&gt;
      cell = new PdfPCell(new Paragraph(&amp;quot;Quick brown fox jumps over the lazy dog.&amp;quot;));&lt;br /&gt;
      table.addCell(cell);&lt;br /&gt;
    }&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table Aligned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.Element;&lt;br /&gt;
import com.lowagie.text.Paragraph;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document();&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable table = new PdfPTable(3);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Paragraph(&amp;quot;header with colspan 3&amp;quot;));&lt;br /&gt;
    cell.setColspan(3);&lt;br /&gt;
    table.addCell(cell);&lt;br /&gt;
    table.addCell(&amp;quot;1&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;2&amp;quot;);&lt;br /&gt;
    table.addCell(&amp;quot;3&amp;quot;);&lt;br /&gt;
    table.setWidthPercentage(100);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    table.setWidthPercentage(50);&lt;br /&gt;
    table.setHorizontalAlignment(Element.ALIGN_RIGHT);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    table.setHorizontalAlignment(Element.ALIGN_LEFT);&lt;br /&gt;
    document.add(table);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Use Table to create Report header ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.DocumentException;&lt;br /&gt;
import com.lowagie.text.Element;&lt;br /&gt;
import com.lowagie.text.Font;&lt;br /&gt;
import com.lowagie.text.FontFactory;&lt;br /&gt;
import com.lowagie.text.PageSize;&lt;br /&gt;
import com.lowagie.text.Phrase;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document(PageSize.A4.rotate());&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable datatable = new PdfPTable(10);&lt;br /&gt;
    int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 };&lt;br /&gt;
    datatable.setWidths(headerwidths);&lt;br /&gt;
    datatable.setWidthPercentage(100);&lt;br /&gt;
    datatable.getDefaultCell().setPadding(5);&lt;br /&gt;
    PdfPCell cell = new PdfPCell(new Phrase(&amp;quot;Report&amp;quot;, FontFactory&lt;br /&gt;
        .getFont(FontFactory.HELVETICA, 24, Font.BOLD)));&lt;br /&gt;
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);&lt;br /&gt;
    cell.setBorderWidth(2);&lt;br /&gt;
    cell.setColspan(10);&lt;br /&gt;
    cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));&lt;br /&gt;
    cell.setUseDescender(true);&lt;br /&gt;
    datatable.addCell(cell);&lt;br /&gt;
    document.add(datatable);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  We need 4 cells with rowspan 2 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import com.lowagie.text.Document;&lt;br /&gt;
import com.lowagie.text.DocumentException;&lt;br /&gt;
import com.lowagie.text.Element;&lt;br /&gt;
import com.lowagie.text.Font;&lt;br /&gt;
import com.lowagie.text.FontFactory;&lt;br /&gt;
import com.lowagie.text.PageSize;&lt;br /&gt;
import com.lowagie.text.Phrase;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPCell;&lt;br /&gt;
import com.lowagie.text.pdf.PdfPTable;&lt;br /&gt;
import com.lowagie.text.pdf.PdfWriter;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Document document = new Document(PageSize.A4.rotate());&lt;br /&gt;
    PdfWriter.getInstance(document, new FileOutputStream(&amp;quot;2.pdf&amp;quot;));&lt;br /&gt;
    document.open();&lt;br /&gt;
    PdfPTable datatable = new PdfPTable(10);&lt;br /&gt;
    int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 };&lt;br /&gt;
    datatable.setWidths(headerwidths);&lt;br /&gt;
    datatable.setWidthPercentage(100);&lt;br /&gt;
    datatable.getDefaultCell().setPadding(5);&lt;br /&gt;
&lt;br /&gt;
    datatable.getDefaultCell().setBorderWidth(2);&lt;br /&gt;
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);&lt;br /&gt;
    datatable.addCell(&amp;quot;User Id&amp;quot;);&lt;br /&gt;
    datatable.addCell(&amp;quot;Name\nAddress&amp;quot;);&lt;br /&gt;
    datatable.addCell(&amp;quot;Company&amp;quot;);&lt;br /&gt;
    datatable.addCell(&amp;quot;Department&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    PdfPTable permissions = new PdfPTable(6);&lt;br /&gt;
    permissions.getDefaultCell().setBorderWidth(2);&lt;br /&gt;
    permissions.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);&lt;br /&gt;
    permissions.getDefaultCell().setColspan(6);&lt;br /&gt;
    permissions.addCell(&amp;quot;Permissions&amp;quot;);&lt;br /&gt;
    permissions.getDefaultCell().setColspan(1);&lt;br /&gt;
    permissions.addCell(&amp;quot;Admin&amp;quot;);&lt;br /&gt;
    permissions.addCell(&amp;quot;Data&amp;quot;);&lt;br /&gt;
    permissions.addCell(&amp;quot;Expl&amp;quot;);&lt;br /&gt;
    permissions.addCell(&amp;quot;Prod&amp;quot;);&lt;br /&gt;
    permissions.addCell(&amp;quot;Proj&amp;quot;);&lt;br /&gt;
    permissions.addCell(&amp;quot;Online&amp;quot;);&lt;br /&gt;
    PdfPCell permission = new PdfPCell(permissions);&lt;br /&gt;
    permission.setColspan(6);&lt;br /&gt;
    datatable.addCell(permission);&lt;br /&gt;
    document.add(datatable);&lt;br /&gt;
    document.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>