wicked_pdf 生产中字体太大

2023-12-15

我遇到一个问题,渲染的 PDF 的字体大小为产量较大。在开发中生成的 PDF 中,一切看起来都很棒。

这是来自的渲染图发展:

enter image description here

这是来自的渲染图生产:

enter image description here

这使得我很难为开发中的生产服务器格式化我的文档。你能看一下吗?

HTML 版本:http://www.hearingtracker.com/tickets/170

PDF下载:http://www.hearingtracker.com/tickets/170.pdf

这是我的控制器操作:

  def show
    @ticket = Ticket.find(params[:id])
    respond_to do |format|
      format.html { render :layout => false }
      format.pdf do
        render  :pdf => "HearingTrackerTicket",
                :layout => false,
                :dpi => '300'
      end
    end
  end

Here is pdf.css.scss

.pdf-body { 
  background-color: white;
  p {
    font-size: 12pt;
    line-height: 20.5pt;
    .underline {
      border-bottom: 1pt solid;
    }
  } 
  h1 {
    margin-top: 0;
    font-size: 24pt;
  }
  h3 {
    font-size: 14.25pt;
  }
  .code {
    position: absolute;
    top: 23pt;
    right: 20pt;
  }
  .header {
    border-bottom: 1pt solid;
  }
  .content {
    .line {
      height:30pt;
      border-bottom: 1pt solid;
      display:block;
    }
    ul {
      list-style-type: none;
      height:112pt;
      li {
        font-size: 12pt;
        display: block;
        float: left;
        height: 22.5pt;
        line-height: 17pt;
        list-style: none;
        margin-right: 20pt;
        width:100%;
        div {
          display: block;
          float: left;
          border:1pt solid;
          width: 15pt;
          height: 15pt;
          margin-right: 10pt;
        }
      }
    }
    ul.horizontal {
      height:30pt;
      li {
        width:auto;
      }
    }
    ul.horizontal-fixed {
      height:30pt;
      li {
        width:250pt;
      }
    }
  }
}

以下是 HTML 输出(与 PDF 的来源相同):

