简体   繁体   English

HTML 渲染器 - 字母间距 CSS 不工作

[英]HTML Renderer - letter-spacing CSS not working

I'm generating PDF from HTML using HTML Renderer, but the letter-spacing HTML is not working:我正在使用 HTML 渲染器从 HTML 生成 PDF,但是字母间距 Z4C4AD5FCA2E03A3F74DBB1ACED 不工作:

h1 {
  text-align: center;
  font-size: 2.2em;
  letter-spacing: 3px;
}

Generating PDF like below:生成 PDF 如下所示:

    var config = new PdfGenerateConfig();
    config.PageOrientation = PageOrientation.Landscape;
    config.PageSize = PdfSharpPageSize.A4;

    string cssStr = File.ReadAllText(folderPath + "1.css");
    CssData css = PdfGenerator.ParseStyleSheet(cssStr);

    PdfSharp.Pdf.PdfDocument pdf = PdfGenerator.GeneratePdf(html, config, css);

    MemoryStream stream = new MemoryStream();
    pdf.Save(stream, false);
    byte[] bytes = stream.ToArray();

    File.WriteAllBytes(folderPath + "document.pdf", bytes);

Also tried inline CSS style, also not working:还尝试了内联 CSS 样式,也不起作用:

<h1 style="letter-spacing:3px;">

Maybe one of these links could be useful?也许这些链接之一可能有用?

It seems as if you have to use the 'XTextFormatter' class to adjust word spacing in PDFsharp似乎您必须使用“XTextFormatter”class 来调整 PDFsharp 中的字间距

I haven't tested it, but it seems the solution to your problem.我还没有测试它,但它似乎可以解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM