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 生产中字体太大 的相关文章

  • 程序“gem”可以在以下软件包中找到

    我正在 Virtual Box Ubuntu 13 10 上安装 Ruby on Rails 以下是步骤 ruby v gt 程序 ruby 可以在以下软件包中找到 尝试 sudo apt get install 来源 我的帐户 gt 好的
  • Rails:调用其他模型的无表模型

    我有一个 Rails 应用程序 其中包含一些模型类 例如Category Subcategory User ETC 为了实现一个不太简单的过滤器功能 我构建了一个过滤器类的层次结构 FilterCategory FilterSubcateg
  • 如何使用Factory Girl生成回形针附件?

    我有一个包含许多图像的模型 Person 其中图像有一个称为数据的回形针附件字段 下面显示了缩写版本 class Person has many images end class Image has attached file data b
  • 如何使用 Rails 应用程序中的 s3 在存储桶之间复制文件?

    我目前正在开发一个 Rails 应用程序 尝试将视频从 s3 中的一个存储桶复制 移动到另一个存储桶 但是我在 Rails 应用程序上不断收到代理错误 502 在杂种日志中 它显示 无法分配内存 一旦发生此错误 应用程序就会终止 我们必须重
  • 在 Rails 4 中渲染部分/rake 任务/后台作业/模型中的视图

    我读过很多关于在 rake 任务 后台作业 模型中渲染 Rails 部分和视图的内容 我在 Stackoverflow 和网络上找到的绝大多数内容都描述了在 Rails 3 中工作的方法 但它们似乎已经过时了 而且我没有让它们工作 即使花了
  • 如何使用 RSpec 检查 JSON 响应?

    我的控制器中有以下代码 format json render json gt flashcard gt flashcard lesson gt lesson success gt true 在我的 RSpec 控制器测试中 我想验证特定场景
  • Rails 中的并行方法

    我的 Rails Web 应用程序有数十种方法 从调用 API 到处理查询结果 这些方法具有以下结构 def method one batch query API process data end def method nth batch
  • UIDocumentInteractionController 显示空白 pdf

    我尝试使用 UIDocumentInteractionController PresentPreviewAnimated 方法在 iOS 设备上显示 pdf 但它一直显示空白文档 我认为这可能与字符编码有关 但我不确定 如果我使用 UIWe
  • Ruby on Rails 最酷的功能是什么,为什么选择它? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 在我问这个问题之前 我浏览了 SO 上 Ruby on Rails 的搜索结果 找不到太多 但以下 在此页面上找到 https stackove
  • 如何在rails中使用npm包?

    我正在尝试使用王牌编辑 https github com ajaxorg ace在我的 Ruby on Rails 应用程序中 大部分视图由 React 组件组成 我正在使用反应轨道宝石 https github com reactjs r
  • 如何使用 Ruby 2.7.0 修复 Rails 的警告消息

    有没有人解决这个问题Ruby 2 7 0 I used rbenv并安装了 Ruby v2 7 0 然后使用创建了一个 Rails 项目Rails v6 0 2 1 目前 通过运行之一 rails s rails s u puma rail
  • 从图像创建 PDF 时设置文档名称

    我使用以下代码从 jpg 图像创建 pdf im new Imagick im gt readImage image jpg im gt setImageFormat pdf im gt writeImage images pdf imag
  • Rails Searchkick / Elasticsearch has_many 和belongs_to 关联

    我尝试使用 Searchkick 运行搜索并基于多个模型返回 我的书本模型包含这个 class Book lt ActiveRecord Base searchkick has many book subjects has many sub
  • 使用 Minitest 测试自定义验证器

    我有多个带有电子邮件验证的模型 因此 我将验证提取到自定义验证器中 我按照以下教程做到了这一点导轨指南 http guides rubyonrails org active record validations html custom va
  • 在每页上插入折叠标记 (wkhtmltopdf)

    我正在使用 wkhtmltopdf 0 12 2 1 创建发票等 我需要在 pdf 的每一页上显示折叠标记 如果内容大于一页 如何在每个页面上使用 javascript 重复它们 这是我的基本标记 div class marks div c
  • 设备注册控制器获取零资源的自定义操作

    基本上我想要有两个单独的操作来更改密码和更改电子邮件 而不是只有一个 我已经更新了我的路由以指向继承自 Devise RegistrationsController 的新控制器 我的路线 rb devise for users contro
  • 在 Swift 中从 UIScrollView 创建 PDF 文件

    我想从 UIScrollView 的内容创建一个 PDF 文件 func createPdfFromView aView UIView saveToDocumentsWithFileName fileName String let pdfD
  • 在 Web 应用程序中显示最新的提交值?

    我有一些 Rails 应用程序 我使用 Git 作为版本控制系统 我使用 GitHub 或 Beanstalk 作为存储库主机 从理论上讲 我想要做的事情非常简单 以某种方式在 Web 应用程序的页脚中显示最新的提交 ID 号 哈希值 这样
  • Rails 4 的 mobile_fu

    我正在尝试将我的应用程序从 Rails 3 2 13 切换到 Rails 4 在此过程中 我遇到了一个主要障碍 我使用 gem mobile fu 来确定用户是否来自移动设备 该 gem 需要 Railties 3 2 13 但 Rails
  • 文本挖掘 pdf 文件/词频问题

    我正在尝试挖掘一篇具有丰富 pdf 编码和图表的文章的 pdf 我注意到 当我挖掘一些 pdf 文档时 我得到的高频词是 phi taeoe toe sigma gamma 等 它与某些 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