<!doctype html>
<html>
  <head>
    <meta charset='utf-8' />
      <style type='text/css'>.pdf-body{background-color:white}.pdf-body h1{margin-top:0;font-size:24pt}.pdf-body h3{font-size:14.25pt}.pdf-body .code{position:absolute;top:23pt;right:20pt}.pdf-body p{font-size:12pt;line-height:20.5pt}.pdf-body p .underline{border-bottom:1pt solid}.pdf-body .header{border-bottom:1pt solid}.pdf-body .content .line{height:30pt;border-bottom:1pt solid;display:block}.pdf-body .content ul{list-style-type:none;height:112pt}.pdf-body .content ul li{font-size:12pt;display:block;float:left;height:22.5pt;line-height:17pt;list-style:none;margin-right:20pt;width:100%}.pdf-body .content ul li div{display:block;float:left;border:1pt solid;width:15pt;height:15pt;margin-right:10pt}.pdf-body .content ul.horizontal{list-style-type:none;height:30pt}.pdf-body .content ul.horizontal li{display:block;float:left;list-style:none;margin-right:20pt;width:auto}.pdf-body .content ul.horizontal li div{display:block;float:left;border:1pt solid;margin-right:10pt}.pdf-body .content ul.horizontal-fixed{list-style-type:none;height:30pt}.pdf-body .content ul.horizontal-fixed li{display:block;float:left;list-style:none;margin-right:20pt;width:250pt}.pdf-body .content ul.horizontal-fixed li div{display:block;float:left;border:1pt solid;margin-right:10pt}
    </style>  
  </head>
  <body class="pdf-body">
    <div class="header">
      <h1>Hearing Tracker Survey</h1>
      <span class="code">Code: <strong>a9e78</strong></span>
      <p style="border-bottom:1px solid; padding-bottom:17px;">
        Thank you for taking the time to review your hearing aid(s) and hearing provider. Your responses will be made available to your hearing provider and to the public (anonymously). <strong>It is important that you answer these questions as honestly as possible.</strong> Your answers will help your provider to improve their practice and help provide valuable feedback to hearing aid manufacturers. For more information please visit <strong>hearingtracker.com</strong>
      </p>
      <p>
        <i>Please complete the included surveys and return to: </i>
      </p>
      <p>
      <strong>Hearing Tracker, Inc <br />
      PO Box 40702 <br />
      Austin, TX 78704</strong>
      </p>

    </div>
    <div class="content">
      <h3 class="section-header">
        Hearing Aid Outcome Survey
      </h3>
      <p style="margin-top:-10px;">
        <i>Place a check mark in <span class="underline">one box</span> per question.</i>
      </p>
      <div class="question">
        <p>
          1) How much does your hearing aid help you to hear speech in quiet environments?
        </p>
        <ul>
          <li><div></div>Vast improvement with the hearing aid(s)</li>
          <li><div></div>Good improvement with the hearing aid(s)</li>
          <li><div></div>Slight improvement with the hearing aid(s)</li>
          <li><div></div>No improvement with the hearing aid(s)</li>
          <li><div></div>I heard better without the hearing aid(s)</li>
        </ul>
      </div>
      <div class="question">
        <p>
          2) How much does your hearing aid help you to hear speech in noisy situations (restaurants, crowds, etc)?
        </p>
        <ul>
          <li><div></div>Vast improvement with the hearing aid(s)</li>
          <li><div></div>Good improvement with the hearing aid(s)</li>
          <li><div></div>Slight improvement with the hearing aid(s)</li>
          <li><div></div>No improvement with the hearing aid(s)</li>
          <li><div></div>I heard better without the hearing aid(s)</li>
        </ul>
      </div>
      <div class="question">
        <p>
          3) How much does your hearing aid help you to hear speech on the phone?
        </p>
        <ul>
          <li><div></div>Vast improvement with the hearing aid(s)</li>
          <li><div></div>Good improvement with the hearing aid(s)</li>
          <li><div></div>Slight improvement with the hearing aid(s)</li>
          <li><div></div>No improvement with the hearing aid(s)</li>
          <li><div></div>I heard better without the hearing aid(s)</li>
        </ul>
      </div>
      <div class="question">
        <p>
          4) How clear and natural does the hearing aid sound?
        </p>
        <ul>
          <li><div></div>Very clear and natural</li>
          <li><div></div>Somewhat clear and natural</li>
          <li><div></div>Clear or natural, but not both</li>
          <li><div></div>Neither clear nor natural</li>
          <li><div></div>The sound is unbearable</li>
        </ul>
      </div>
      <div class="question">
        <p>
          5) How much does your hearing aid improve your hearing for music?
        </p>
        <ul>
          <li><div></div>Vast improvement with the hearing aid(s)</li>
          <li><div></div>Good improvement with the hearing aid(s)</li>
          <li><div></div>Slight improvement with the hearing aid(s)</li>
          <li><div></div>No improvement with the hearing aid(s)</li>
          <li><div></div>I heard better without the hearing aid(s)</li>
        </ul>
      </div>
      <div class="question">
        <p>
          6) How comfortable is the hearing aid?
        </p>
        <ul>
          <li><div></div>I don't even notice the hearing aid in my ear</li>
          <li><div></div>I can feel the hearing aid in my ear, but it's very comfortable</li>
          <li><div></div>The hearing aid is slightly uncomfortable after a few hours</li>
          <li><div></div>The hearing aid is not comfortable, but I can tolerate it</li>
          <li><div></div>The hearing aid hurts my ear</li>
        </ul>
      </div>
      <div class="question">
        <p>
          7) How reliable is the hearing aid?
        </p>
        <ul>
          <li><div></div>I've had no problems, and expect none in the future</li>
          <li><div></div>I've had no problems, but anticipate there might be some in the future</li>
          <li><div></div>I've had some issues, but nothing I couldn't take care of myself</li>
          <li><div></div>I've had some issues with my hearing aid, but my provider has taken care of it in the clinic</li>
          <li><div></div>My hearing aid has been sent offsite for repair by my audiologist</li>
        </ul>
      </div>
      <div class="question">
        <p>
          8) Does the hearing aid do a good job of stopping unwanted feedback (buzzing and whistling)?
        </p>
        <ul>
          <li><div></div>I never hear feedback from my hearing aid</li>
          <li><div></div>My hearing aid creates feedback very rarely</li>
          <li><div></div>My hearing aid creates feedback occasionally</li>
          <li><div></div>My hearing aid creates feedback often</li>
          <li><div></div>My hearing aid creates feedback frequently</li>
        </ul>
      </div>
      <div class="question">
        <p>
          9) How much does the hearing aid improve your hearing?
        </p>
        <ul class="horizontal-fixed">
          <li><div></div>Vast improvement with the hearing aid(s)</li>
          <li><div></div>Good improvement with the hearing aid(s)</li>
          <li><div></div>Slight improvement with the hearing aid(s)</li>
          <li><div></div>No improvement with the hearing aid(s)</li>
          <li><div></div>The hearing aid hurts my ear</li>
        </ul>
      </div>
      <div class="question">
        <p style = "clear: both; padding-top: 20px;">
          10) How would you rate the value of your hearing aid?
        </p>
        <ul class="horizontal">
          <li><div></div>Excellent value</li>
          <li><div></div>Great value</li>
          <li><div></div>Good value</li>
          <li><div></div>Fair value</li>
          <li><div></div>Poor value</li>
        </ul>
      </div>
      <div class="written">
        <p>
          What would you tell others about your experience with your hearing aid(s)? Please DO NOT review your provider here.
        </p>
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
        <p>
          More to say? Please continue on the back of this page, or on a separate sheet of paper.
        </p>
      </div>
      <h3 class="section-header">
        Provider Survey
      </h3>
      <div class="question">
        <p>
          The location was easy to access, pleasant, and professional
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          I was seen in a reasonable amount of time
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          My provider listened to me
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          My provider was knowledgable
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          My provider adequately explained procedures and results
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          My provider solved or offered solutions for my hearing needs
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          I am satisfied with the overall experience
        </p>
        <ul>
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>
      <div class="question">
        <p>
          I would recommend my provider to a family member or friend
        </p>
        <ul class="horizontal">
          <li><div></div>Strongly Agree</li>
          <li><div></div>Agree</li>
          <li><div></div>Neutral</li>
          <li><div></div>Disagree</li>
          <li><div></div>Strongly Disagree</li>
        </ul>
      </div>


      <div class="written">
        <p>
          Please provide a short review of your hearing professional.
        </p>
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
        <p>
          More to say? Please continue on the back of this page, or on a separate sheet of paper.
        </p>
      </div>
    </div>
  </body>
