我们使用 SelectPdf Html2Pdf api 从 html 代码生成 pdf。这运作良好,但有一个问题我们无法找到解决方案。当我们在 a 中有一条长线时
标签,这条线超出了pdf。我们想要的是,这条线被分成多条线。
var html = $"<html><body><p>{aVeryLongLine}<p></body></html>";
SelectPdf.GlobalProperties.LicenseKey = "{our_license_key}";
var converter = new SelectPdf.HtmlToPdf();
converter.Options.AutoFitWidth = SelectPdf.HtmlToPdfPageFitMode.NoAdjustment;
converter.Options.AutoFitHeight = SelectPdf.HtmlToPdfPageFitMode.NoAdjustment;
var doc = converter.ConvertHtmlString(html, "");
var stream = new System.IO.MemoryStream();
doc.Save(stream);
pdfbytes = stream.ToArray();
stream.Close();
doc.Close();
我们尝试过使用 HtmlToPdfPageFitMode,但该选项只会缩小线条以使其适合页面,但这是不可读的,因为它变得太小了。有谁知道是否可以选择正确设置?