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


相关推荐

  • layout_gravity和gravity的用法

    layout_gravity和gravity的用法也谈layout_gravity和gravity的用法相信对于Android的初学者来说,大家都曾经被layout里这两个极其相似的属性迷惑过。简单使用一下搜索工具,我们就不难找到下面这样的答案:layout_gravity表示组件自身在父组件中的位置gravity            表示组件的子组件在组件中的位置看似很简单嘛~)貌似大伙瞅一眼就明白了。

    2022年7月15日
    14
  • 小技巧——防止系统出问题文件丢失

    为什么要进行数据备份,怕有一天数据你真的找不回来的时候,还有后悔药可以吃!有时候数据在你手上的时候你可能觉得它的价值不是很高,但是一旦你失去,你就会发现,它的重要性远远超过了你的想象!不犯错就不会成长,这次我一定要记住,让这种错误以后再也不要犯!重要的资料不要放到c盘!!! 不要放到桌面!!! 重要的资料不要放到c盘!!! 不要放到桌面!!!

    2022年2月25日
    43
  • jar包反编译工具

    jar包反编译工具在学习和开发JAVA项目中,我们经常会用到第三方提供的一些jar。使用这些第三方工具包,可以提高我们开发的效率,缩短开发的时间。有的第三方工具,提供具体的使用说明和源代码,有时有的却不提供源代码,使用说明也不是很具体,这对我们使用就非常不方便。  有道是,知其然才知其所以然。有时候,我们…

    2022年7月8日
    25
  • 关于python中lambda函数的描述_Python全局变量

    关于python中lambda函数的描述_Python全局变量PythonLambda表达式

    2022年10月9日
    0
  • 密宗经典是佛说的吗_华为微信语音加密怎么试听

    密宗经典是佛说的吗_华为微信语音加密怎么试听什么?佛经都能用来加密了?自上次的社会主义核心价值观加密之后,我已经见怪不怪了。题目:夜哆悉諳多苦奢陀奢諦冥神哆盧穆皤三侄三即諸諳即冥迦冥隸數顛耶迦奢若吉怯陀諳怖奢智侄諸若奢數菩奢集遠俱老竟寫明奢若梵等盧皤豆蒙密離怯婆皤礙他哆提哆多缽以南哆心曰姪罰蒙呐神。舍切真怯勝呐得俱沙罰娑是怯遠得呐數罰輸哆遠薩得槃漫夢盧皤亦醯呐娑皤瑟輸諳尼摩罰薩冥大倒參夢侄阿心罰等奢大度地冥殿皤沙蘇輸奢恐豆侄得罰提哆伽諳沙楞缽三死怯摩大蘇者數一遮解析:这题是攻防世界中的一道题目,这一段文字是佛经,按..

    2022年10月23日
    0
  • 黑盒测试的优缺点_黑盒测试的概念

    黑盒测试的优缺点_黑盒测试的概念黑盒测试概念:又称功能测试或数据驱动测试,是用来检测每个功能是否正常使用。黑盒测试主要意味着测试要在软件的接口处进行,这种测试方法是将测试对象看成一个盒子,测试人员不考虑内部,直接按照需求规则说明书,直接检查他的功能是否符合要求。如上图所示,将系统看成黒盒,内部如何实现是不需要了解的,只需要知道输入和预期输出。黑盒的优缺点介绍:黑盒测试的优点有:1.不需要了解程序内部的代码及实现,操作…

    2022年10月3日
    0

发表回复

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

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