table array什么意思_html中table属性

table array什么意思_html中table属性IamcreatingalargeHTMLtableandIhaveproblemwithpagebreaksasyoucanseeinthefollowingimage:Isthereamethodsettledowntheproblemautomatically?Orwhatisthewaytodoit?Tryaddi…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

I am creating a large HTML table and I have problem with page breaks as you can see in the following image:

b1c564065c8f886646ea5ab0f72156f4.png

Is there a method settle down the problem automatically? Or what is the way to do it?

Try adding this to your

tags: nobr=”true”.

So a quick example would be:

Test Test 2

The nobr=”true” prevents the table rows from ever breaking apart. You can also put this on

and tags.

I know it’s rather old question, but I had this same issue today, my table was splitted between pages and I investigated a little bit further on the method from FastTrack’s answer and it turned out that you can also use the nobr=”true” attribute also to the

Test Test 2

Warning – this code makes sense only when your tables are smaller than one page.

I had the same problem with overlapping headers.

I tried yevgeny solution, but that required some more editions to my PDF generator code (I have lots of PDFs outputs written in FPDF and I wanted to minimize the process of miograting them to TCPDF), so I used this more simple solution

class MYPDF extenfs TCPDF {

//your initialization code

function header(){

//your code here

//we change only the top margin and this executes for every header in every page, even the frst one

$this->SetTopMargin($this->GetY());

}

}

yevgeny

roney, thank you so much, writing HTML generated overlaps with the header for pages 2,3 .. this worked for me:

class your_PDF extends TCPDF

{

var $top_margin = 20;

function Header() {

// set top margin to style pages 2, 3..

//title goes here

$this->top_margin = $this->GetY() + 5; // padding for second page

}

}

in your code

// set top margin to style pages 2, 3..

$pdf->SetMargins(15, $pdf->top_margin, 15);

For the interested, just do as follows and it will work like a charm:

$pdf->SetMargins(0, 0, 0);

$pdf->SetHeaderMargin(0);

$pdf->SetFooterMargin(0);

Strangely enough the solutions mentioned here didn’t work for me. Well, it did sortof, but content inside of tags would get repeated (as desired) but would then cause layout issues for the cell above or below if it was rowspanned. As I experimented, it just got worse.

My solution, while inelegant, was to set AutoPageBreak to false, put a row incrementer counter up, incrementing for each row, then checked if it had exceeded a certain value. If so, I closed the table, used writeHTML(), called addPage() and then continued , having rebuilt it as a new table, headers and all.

Like I said, inelegant, but it worked. I hope this helps someone … it’s a fairly obvious solution but execution is not always quite so obvious. Also, there may be a better way that works for your particular situation, but if it doesn’t, give mine a try. :)

Some CSS solved for me:

// Include the main TCPDF library (search for installation path).

require_once(‘tcpdf/tcpdf.php’);

// create new PDF document

$pdf = new TCPDF(‘R’, PDF_UNIT, PDF_PAGE_FORMAT, true, ‘UTF-8’, false);

// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetAuthor(‘Author’);

$pdf->SetTitle(‘TCPDF HTML Table’);

$pdf->SetSubject(‘TCPDF Tutorial’);

$pdf->SetKeywords(‘TCPDF, PDF, html,table, example, test, guide’);

// set default header data

$pdf->SetHeaderData(”, ”, ‘ HTML table’, ”);

// set header and footer fonts

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, ”, PDF_FONT_SIZE_MAIN));

$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, ”, PDF_FONT_SIZE_DATA));

// set default monospaced font

//$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins

$pdf->SetMargins(15, 15, 15);

$pdf->SetHeaderMargin(15);

$pdf->SetFooterMargin(15);

// set auto page breaks

$pdf->SetAutoPageBreak(TRUE, 15);

// set image scale factor

//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// ———————————————————

// set font

$pdf->SetFont(‘times’, ”, 10);

// add a page

$pdf->AddPage();

$start = 1;

$end = 254;

$step = 1;

$arr = range($start, $end, $step);

