How To Show Grid Lines In PDF FILE

Topics: Developer Forum, Project Management Forum
Oct 3, 2009 at 10:08 AM


I would like to show grid lines in the PDF file for the proper allignment of the pdf in the older version u able to show and hide the grid lines but now in th v 1.7  i cant able to show or hide this grid Lines

Oct 3, 2009 at 10:57 PM

We are monitoring this work item in TCPDF that asks for full border support:

Until that is fixed, we unfortunately don't have fine control with borders in PDF output.

But if you want to show all gridlines you may try this:

TCPDF is being fed with HTML, so near line 741 in PHPExcel/Writer/HTML.php, locate this line

$html .= '    <table border="0" cellpadding="0" cellspacing="0" style="' . $style . '">' . "\r\n";

and change border="0" to border="1" so you have

$html .= '    <table border="1" cellpadding="0" cellspacing="0" style="' . $style . '">' . "\r\n";


Sep 6, 2010 at 11:46 AM



I've checked this work item in TCPDF :

They claim to have fixed the borders issue in their last release (see last comment on the work item).

Can someone take a look at that and see how it to integrate this fix into PHPExcel?

I'd like very much to see borders in the output of PHPExcel_Writer_PDF ;-)



Nov 12, 2010 at 2:10 AM

Yes I second that.  With this problem now fixed in the latest TCPDF library any chance of getting the borders problem fixed?



Nov 12, 2010 at 9:11 AM
bludginozzie wrote:

Yes I second that.  With this problem now fixed in the latest TCPDF library any chance of getting the borders problem fixed?

 I've already tried running some tests with the latest version of tcPDF, but if anything it's actually producing worse output for me. Cells without borders are getting an extremely thick (about 20px) black border that obscures some of the cell content, and merged cells with borders are only displaying a partial border in the top-right cell. It's something that I want to get right, because it will make a lot of users happy, but my focus for much of the last month has been on the performance of the Writers, particularly for Excel5 and Excel2007, and I think the 25%-30% improvement in speed (and the reduction in memory usage for the Excel5 Writer) will make people even happier with the next release. I know that the HTML and PDF Writers are also slow, and will be focusing my attentions on them over the next week to see if I can get similar speed improvements there. I'll take a look at the PDF borders while I'm doing that, and see if I can get better results with the newest tcPDF.

Nov 13, 2010 at 6:31 AM

That sounds great!


Nov 13, 2010 at 12:16 PM
bludginozzie wrote:

That sounds great! 

Remember that it is dependent on my being able to get the latest tcPDF working correctly. I know some people have just overwritten the version of tcPDF provided in the PHPExcel distribution with the latest source from, and it has worked for them. It doesn't work on any of my test boxes, so clearly some work is needed to ensure that it will work correctly for everybody; but a simple replacement may work for you.