在飞碟PDF上,为什么在我的粗体文本之后添加空格,我该如何解决?

问题描述

我正在使用飞碟PDF为电子邮件活动生成PDF。我们正在遇到下面描述的问题,其中某些HTML元素最终在点标之前需要渲染并添加空间。

首先,这是我的样式表,可用于转换为PDF:

@font-face {
    font-family: 'Montserrat';
    src: url('path/Montserrat-Regular-400.ttf');
    font-weight: 400;
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: Identity-H;
}
@font-face {
    font-family: 'Montserrat';
    src: url('path/Montserrat-Bold-700.ttf');
    font-weight: 700;
    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: Identity-H;
}
* {
    font-family: 'Montserrat',sans-serif;
    font-weight: 400;
}
strong,b {
    font-weight: 700;
}

要转换的HTML:

<p>Here is a test paragraph. First,we use <b>b tags to denote bold text</b>.<br/>Next,we use <strong>strong tags to denote bold text</strong>.<br/>Finally,we use a <span style='font-weight: 700'>span with an inline style to denote bold text</span>.<br/><br/>This also occurs around <a href='#'>anchor tags that include and href</a>.

这是生成的PDF输出:

HTML to PDF conversion result

注意句点前的空格。

我尝试将页边距和填充设置为零,并添加display: inline-block,但都没有成功。我也尝试过调整white-space属性,但是这也不起作用。如果我将标点符号放在标签中,问题就消失了,但这对于我的应用程序最终是不可取的。看起来像这样:

HTML:

<p>Here is a test paragraph. First,we use <b>b tags to denote bold text.</b><br/>Next,we use <strong>strong tags to denote bold text.</strong><br/>Finally,we use a <span style='font-weight: 700'>span with an inline style to denote bold text.</span><br/><br/>This also occurs around <a href='#'>anchor tags that include and href.</a>

Corrected result

也许这是字体的问题,还是Java方面的问题?非常感谢您的帮助。

编辑为了清晰起见:我的开发环境没有可用的字体,因此屏幕截图实际上未应用Montserrat。生产中存在正确应用字体的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)