- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将网页呈现为 PDF。它使用单个图像,我读过您需要为 PDFkit 提供绝对 URL 才能使用该图像,所以我的代码是:
= image_tag image_url(user.avatar)
2013-12-04 13:53:36.576 wkhtmltopdf[27410:507] CoreText performance note: Client called CTFontCreateWithName() using name "Arial" and got font with PostScript name "ArialMT". For best performance, only use PostScript names when calling this API.
2013-12-04 13:53:36.577 wkhtmltopdf[27410:507] CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
2013-12-04 13:53:36.582 wkhtmltopdf[27410:507] CoreText performance note: Client called CTFontCreateWithName() using name "Arial" and got font with PostScript name "ArialMT". For best performance, only use PostScript names when calling this API.
2013-12-04 13:53:36.584 wkhtmltopdf[27410:507] CoreText performance note: Client called CTFontCreateWithName() using name "Arial" and got font with PostScript name "ArialMT". For best performance, only use PostScript names when calling this API.
^C
RuntimeError - command failed: /usr/local/bin/wkhtmltopdf --page-size Legal --print-media-type --quiet - -:
pdfkit (0.5.4) lib/pdfkit/pdfkit.rb:73:in `to_pdf'
pdfkit (0.5.4) lib/pdfkit/middleware.rb:21:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__4124003592524659480__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
better_errors (1.0.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:56:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.0) lib/thin/connection.rb:82:in `block in pre_process'
thin (1.6.0) lib/thin/connection.rb:80:in `catch'
thin (1.6.0) lib/thin/connection.rb:80:in `pre_process'
thin (1.6.0) lib/thin/connection.rb:55:in `process'
thin (1.6.0) lib/thin/connection.rb:41:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.0) lib/thin/backends/base.rb:73:in `start'
thin (1.6.0) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.0.0) lib/rails/commands/server.rb:84:in `start'
railties (4.0.0) lib/rails/commands.rb:78:in `block in <top (required)>'
railties (4.0.0) lib/rails/commands.rb:73:in `tap'
railties (4.0.0) lib/rails/commands.rb:73:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
最佳答案
这是一个臭名昭著的问题,您正在遇到它,因为您的 HTML 中可能有相对链接的 Assets (即图像、CSS、JS、字体等),并且您的 Web 服务器只能处理一个请求/线程一次(如 WEBrick
)。
那么会发生什么?当您请求其 URL 时,服务器开始生成 PDF。 PDFkit 找到链接的 Assets ,因此它尝试从服务器加载此 Assets ,该服务器恰好是运行 PDFkit 的同一台服务器。但是,服务器的单线程已经忙于运行 PDFkit,因此它无法“腾出”来为请求的 Assets 提供服务。总之,这是一个僵局——PDFkit 正在等待 PDFkit 完成处理的同一台服务器上的 Assets ,以便它可以将 Assets 提供给 PDFkit...
解决方案 : 要么 Base64-embed your assets in the HTML这样 PDFkit 就不需要发出任何额外的请求(我个人更喜欢的解决方案),或者暂时将 Assets 卸载到另一台服务器(例如临时 AWS 存储桶)。您也可以尝试使用 unicorn
或 Thin
启用多线程的网络服务器,或添加 config.threadsafe!
在 in application.rb
,但不能保证这些方法会起作用。
当然,这些黑客(嵌入 Assets 或托管在其他地方)应该只在开发环境中使用——你不应该在生产中遇到这些类型的问题,因为实时服务器应该(希望)能够处理多个 GET要求。
关于ruby-on-rails - PDFkit 在生成带有图像的 pdf 时挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20377401/
我创建了 iPhone 应用程序,在其中使用 fastpdfkit 显示 PDF 并播放音频和视频文件。 现在我也想为 Android 制作相同的应用程序。有没有适用于 Android 的套件可以让我
我安装了 pdfkit,甚至还安装了 wkhtmltopdf,但是每次我尝试创建 pdf 时都会收到以下错误。 PDFKit::NoExecutableError No wkhtmltopdf exe
我正在尝试使用 PDFKit。 它看起来相当简单,所以我试图关注 Ryan's Rails cast . 所以我将 gem 添加到我的 GemFile 并更新了我的 application.rb和:
我想知道是否有人知道如何在运行 pdfkit 时实现超时? 我正在尝试遍历大量 URL 以打印每个 URL 页面的 pdf。有时循环可能会挂起,但是如果它花费超过 30 秒,我只想跳过循环中的 URL
是否可以使用 PDFKit 在矩形上呈现文本。也许可以使用hack,用不透明度填充矩形 - 但我不想那样使用它。我的文本被矩形隐藏(我通过交替使用不同颜色的矩形创建表格)。 更新 我发现文本在某种程度
在我的应用程序中,我使用 PDFKit 来显示简单的 PDF。 PDF 显示在 ViewController 上。 PDF 要设置为屏幕宽度,仅此而已。我在 Storyboard 中将 PDFView
我有一个使用 PDFKIT 创建的 PDF View ,它在 iPad 中加载 PDF。当我们缩放 PDF 并进行一些手绘时,它会崩溃。可能是什么问题? 最佳答案 我有一个类似的问题,放大具有多个子类
我正在使用 PDFKit在浏览器中生成 PDF,然后将该 PDF 的 blob 数据发送到新选项卡以供用户下载。我真的很喜欢 PDFKit...它非常漂亮。 但是,当我尝试使用 PDFDocument
我正在尝试整合 PSPDFKit对于我的项目中的 iOS,我还没有成功。下载Demo版后,将框架添加到我的项目中,添加所有需要的库并放置 #import 在“前缀”文件上,我收到链接器错误: ld:
我一直在网上搜索使用 pdfkit(python 包装器)实现页眉和页脚的示例,但找不到任何示例。 谁能展示一些如何使用 pdfkit python 包装器在 wkhtmltopdf 中实现选项的示例
我想在 pdf 中找到一个特定的单词并在其上绘制一个边界框。为此,我使用 func findString(_ string: String, withOptions options: NSString
我正在使用 Apple 的 PDFKit,我正在使用他们的 sample app for adding a watermark到pdf文档。 除我拥有的一份 pdf 文件外,该代码按预期工作。这个特定
是否可以使用 PDFkit 将文本中的“ěščřžýáé”等字符保存为 PDF? 他们的浏览器演示在这里: http://pdfkit.org/demo/browser.html 注意:我只使用js库
如何使用 PDFKit 在 PDFView 中禁用滚动反弹? 显示 PDF 的 View 没有滚动反弹选项。 这是我的代码: if let path = Bundle.main.path(forRes
我正在尝试在 iOS 上使用 PDFKit 向文档添加高亮注释。 let highlight = PDFAnnotation(bounds: selection.bounds(for: page),
是否可以在 PDFKit 中更改 FreeText 注释的文本(即 contents)而不删除注释/构建新注释? 在 PDFView 中查看时,以下代码片段不会更改注释的内容: let url = B
使用python pdfkit生成pdf文件中遇到中文乱码问题 1.生成的文件名不能带有中文字符 2.生成的pdf内容中文为乱码 生成的文件名不能带有中文字符 解决方法: 我暂时想到的处理
如何从 pt/px 设置 characterSpacing? 如何从 pt/px 设置 lineHeight? 我只是不明白如何将点或像素转换为 pdfkit 的值。请帮帮我 https://gith
我试图了解如何让 PDF Kit 在 React JS 中工作。 我的简单要求是使用 ReactJS 和 PDFKit 在浏览器中呈现文件。 查看教程,引用了一些 PDFKit 可以在浏览器中工作的选
我想控制pdf文件的缩放级别。默认情况下,当它启动时,它不适合屏幕。即使手动(捏缩放)放大和缩小也不能使其适合页面。我已将 autoScales 设置为 true。 还尝试使用以下变量,但没有帮助
我是一名优秀的程序员,十分优秀!