$table_header .= sprintf(“

%s%s%s%s”, ‘IP’, ‘Computer’, ‘User’, ‘Fone’);

foreach ($arr as $ar) {

$row[] = $ar;

}

foreach ($row as $r):

if (($r % 40) === 0):

$table_header;

endif;

$table .= sprintf(“

\n%s\n%s\n%s\n%s\n\n”, $r, $r, $r, $r);

endforeach;

$now = date(“d/m/Y”);

$caption = “

IP addresses
$now\n”;

$n = “\n”;

$tbl = <<

table{

font-family: serif;

font-size: 11pt;

}

table tr {

}

table tr td {

padding:3px;

border:#000000 solid 1px;

}

em {

font-size: 4pt;

}

tr { white-space:nowrap; }

{$caption}

{$table_begin}

{$table_header}

{$table}

EOD;

$pdf->writeHTML($tbl, true, false, false, false, ”);

// reset pointer to the last page

//$pdf->lastPage();

// ———————————————————

//Close and output PDF document

$pdf->Output(‘html_table.pdf’, ‘I’);

//============================================================+

// END OF FILE

//============================================================+

have you tried

This is my header which appears on every page

My Content

I’m using smarty, with this you have more possibilities to manually break the table (e.g. if you’re using borders). If needed, i’ll post this, too…

来源:https://stackoverflow.com/questions/5846164/tcpdf-html-table-and-page-breaks

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/196002.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • winserver2003DNS服务器配置[通俗易懂]

    winserver2003DNS服务器配置[通俗易懂]目前很多企业事业单位都建立了单位内部的局域网,网络内部都配备相关的服务器(如web、ftp等服务器)。内部网络的用户都希望所有的服务器都用域名来访问,网络管理员可以采用在内部搭建DNS服务器的方式来实现。在内部网络搭建DNS服务器,让用户在其计算的“DNS服务器的IP地址”中输入内部网络DNS服务器的ip地址。在该内部网络的DNS服务器上建立正向、方向搜索区域。将没有注册互联网

    2022年6月1日
    118
  • 位图和矢量图区别

    位图和矢量图区别位图和矢量图是计算机图形中的两大概念,这两种图形都被广泛应用到出版,印刷,互联网[如flash和svg]等各个方面,他们各有优缺点,两者各自的好处几乎是无法相互替代的,所以,长久以来,矢量跟位图在应用

    2022年8月2日
    7
  • 卸载vs2013_如何卸载vs2015

    卸载vs2013_如何卸载vs2015最近編譯代碼時由於出現頭文件不匹配,需要升級VS2005,升級比較麻煩,乾脆直接過渡到VS2008得了.先把.NETFramework從1.0一直刪除到3.0,再刪除一些相關依賴包時,安裝程式出錯.找了一下資料,正確的安裝過程如下:VisualStudio2005进入控制面板,运行添加或删除程序卸载"MSDNLibraryforVisualStudio2005Beta"卸载"…

    2022年9月23日
    5
  • JS–免费刷流量软件工具源码

    JS–免费刷流量软件工具源码&lt;!DOCTYPEHTMLPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;html&gt;&lt;head&gt;&lt;metahttp-equiv="Content-Type"cont

    2022年9月29日
    4
  • Linux curl 命令详解,以及实例

    Linux curl 命令详解,以及实例转载来源作者 海底苍鹰地址 http blog 51yip com linux 1049 htmllinuxcur 是一个利用 URL 规则在命令行下工作的文件传输工具 它支持文件的上传和下载 所以是综合传输工具 但按传统 习惯称 url 为下载工具 一 curl 命令参数 有好多我没有用过 也不知道翻译的对不对 如果有误的地方 还请指正 查看复

    2025年6月2日
    2
  • Idea激活码永久有效Idea2021.1激活码教程-持续更新,一步到位[通俗易懂]

    Idea激活码永久有效Idea2021.1激活码教程-持续更新,一步到位[通俗易懂]Idea激活码永久有效2021.1激活码教程-Windows版永久激活-持续更新,Idea激活码2021.1成功激活

    2022年6月17日
    42

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号