rveach
2014-12-30 20:25:50 UTC
I couldn't find a bug tracking maillist, so I am posting this here. If there
is a better place for it, let me know. Thanks.
I was messing around with PDF tables when I ran into an issue I couldn't
reproduce on a smaller version pdf.
I narrowed down the issue to how I am creating the cells and the contents
inside the cell and will provide a breif code example of the issue.
The objects and order of creation are the same for both methods, the
differences come from using the constructors versus the add methods.
The add methods seem to create an extra line of blank space in the cell not
seen when you use the constructors directly. This seems like a bug to me
since I am not adding any extra data/attributes to the cell to make it
display differently.
I am using Java with iText version 5.5.4.
<code>
import java.io.FileOutputStream;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Font.FontFamily;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class TestPdf {
public static void main(String[] args) throws Exception {
final Document document = new Document(PageSize.LETTER.rotate(), 21, 21,
30, 35);
PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
document.open();
final Font font = new Font(FontFamily.HELVETICA, //
12.0f * 0.75f,//
Font.BOLD, //
BaseColor.BLACK);
// method 1
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorderColor(BaseColor.BLACK);
table.getDefaultCell().setBorderWidth(1);
table.setWidthPercentage(100);
Phrase phrase = new Phrase();
phrase.add(new Chunk("Method 1", font));
PdfPCell cell = new PdfPCell(table.getDefaultCell());
cell.addElement(phrase);
table.addCell(cell);
document.add(table);
// method 2
PdfPTable table2 = new PdfPTable(1);
table2.getDefaultCell().setBorderColor(BaseColor.BLACK);
table2.getDefaultCell().setBorderWidth(1);
table2.setWidthPercentage(100);
table2.addCell(new Phrase(new Chunk("Method 2", font)));
document.add(table2);
document.close();
}
}
</code>
Which produces the 2 tables:
***********************
* *
* Method 1 *
***********************
* Method 2 *
***********************
--
View this message in context: http://itext-general.2136553.n4.nabble.com/Table-Columns-Heights-different-with-Constructors-versus-Add-Methods-tp4660649.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
is a better place for it, let me know. Thanks.
I was messing around with PDF tables when I ran into an issue I couldn't
reproduce on a smaller version pdf.
I narrowed down the issue to how I am creating the cells and the contents
inside the cell and will provide a breif code example of the issue.
The objects and order of creation are the same for both methods, the
differences come from using the constructors versus the add methods.
The add methods seem to create an extra line of blank space in the cell not
seen when you use the constructors directly. This seems like a bug to me
since I am not adding any extra data/attributes to the cell to make it
display differently.
I am using Java with iText version 5.5.4.
<code>
import java.io.FileOutputStream;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Font.FontFamily;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class TestPdf {
public static void main(String[] args) throws Exception {
final Document document = new Document(PageSize.LETTER.rotate(), 21, 21,
30, 35);
PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
document.open();
final Font font = new Font(FontFamily.HELVETICA, //
12.0f * 0.75f,//
Font.BOLD, //
BaseColor.BLACK);
// method 1
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorderColor(BaseColor.BLACK);
table.getDefaultCell().setBorderWidth(1);
table.setWidthPercentage(100);
Phrase phrase = new Phrase();
phrase.add(new Chunk("Method 1", font));
PdfPCell cell = new PdfPCell(table.getDefaultCell());
cell.addElement(phrase);
table.addCell(cell);
document.add(table);
// method 2
PdfPTable table2 = new PdfPTable(1);
table2.getDefaultCell().setBorderColor(BaseColor.BLACK);
table2.getDefaultCell().setBorderWidth(1);
table2.setWidthPercentage(100);
table2.addCell(new Phrase(new Chunk("Method 2", font)));
document.add(table2);
document.close();
}
}
</code>
Which produces the 2 tables:
***********************
* *
* Method 1 *
***********************
* Method 2 *
***********************
--
View this message in context: http://itext-general.2136553.n4.nabble.com/Table-Columns-Heights-different-with-Constructors-versus-Add-Methods-tp4660649.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php