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


相关推荐

  • jboss安装与配置_andrax安装出错

    jboss安装与配置_andrax安装出错一.              下载与安装JBoss在本文中,我们下载的JBoss版本为:4.2.1.GA。下载地址:http://www.jboss.org/jbossas/downloads/在如上的下载页中下载JBoss-4.2.1.GA.zip文件。下载完成后,将其解压缩后即可完成安装,解压缩后将其放置到一个不带空格的目录(若目录带有空格,例如:C:

    2022年10月3日
    2
  • 微信后台服务器能查撤回的消息吗,微信撤回的消息还能看到吗?查看方法介绍…「建议收藏」

    微信后台服务器能查撤回的消息吗,微信撤回的消息还能看到吗?查看方法介绍…「建议收藏」如果大家在使用钉钉办公软件的话,应该知道钉钉密聊功能,使用这个功能之后聊天的内容会自动销毁,而且不能进行复原操作的。所以很多用户都在问微信撤回的消息还能看到吗,是不是和钉钉密聊一样不能进行恢复了,接下来小编就为大家进行详细介绍,以及对微信撤回的消息查看方法进行介绍。微信撤回的消息按照原理或者是字面上的意思来说用户是看不到这类消息了,除非大家在对方未操作消息撤回之前已经进行了消息的查看,如果没有进行…

    2022年6月16日
    69
  • C语言实现学生成绩管理系统设计

    C语言实现学生成绩管理系统设计本系统有**增加学生记录、修改学生记录、删除学生记录、按姓名查询学生记录、按C语言成绩对学生进行排序、退出系统**6大功能。能够对学生的姓名,学号,c语言成绩做相应的操作。在检测到输入成绩大于55时,会自动加上5。该管理系统设计功能模块图:下面是源代码:#include”stdio.h”#include”string”/*定义学生结构体*/structStudent

    2022年6月20日
    27
  • C语言实现约分最简分式[通俗易懂]

    C语言实现约分最简分式[通俗易懂]题目要求:分数可以表示为分子/分母的形式。编写一个程序,要求用户输入一个分数,然后将其约分为最简分式。最简分式是指分子和分母不具有可以约分的成分了。如6/12可以被约分为1/2。当分子大于分母时,不需要表达为整数又分数的形式,即11/8还是11/8;而当分子分母相等时,仍然表达为1/1的分数形式。输入格式:输入在一行中给出一个分数,分子和分母中间以斜杠/分隔,如:12/34表示34分之12。…

    2025年7月30日
    4
  • c语言tinyxml使用方法,TinyXml使用方法[通俗易懂]

    c语言tinyxml使用方法,TinyXml使用方法[通俗易懂]本文用一个详细的例子说明了TiXml的使用方法。如写、查找、插入、替换、加载、遍历等常见操作。首先简单介绍一下TinyXml,要看详细的在网上搜搜了^_^:1、TinyXml源代码只有4个cpp文件和2个头文件。2、首先要理解TinyXml中的各个基本类型之间的关系,看看这个继承图大家就会很明白了!可以看到TinyXml中的注释comment,声明declaration,元素element,文本等…

    2022年5月6日
    63
  • 一分钟学习静态网页制作[通俗易懂]

    一分钟学习静态网页制作[通俗易懂]第一章静态网页制作:什么叫做HTML:超文本标记语言HTML优势:世界知名浏览器都支持Google,苹果,微软,等等……还有市场需求跨平台:1.win系统2.苹果系统3.linux系统w3c标准包涵:1.结构化标准(XHEML,XML)2.表现化标准(CSS)3.行为化标准(DOM,ECMAScript)网页的基本标签:1.标题标签:h1~h…

    2025年9月13日
    8

发表回复

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

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