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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 日语自动词和他动词是什么意思_日语自动词他动词总结

    日语自动词和他动词是什么意思_日语自动词他动词总结http://coffeejp.com/bbs/thread-182243-1-1.html自动词:强调自发的行为他动词:强调他人驱使的行为拿到两个动词后按照它们的构词形式可以进行区分,基本可以分为4种方法(1)两个动词都以「る」结尾时:看「る」前的那个假名(汉字除外),如果是「あ」段假名,一般是自动词;如果是「え」段假名,一般是他动词(2)两个动词一个以「る」结尾,另一个不是以「る」结尾…

    2025年7月3日
    3
  • 通过数据泵expdp、impdp方式备份与还原(导出与导入)Oracle数据库

    通过数据泵expdp、impdp方式备份与还原(导出与导入)Oracle数据库前言备份还原oracle数据库的方式有很多种,本文只讲解使用expdp、impdp数据泵方式备份与还原(恢复)数据库,此种方式可以导出/导入数据库表以及表中的数据。请自行修改目录路径,否则出现错误别怪我哦~一、备份step1:使用system登录oracle打开DOS命令行界面,使用system用户登录oracle,格式:sqlplus用户名/密码@实例名(或者使用plsql……

    2022年10月20日
    3
  • html5div居中属性,html怎样让div居中

    html5div居中属性,html怎样让div居中html让div居中的方法:1、通过加“内容”标签让div居中;2、在div中加入“margin:0auto属性;”自动调节居中。本文操作环境:windows7系统、HTML5&&CSS3版、DellG3电脑。DIV居中提供两个方法:1、简单快捷方法就是加内容标签。示例:center居中我要居中啦2、div中加入margin:0auto属性;自动调节居中。示例2:margin…

    2025年5月25日
    3
  • java setaccessible_java.lang.reflect.AccessibleObject.setAccessible(boolean flag)方法示例

    java setaccessible_java.lang.reflect.AccessibleObject.setAccessible(boolean flag)方法示例java lang reflect AccessibleOb setAccessibl booleanflag 方法将此对象的可访问标志设置为指定的布尔值 设置值为 true 表示反射对象应该在使用时抑制 Java 语言访问检查 设置值为 false 表示反射对象应强制执行 Java 语言访问检查 声明以下是 java lang reflect AccessibleOb setAccessi

    2025年9月13日
    4
  • 计算权重的方法_ahp权重计算方法

    计算权重的方法_ahp权重计算方法三.层叠和继承+继承父元素拥有了某个css属性,子元素不需要任何条件的情况下都会拥有父元素的属性。并不是所有的css属性都能继承,可以被继承的css属性有以下:colortextlin

    2022年8月4日
    7
  • ETH硬分叉降低了显卡矿机的挖矿收益吗?

    ETH硬分叉降低了显卡矿机的挖矿收益吗?“北京时间2019年3月1日凌晨3:52分,ETH完成了君士坦丁堡硬分叉升级。这场从2018年8月份就开始计划的硬分叉,几经波折,但最终是平稳顺利的。虽然对比其他主流币种轰轰烈烈的硬分叉,ETH这次硬分叉显得过于平淡,但还是有很多矿工朋友想知道它是否降低了ETH的挖矿收益,未来挖矿收益如何变化,显卡矿机未来的出路在哪里?”笔者根据最近一年的ETH挖矿难度、挖矿收益、币价等变化情况,做了一些…

    2022年6月9日
    48

发表回复

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

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