- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试使用 Prawn 0.12.0 生成 pdf。
我呈现的内容非常动态,通常跨越多个页面。
我遇到的问题是,当它自动开始一个新页面时,当前的边界框会“中断”。在新页面上呈现的文本没有正确的边界框。如果我使用 stroke_bounds
,我可以在页面的最底部看到底部笔划。我在各种论坛上读到过这个问题,但似乎无法弄清楚到底发生了什么。
下面是循环出内容的具体代码:
items.each do |item|
group do
title_text = [{ text: item.title, styles: [@heading_style], size: 11}]
formatted_text title_text
text(item.description, size: 9)
stroke { line(bounds.bottom_left, bounds.bottom_right); }
end
end
如您所见,我想在每个项目下方画一条线,这就是为什么我需要当前边界框是正确的。
最佳答案
根据 Prawn 文档: http://prawnpdf.org/manual.pdf
边界框绑定(bind)到页边距:
A bounding box is a structure which provides boundaries for inserting content. A bounding box
also has the property of relocating the origin to its relative bottom-left corner. However, be aware
that the location specified when creating a bounding box is its top-left corner, not bottom-left
(hence the [100, 300] coordinates below).
跨度是一种更好的选择,可以优雅地跨页面流动的边界类型:
Span is a different kind of bounding box as it lets the text flow
gracefully onto the next page. It doesn't matter if the text started
on the middle of the previous page, when it flows to the next page
it will start at the beginning.
跨度应该能够包含所需的线条笔划。希望这可以帮助。
关于ruby - Prawn pdf和分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11194314/
我一直在 Prawn 中为 Ruby 随机尝试字体。 例如: Times New Roman - 是的 Palatino Linotype - 没有 是否有可用字体和不可用字体的列表? 最佳答案 代码
我正在尝试为单行设置 prawn 中笔划线的宽度。我想做的是...... pdf.stroke_horizontal_line(0, bounds.width, :at => row*spacin
我正在使用Rails 4 + prawn_rails +最新版本的prawn(v 1.1.0),并在以下更改日志中注意到:https://github.com/prawnpdf/prawn/wiki/
对不起我的英语不好。 我正在尝试在我的应用程序上使用 prawn 和 prawnto。我有一个 pdf 文件用作模板,该 pdf 文件只有一个页面,而该页面只有一个页眉和一个页脚,然后,我的 Cont
我在 rails 3.0 应用程序中使用 Prawn Gem 0.12.0。 我的文档显示正常: class TemplatePdf filename) text_box "2005
我采用了 Railscast episode 153 revised 的方法。 我的 Controller 是 class AdminsController "https://github.com/
我正在关注这个 railscasts #153,我正在尝试将表数据添加到 prawn。我不断收到此错误: Prawn::Errors::UnrecognizedTableContent 最佳答案 注意
我正在使用 ruby、prawn 和 prawnto 动态生成包含其他语言文本的 pdf。我似乎无法显示任何带有非英语字符的语言的文本。它不会抛出任何错误...只是显示一堆破折号而不是字符。 Pr
我正在尝试使用 Prawn 生成 pdf @buyer = Buyer.last Prawn::Document.generate("samle.pdf") do text "hello #{@b
我正在尝试在 prawn 类中使用 rails 3.2 助手,但 rails 抛出: undefined method `number_with_precision' for # Prawn 类 cl
我使用 Prawn 创建 pdf 文件,我想将 Logo 放入文件中。我看过这个网站 Creating pdf引用如何添加图像。 这是我在 ExamResultPdf.rb 中的代码生成pdf的文件:
我有一个 4 页的 PDF 模板,我想用 prawn 生成.我需要在我的 pdf 中多次重复这个模板,每次用不同的内容填充它。 如果我使用: Prawn::Document.generate('o
我正在尝试使用 Prawn 从包含大量图像的目录生成 PDF。到目前为止,我的代码运行良好,只有一个小问题,它会在 PDF 的开头插入一个空白页。 因为我不一定知道图像的大小(除了它们大致相同,任一维
我最近开始在我的应用程序中使用 Prawn 来生成 PDF,我还使用 Nori 来解析 XML 和发送 SMS。 我意识到我的应用无法再发送短信,我收到了这条错误消息: nori: undefine
目标是:创建具有标题横幅和重复标题表的 PDF 问题是:如果表格开始新页面,pdf.move_down 不起作用 CODE: # repeat drawing in every page pdf.re
我似乎无法将元数据设置为基于模板生成的 pdf。这是不允许的还是我做错了什么。 这是代码 pdf = Prawn::Document.new(:template => "sample.pdf",
我正在尝试这个简单的脚本: require 'prawn' template_file_name = File.join(File.dirname(__FILE__), 'template.pdf')
我的客户说生成的 PDF 必须是 CMYK 格式。 Prawn 能做到吗? 我在文档中找不到答案。 最佳答案 是的,Prawn 可以做到这一点。这个主题似乎被文档省略了,所以你可以看看源代码。 Thi
我有一张图片image.jpg,我想将它放在每页左下角的页脚中。我目前正在这样做,使用 Ruby 1.9.3 和 prawn gem 来创建 PDF,如下所示: start_new_page imag
我正在使用 Prawn 在 Rails 3 应用程序中生成 PDF。 是否可以像在 HTML View 中一样将 Unicode 字符串打印到 PDF 中? 例如, 在 show.html.erb
我是一名优秀的程序员,十分优秀!