从大型html生成PDF
本文关键字:PDF 生成 html 大型 | 更新日期: 2023-09-27 18:30:01
我正在从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,但不处理溢出。文本在页面后面继续。是否可以将页面的最大"高度"设置为不交叉,如果交叉,则会重新创建新页面?
希望它有意义!
非常感谢
您可以通过选择所需的PDF页面类型(如A1、A2等)来设置页面高度。后记,你的页面高度问题将自动由Aspose解决。有关更多信息,请参阅链接。。
Aspose PDF页面高度
更新
将CCD_ 1更新为CCD_。