We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Overlapping borders using nested tables

Hello!



I believe I found several issues with nested tables in aspose pdf.



Currently I try to create small demos of the issues. The first is the following:



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">






Java2HTML: BorderIssue.java






1 package de.gad.gfw.web.print.pdf.issues;
2
3 import aspose.pdf.BorderInfo;
4 import aspose.pdf.BorderSide;
5 import aspose.pdf.Cell;
6 import aspose.pdf.ColumnAdjustmentType;
7 import aspose.pdf.MarginInfo;
8 import aspose.pdf.Pdf;
9 import aspose.pdf.Row;
10 import aspose.pdf.Section;
11 import aspose.pdf.Table;
12 import aspose.pdf.Text;
13
14 public class BorderIssue {
15 public static void main(String[] args) {
16
17 // issue 01: when using nested tables the borders of outer and inner table overlap
18 // issue 02: when using nested tables repeating header rows are not repeated
19 // issue 03: embedding fonts does not work on Windows XP and Mac OS x 10.6
20
21 // create a pdf
22 Pdf pdf = new Pdf();
23 Section sec = pdf.getSections().add();
24
25 // prepare a margin
26 MarginInfo margin = new MarginInfo();
27 margin.setLeft(5);
28 margin.setRight(5);
29 margin.setTop(5);
30 margin.setBottom(5);
31
32 // Insert a bordered table with a margin of 5 points into the pdf...
33 Table outerTable = new Table(sec);
34 BorderInfo border = new BorderInfo(BorderSide.All.getValue(),
35 1.0f);
36 outerTable.setDefaultCellBorder(border);
37 outerTable.setDefaultCellPadding(margin);
38 sec.getParagraphs().add(outerTable);
39
40 // and create a single cell.
41 Row row = outerTable.getRows().add();
42 Cell cell = row.getCells().add();
43
44 // Create a second bordered table with the same margin ...
45 Table innerTable = new Table(sec);
46 innerTable.setDefaultCellBorder(border);
47 innerTable.setDefaultCellPadding(margin);
48
49 // and insert it into the single cell of the outer table.
50 cell.getParagraphs().add(innerTable);
51
52 // Create a cell in the inner table and put a dummy text into it.
53 row = innerTable.getRows().add();
54 cell = row.getCells().add();
55 cell.getParagraphs().add(new Text("Hello world!"));
56
57 pdf.save("aspose.pdf");
58 }
59 }







The result looks like: image



I expected to see two tables comprising one cell each with a neat border around each cell.



Best regards,
Juergen

Hello Juergen,

Thanks for using our products.

The issue is occurring because you have not specified the width of columns in each table. By default Aspose.Pdf is generating two tables both with column width of 100 points. Please add the following code line in order to resolve this problem.

innerTable.setColumnWidths("90");

The resultant PDF that I have generated using Aspose.Pdf for Java 2.7.0 is in attachment. Please take a look. In case it does not resolve your problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

Hello codewarrior!



Thank you very much for the quick help!



Best regards, Juergen