【问题标题】:OOWrite is to LaTeX as OODraw is to?OOWrite 之于 LaTeX 就像 OODraw 之于?
【发布时间】:2010-05-17 14:46:10
【问题描述】:

我正在寻找一种能够很好地生成单页 PDF 的工具。我的需求是:

  • 能够将 PDF/EPS/... 作为背景
  • 绝对定位
  • 能够定义表格、列表
  • 能够旋转方块
  • 相当简单的语法(将用于自动生成许多外观相似的文档)
  • 可通过 Python 轻松使用
  • 免费或非常便宜

本质上,我正在寻找适合 OODraw/CorelDraw/... 的工具 X,就像 LaTeX 适合 OOWrite/MS Word 一样。

我查看了 webkit2pdf 和无头 OODraw,但两者似乎都有些过头了。 XML-FO 有一些限制,例如无法预测您的文档跨越多少页。 Reportlab 很贵。

有什么想法吗?

谢谢!

【问题讨论】:

    标签: python pdf latex


    【解决方案1】:

    绝对是PGF/TikZ。卖点:

    由此代码创建:

    % Rooty helix
    % Author: Felix Lindemann
    \documentclass{minimal}
    
    \usepackage{tikz}
    \usetikzlibrary{calc}
    \begin{document}
    
    \pagestyle{empty}
    \pgfdeclarelayer{background}
    \pgfdeclarelayer{foreground}
    \pgfsetlayers{background,main,foreground}
    
    \xdefinecolor{darkgreen}{RGB}{175, 193, 36}
    \newcounter{cntShader}
    \newcounter{cntRoot}
    \setcounter{cntShader}{20}
    \def\couleur{darkgreen}
    
    \begin{tikzpicture}
        \foreach \y in {86,38,15}{
            \setcounter{cntShader}{1}
            \coordinate (a) at (0,0);
            \coordinate (b) at (0:1);
            \foreach \x in {1,...,\y}{%
                \coordinate (c) at ($ (b)!1cm!270:(a) $);
                \begin{pgfonlayer}{background}
                    \draw[fill=\couleur!\thecntShader] (a)--(b)--(c)--cycle;
                \end{pgfonlayer}
                \setcounter{cntRoot}{\x}
                \addtocounter{cntRoot}{1}
                \node[fill=white,draw,circle,inner sep=1pt] at (c)
                    {$\sqrt{\thecntRoot}$};
                \coordinate (b) at (c);
                \pgfmathsetcounter{cntShader}{\thecntShader+4}
                \setcounter{cntShader}{\thecntShader}
           }
        }
        \node[fill=white,draw,circle,inner sep=1pt] at (0:1) {$\sqrt{1}$};
    \end{tikzpicture}
    
    \end{document} 
    

    公然从examples盗取。

    【讨论】:

    • 你甚至可以确定这仍然是 LaTeX!
    【解决方案2】:

    TikZ 的替代方法是使用带有 Context 的 Metapost:这是一种比 TikZ 的基础语言 PGF 更具表现力的语言,在基于 Tex 的处理语言 Context 中,它比任何一种都更适合 PDF 中的页面布局乳胶或纯 Tex。

    支持 Context/Metapost 的三点:

    1. Metapost 相对于 PGF 的主要表达优势在于它是一种可以确定曲线交点的约束求解语言。这允许人们为树布局指定递归算法,例如,尽可能紧密地打包树而不会重叠,这是 PGF 中无法做到的。见The Metapost user manual第9节;
    2. Context 的图层允许将 PDF 图像插入到文本或其他 PDF 图像后面相当容易。见the entry on Layers at the Context wiki
    3. 上下文允许根据网格指定页面布局,这对于 Latex 来说确实令人不快。请参阅Context: the manual 的第 3.4 节。

    另外三个支持 Latex/TikZ:

    1. 它们有更好的文档记录和更广泛的使用。
    2. TikZ 有一个可爱的示例图形库。
    3. TikZ 适用于所有主要的 Tex 实现,而 Context 与 Luatex 相关联。

    了解如何将 Context 与 Metapost 结合使用的最佳起点是 Hans Hagen 的两本(很长!)介绍性指南:Context: an excursionMetafun(Metafun 是 Metapost 的一个实现,带有一些扩展)。

    【讨论】:

      【解决方案3】:

      ReportLab 可能是一个不错的解决方案:

      ReportLab 工具包是久经考验的超强大开源引擎,用于以编程方式创建 PDF 文档并构成 RML 的基础;它还包含一个用于创建与平台无关的矢量图形的库。这是一个用 Python 编写的快速、灵活、跨平台的解决方案。

      http://www.reportlab.com/software/opensource/

      【讨论】:

        猜你喜欢
        • 2012-12-22
        • 1970-01-01
        • 1970-01-01
        • 2010-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-30
        • 1970-01-01
        相关资源
        最近更新 更多