如何使表格(或表格的一部分)在高度上填充容器的其余部分

发布于 2024-12-13 02:31:08 字数 312 浏览 3 评论 0原文

基本上,我正在尝试设置一个布局来使用 tcpdf 打印账单,并且我希望底部部分占据打印产品、服务和其他内容后剩余的空间。我想知道是否可以让它做到这一点而不用 javascript 计算它的高度。

我使用 javascript 时遇到的问题是,我不能只获取它们的高度并进行一些神奇的数学运算以使它们适合,因为它们不存在于窗口中。我必须以某种方式根据行数计算产品表的高度,这可能并不难,但是如果某些内容超出其单元格宽度并占用其中的两个单元格,我该怎么办?

非常感谢您的帮助。

我没有添加代码,因为实际上没有什么可添加的,它只是将 HTML 提供给 tcpdf 函数。

Basically I'm trying to set up a layout to print bills with tcpdf and I want the bottom part to take up the space remaining after I print the products and services and stuff. I'm wondering if I can make it do that without calculating its height with javascript.

The problem I have with javascript is that I can't just take their height and do some magic math to make them fit because they don't exist in a window. I'd have to somehow calculate the height of the products table based on the number of rows which might not be hard but what do I do if something exceeds its cell width and takes up two of them?

Help's totally apreciated.

i'm not adding code because there's really not much to add, it's just feeding HTML to the tcpdf function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少跟Wǒ拽 2024-12-20 02:31:08

使表格的底行变大是非常困难的。

替代解决方案:

  • table 包裹在div 中,并将其高度设置为100%。然后 div 将填充背景。如果您使表格不透明,它看起来会是正确的,除非您想要“将列边框延伸到底部”之类的内容。

  • HTML 不是创建分页输出的良好格式。 HTML 没有真正的“页面大小”概念,很难影响应该(或不应该)发生分页符的位置等。不要尝试远程操作输出,而是尝试直接驱动 TCPDF 框架。创建 PDF 页面对象,在整个高度上绘制表格轮廓,开始渲染单元格直到页面填满,开始新页面,冲洗,重复。

It's very hard to make the bottom row of a table grow.

Alternate solutions:

  • Wrap the table in a div and set it's height to 100%. The div will then fill the background. If you make the table opaque, it will look right unless you want something like "extend column borders to the bottom".

  • HTML is not a good format to create paged output. HTML has no real concept of "page size", it's hard to influence where a page break should (or should not) occur, etc. Instead of trying to manipulate the output remotely, try to drive the TCPDF framework directly. Create PDF page objects, draw the table outline over the full height, start rendering cells until a page is full, start new page, rinse, repeat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文