我正在使用Gmanny的Pechkin Pdf库,它运行得很好.这是我的代码:
private void CreatePdfPechkin(string htmlString, string fileName)
{
//Transform the HTML into PDF
var pechkin = Factory.Create(new GlobalConfig()
.SetMargins(new Margins(100, 50, 100, 100))
.SetDocumentTitle("Test document")
.SetPaperSize(PaperKind.A4)
.SetCopyCount(1)
//.SetPaperOrientation(true)
// .SetOutputFile("F:/Personal/test.pdf")
);
ObjectConfig oc = new ObjectConfig();
oc.Footer.SetLeftText("[page]");
oc.Footer.SetTexts("[page]", "[date]", "[time]");
oc.Header.SetCenterText("TEST HEADER TEST1");
oc.Header.SetHtmlContent("<h1>TEST HEADER V2</h1>");
oc.SetAllowLocalContent(true);
//// create converter
//IPechkin ipechkin = new SynchronizedPechkin(pechkin);
// set it up using fluent notation
var pdf = pechkin.Convert(new ObjectConfig()
.SetLoadImages(true).SetZoomFactor(1.5)
.SetPrintBackground(true)
.SetScreenMediaType(true)
.SetCreateExternalLinks(true), htmlString);
//Return the PDF file
Response.Clear();
Response.ClearContent();
Response.ClearHeaders(); …Run Code Online (Sandbox Code Playgroud) 我正在使用pechkin dll基于某些HTML生成PDF文件.
这一切都很好,除了我需要在某些地方添加分页符,我不知道如何.
我认为使用css page-break-before,但这似乎不起作用.
我正在使用的HTML的一个例子是:
<table style="border-top: 0px solid black; border-bottom: 2px solid black; height: 30px; width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 200px;"><strong>Recommendation</strong></td>
<td style="width: 600px;">[6060:Builder Recommendation]</td>
</tr>
</tbody>
</table>
<table style="page-break-before: always;border-top: 0px solid black; border-bottom: 2px solid black; background-color: #99ccff; height: 30px; width: 800px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><strong>Summary of Actions</strong></td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我用来生成PDF的代码如下:
Dim buf As Byte() = Pechkin.Factory.Create(New GlobalConfig().SetMargins(New Margins(20, 20, 20, 20))
.SetDocumentTitle("").SetCopyCount(1).SetImageQuality(100)
.SetLosslessCompression(True)
.SetMaxImageDpi(300)
.SetOutlineGeneration(True)
.SetOutputDpi(1200)
.SetPaperOrientation(True)
.SetPaperSize(PaperKind.A4) …Run Code Online (Sandbox Code Playgroud) 我正在使用 Pechkin 将带有 css 的 html 内容转换为 pdf 文件。
我面临的问题是 html 块的一部分被切断,因为它不再适合当前页面。
现在我想要的是,当内容不适合当前页面时,它会在下一页上创建它。
佩希金可能做到这一点吗?
代码:
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);
Run Code Online (Sandbox Code Playgroud)
