简体   繁体   English

在html中生成PDF文件时如何设置字体系列

[英]How to set font family when generating PDF file in html

I'm using html for design pdf template, but my pdf not taken proper font-family.it taken default font family.我正在使用 html 设计 pdf 模板,但我的 pdf 没有采用正确的字体系列。它采用了默认字体系列。 I have using stRyde font family and font family installed in project folder but it's not generate stRyde font family .below styles use in html.我在项目文件夹中使用了 stRyde 字体系列和字体系列,但它不会生成 stRyde 字体系列。以下样式在 html 中使用。

<style>
  @font-face {
     font-family: 'stRyde';
     font-display: fallback;
     src: url('./fonts/StRydeRegular.woff') format("woff"), 
     url('./fonts/StRydeRegular.ttf') format("truetype"), url('./fonts/StRyde- 
     Regular.otf') format("otf");
  }

  html {
     font-family: stRyde, Arial, Helvetica, sans-serif;
     --dark-brown: rgb(76, 29, 12);
  }
</style>

below screen shot show pdf text.下面的屏幕截图显示 pdf 文本。

在此处输入图片说明

Have you tried print media query??您是否尝试过印刷媒体查询?

@media print {
  selector{
    font-family: .....;  
  }
}

But I am not sure if the font desired on print should be installed on the user's device or not.但我不确定是否应该在用户的设备上安装打印所需的字体。

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

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