代码之家  ›  专栏  ›  技术社区  ›  Peter Miehle

使用Ruby打印报告和发票?

  •  4
  • Peter Miehle  · 技术社区  · 17 年前

    在Ruby中,这将如何实现?

    构建一个.odt并将其扔到OpenOffice或.tex并将其抛到LaTeX?

    或者有没有免费的库,可以为我做所有这些事情,所以我只需要提供相关部分,让Ruby做文本格式化的事情?

    编辑:

    更具体地说:我想在第一页的特定位置放一个公司标志(DIN-A4格式,但也可以是字母),以及每页的页脚和第一页的地址框。其余的都应该是自由浮动的文本块,左右合理,粗体字在文本中间。

    大约

    pdf.column.blocktext("Hello Mr. P\nwe have [b]good news[/b] for you. bla bla bla and so on. Please keep this text together (no page break)...");
    pdf.column.floatingblock("This is another block, that should be printed, and can be broken over more than one column...");
    

    如果文本到达页面底部,它应该在纸上以公司字体呈现文本,对齐并整齐地包裹到下一列/页面。

    仔细想想,这正是LaTeX的用途。

    3 回复  |  直到 8 年前
        1
  •  3
  •   Jim Puls    17 年前

    我建议你考虑PDF生成。在Rails中,使用Prawn库非常简单。

    还有一个 fresh new Railcast about that .

    Official web site .

        3
  •  1
  •   Sam Coles    17 年前

    Ruport library acts_as_reportable