简体   繁体   English

HTML分页问题

[英]HTML Page Break Issue

I am converting HTML into PDF and its working perfectly but I have an issue with how data is being displayed. 我正在将HTML转换为PDF,并且可以正常工作,但是我对数据的显示方式有疑问。

I have an array of strings and I am looping through them and displaying them within my ejs template.For example: 我有一个字符串数组,正在遍历它们并在我的ejs模板中显示它们,例如:

<div style="page-break-after: auto; padding: 10px;">
  <h3>Cost Saving Calculation:</h3>
  <p><%= modules[i].costSavedInfo %></p>
</div>

<div style="page-break-after: auto; padding: 10px;">
  <h3>Culture Change</h3>
  <p><%= modules[i].cultureChange %></p> 
</div>

<div style="page-break-after: auto; padding: 10px;">
  <h3>Other Efficiency</h3>
  <p><%= modules[i].otherEfficieny %></p>
</div>

The issue: 问题:

When the PDF is generated the text is displayed across 2 pages like this: 生成PDF时,文本将跨2页显示,如下所示:

在此处输入图片说明

In the above image half the text is on one pdf page and other on second page. 在上图中的一半文本在一个pdf页面上,另一文本在第二页上。

I am not sure whether it is possible or not but how can I change the HTML that it moves the text over to a new page if its going to be displayed across 2 pages. 我不确定是否可行,但是如果要在2页上显示文本,如何更改将文本移动到新页面的HTML。 Now the length of the text in the array could be anything.There are no word limitations. 现在数组中的文本长度可以是任何长度,没有单词限制。

Is this even possible? 这有可能吗?

The problems you have when a page break confuses your paragraphs are called orphans and widows. 分页符使您的段落混乱时遇到的问题称为孤儿和寡妇。

You can define via CSS how many lines are not separated before breaking the page. 您可以通过CSS定义在分页之前不分隔多少行。

Please check out these descriptions: 请查看以下描述:

widows - "The widows property in CSS controls the minimum number of lines of a paragraph that can fall to a new page." widows- “ CSS中的widows属性控制可以落入新页面的段落的最小行数。”

orphans - "The orphan property controls the minimum number of lines of a paragraph that can be left on the old page." orphans- “ orphan属性控制可以在旧页面上保留的段落的最小行数。”

I think, you want to define both properties to have a senseful output. 我想,您想定义两个属性以产生有意义的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM