0

我正在从 HTML 字符串生成 PDF。当这个字符串真的很长时,我想创建一个新页面,拆分文本(不破坏html)等等。

这是我的代码:

// instantiate Pdf object
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

// specify the Character encoding for for HTML file
pdf.HtmlInfo.CharSet = "UTF-8";
pdf.HtmlInfo.Margin.Left = 10;
pdf.HtmlInfo.Margin.Right = 10;
pdf.HtmlInfo.PageHeight = 1050;
pdf.HtmlInfo.PageWidth = 730;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
pdf.HtmlInfo.TryEnlargePredefinedTableColumnWidthsToAvoidWordBreaking = true;
pdf.HtmlInfo.CharsetApplyingLevelOfForce = Aspose.Pdf.Generator.HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent;
// bind the source HTML

pdf.BindHTML("MyVeryVeryLongHTML");

MemoryStream stream = new MemoryStream();
pdf.Save(stream);

byte[] pdfBytes = stream.ToArray();

此代码适用于 HTML,但未处理溢出。文本在页面之后继续。是否可以将页面的最大“高度”设置为不交叉,如果可以,它会重新创建一个新页面?

希望这是有道理的!

非常感谢

4

1 回答 1

1

您可以通过选择所需的 PDF 页面类型来设置页面高度,例如 A1、A2 等。后记,您的页面高度问题将由 Aspose 自动处理。更多请参考链接。。

设置 PDF 页面高度

更新

更新pdf.HtmlInfopdf.PageSetup (or pdf.PageInfo)添加底部边距。

于 2016-01-12T11:30:15.427 回答