如果新页面不适合,我该如何在新页面上启动内容

时间:2021-08-08 02:43:17

I'm using Pechkin to convert html content with css to pdf files.

我正在使用Pechkin将带有CSS的html内容转换为pdf文件。

The problem I am facing is that a part of a html block is being cut off because it doesn't fit on the current page anymore.

我面临的问题是html块的一部分被切断,因为它不再适合当前页面。

Now what i would like is that when the content doesn't fit on the current page that it creates it on the next page.

现在我想要的是当内容不适合它在下一页上创建它的当前页面时。

Is this possible with Pechkin?

Pechkin有可能吗?

Code:

码:

var pechkin = new SynchronizedPechkin(new GlobalConfig());
return pechkin.Convert(new ObjectConfig()
                         .SetLoadImages(true).SetZoomFactor(1.5)
                         .SetPrintBackground(true)
                         .SetScreenMediaType(true)
                         .SetPrintBackground(true)
                         .SetCreateExternalLinks(true), html);

如果新页面不适合,我该如何在新页面上启动内容

2 个解决方案

#1


3  

A way to add page breaks is by injecting CSS into your HTML.

添加分页符的方法是将CSS注入HTML。

<div style='page-break-after:always'></div>

If you want to prevent certain HTML blocks to be cut off you can try wrapping the with this div (or apply the style to your existing code block:

如果要阻止某些HTML块被切断,可以尝试使用此div包装(或将样式应用于现有代码块:

<div style='page-break-inside: avoid;'></div>

#2


0  

Instead of using float elements I switched to inline-block elements. I gave the inline-block elements the style: page-break-inside: avoid; and it now knows when to start on a new page.

我没有使用浮动元素,而是切换到内联块元素。我给了内联块元素样式:page-break-inside:avoid;它现在知道何时开始新页面。

#1


3  

A way to add page breaks is by injecting CSS into your HTML.

添加分页符的方法是将CSS注入HTML。

<div style='page-break-after:always'></div>

If you want to prevent certain HTML blocks to be cut off you can try wrapping the with this div (or apply the style to your existing code block:

如果要阻止某些HTML块被切断,可以尝试使用此div包装(或将样式应用于现有代码块:

<div style='page-break-inside: avoid;'></div>

#2


0  

Instead of using float elements I switched to inline-block elements. I gave the inline-block elements the style: page-break-inside: avoid; and it now knows when to start on a new page.

我没有使用浮动元素,而是切换到内联块元素。我给了内联块元素样式:page-break-inside:avoid;它现在知道何时开始新页面。