如何使表格(或表格的一部分)在高度上填充容器的其余部分
基本上,我正在尝试设置一个布局来使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使表格的底行变大是非常困难的。
替代解决方案:
将
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 adiv
and set it's height to100%
. Thediv
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.