</html>

wkhtmltopdf可以(并且将会)使用系统字体通过其无头 wekbkit 浏览器呈现内容。

所以你的问题实际上是开发和生产环境不同的问题。

如果您对服务器有一定的控制权,您可以尝试安装freetype and fontconfig包以在服务器上获取额外的字体,或者在样式表中将字体作为 OTF 文件提供,如下所示:

# in application.css.erb
@font-face {
  font-family: 'OpenSansRegular';
  src: url('<%= font_url('OpenSans.otf') %>');
  font-weight: normal;
  font-style: normal;
}

并告诉样式表使用它:

body {
  font-family: 'OpenSansRegular';
  font-size: 13px;
}

如果你没有OTF字体,这是转换它们的服务.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

wicked_pdf 生产中字体太大 的相关文章

随机推荐

  • R - 在 Shiny UI 层中对文件进行 source() 处理

    我正在尝试将我的 Shiny 应用程序分解成更小的文件 以便通过 git 与同事进行协作更加容易 这个问题帮助我弄清楚如何source 通过使用将文件添加到我的 server rsource local T 现在我正在尝试对我的 UI 层做
  • 为什么这个函数返回一个(拥有的)值?

    代码 从 Genie 如何将字符串作为字符串数组重复 N 次Genie 如何将字符串作为字符串数组重复 N 次 def repeatwithsep e string n int separator string string var ele
  • mpirun:无法识别的参数 mca

    我有一个 C 求解器 需要使用以下命令并行运行 nohup mpirun np 16 my exec gt log txt 该命令将运行my exec独立于我的节点上可用的 16 个处理器 这曾经非常有效 上周 HPC 部门执行了操作系统升
  • 使用 Bootstrap 3 定位多个设备

    我正在开发针对手机 平板电脑和台式机的网站 假设我有一个 div 元素 处理这些设备的好方法是什么 我应该有 3 个不同版本的代码 或者也许我只需将所有类包含在一个 div 中 如下所示 div class col xs 12 col sm
  • 在窗口加载时通过 URL 将值传递给 JS 函数

    my page http www dinomuhic com 2010 index php使用正文中的 onLoad 调用在页面开头加载 Showreel 如下所示 96 是 SQL 库中节目卷的 ID JS 函数 sndReq 是使用 J
  • 如何通过C程序打印扩展ASCII字符127到160?

    我正在尝试下面的代码来打印所有 ASCII 字符 但它不会打印 127 到 160 的任何内容 我知道它们是控制字符集或一些拉丁 西班牙语字符 如果从Windows复制粘贴相同的字符 则在unix中打印效果很好 为什么不通过 C 程序呢 i
  • Android Studio 卡在“Gradle:解析依赖项‘_debugCompile’”或“detachedConfiguration1”上

    我不知道我在项目中更改了什么 但在构建 gradle 脚本时突然无法通过这一步 仅使用 gradle assemble 构建它是没有问题的 编辑 之前的卡点是解决依赖项 detachedConfiguration1 在第一次尝试 debug
  • AES ECB iOS 加密

    我尝试使用 AES 算法和 ECB 选项来加密一些字符串 size t bufferSize dataLength kCCBlockSizeAES128 void buffer malloc bufferSize size t numByt
  • 无法使用连接字符串连接到本地 SQL Server DB,但 VS 可以

    我正在尝试使用连接字符串通过 Visual Studio 15 连接到本地 Sql Server 2012 数据库实例 虽然我已经能够通过 Visual Studio SQL Server 对象资源管理器连接到数据库并成功运行测试过程 但我
  • bash“如果[假];”返回 true 而不是 false —— 为什么?

    为什么会输出如下True bin sh if false then echo True else echo False fi 这将始终输出True即使情况似乎表明情况并非如此 如果我去掉括号 然后它起作用了 但我不明白为什么 您正在运行 a
  • 返回列表 1 和列表 2 中的项目匹配的列表

    假设我有 2List
  • 关于清单文件中的“singleton:= true”

    我有一个插件 目前没有任何扩展点 它也不扩展任何其他插件 为了解决某个问题 我必须为此插件创建一个扩展点 并在其他地方创建一个适当的扩展 当做这个日食时迫使我设置singleton true在清单文件中 我知道必须设置此参数的原因 但我想知
  • 检查字符串中所有字符是否相等的函数 javascript - 作业警告

    我找到了这个作业问题的解决方案 但我不认为这是解决问题的最有效方法 对我应该探索的其他解决方案感兴趣 问题 编写一个名为 allEqual 的函数 如果字符串中的每个字符都相同 则返回 true Example 如果你传递 aaa 它应该返
  • 重绘中的图形绘制随机线条

    因此 我正在创建一个手绘 JPanel 它对鼠标移动做出反应并绘制线条 我让它大部分工作 除了一个错误 它会在线条之间随机绘制一条直线 这条随机直线不是故意的 缓冲图像上绘制的内容应该严格是用户绘制的 这些随机绘制的线条不是由用户完成的 而
  • Saas:单实例、多实例、单租户、多租户?

    我一直在阅读有关实例和租户以及 Saas 架构的内容 我的问题如下 如果您发现我对以下任何术语有错误 请更正 1 实例 某个软件的实例是否只是该软件的副本及其自己的数据库 还有比这更重要的事情吗 2 Tenant 租户是对单个实例共享一组通
  • Golang 中的位掩码和按位运算

    一般来说 我是编程的初学者 所以如果我在提出这个问题时犯了一些错误 我很抱歉 我正在遵循的教程将详细介绍此代码 package main import fmt const isAdmin 1 lt lt iota isHeadquarter
  • 动画计数器从开始值到结束值

    我想在我的网站上放置一个柜台 以下代码适用于非常大的数字 但像 3 或 95 5 这样的小数字则不起作用 但它适用于超过 1000 的数字 您认为 JavaScript 代码编写的问题出在哪里 预先感谢您的指导 const counters
  • 模板专用函数

    我需要使用模板类对我的函数进行专门化 并且遇到 非法使用显式模板参数 的问题 template
  • MySQL 复合在 FK 上是独一无二的

    我想在mysql中实现以下约束 create table TypeMapping constraint unique server id type id constraint foreign key server id references
  • wicked_pdf 生产中字体太大

    我遇到一个问题 渲染的 PDF 的字体大小为产量较大 在开发中生成的 PDF 中 一切看起来都很棒 这是来自的渲染图发展 这是来自的渲染图生产 这使得我很难为开发中的生产服务器格式化我的文档 你能看一下吗 HTML 版本 http www