【发布时间】:2010-10-19 15:29:54
【问题描述】:
我正在尝试将cl-pdf 用于一些相当基本的 PDF 生成,但我被示例绊倒了(这至少可以说是令人尴尬的)。
当我运行包中包含的第一个示例时
(defun example1 (&optional (file #P"/tmp/ex1.pdf"))
(pdf:with-document ()
(pdf:with-page ()
(pdf:with-outline-level ("示例" (pdf:register-page-reference))
(让 ((helvetica (pdf:get-font "Helvetica")))
(pdf:文本模式
(pdf:set-font helvetica 36.0)
(pdf:移动文本 100 800)
(pdf:draw-text "cl-pdf: Example 1"))
(pdf:翻译 230 500)
(循环重复 150
对于 i = 0.67 那么 (* i 1.045)
做 (pdf:in-text-mode
(pdf:set-font helvetica i)
(pdf:set-rgb-fill (/ (随机 255) 255.0)
(/ (随机 255) 255.0)
(/ (随机 255) 255.0))
(pdf:移动文本 (* i 3) 0)
(pdf:show-text "cl-typesetting"))
(pdf:旋转 13)))))
(pdf:write-document 文件)))
通过运行 (example1 #P"/home/inaimathi/Desktop/ex1.pdf") 它给了我这个错误
#不是二进制输出流。 [SIMPLE-TYPE-ERROR 类型的条件] 重启: 0: [ABORT] 退出调试器,返回顶层。
当我拨打(example1) 或拨打电话时,也会发生同样的事情
(with-open-file
(测试文件#P“/home/inaimathi/Desktop/ex1.pdf”
:direction :output :if-does-not-exist :create)
(example1 测试文件))
最后,如果我尝试
(with-open-file
(测试文件#P“/home/inaimathi/Desktop/ex1.pdf”
:direction :output :if-does-not-exist :create
:element-type '(无符号字节 8))
(example1 测试文件))
我得到了错误
#不是字符输出流。 [SIMPLE-TYPE-ERROR 类型的条件] 重启: 0: [ABORT] 退出调试器,返回顶层。
有没有办法声明binary character stream?如何从cl-pdf 获得简单的输出?我直接从 debian 存储库(我认为是 1.0.29)中使用 SBCL,以防万一。
【问题讨论】:
-
我在看我的东西(使用 cl-typesetting,它调用 cl-pdf 的 write-document),它看起来不错。您是否可能遇到权限问题?
-
似乎不是权限错误;当我尝试写入与上述相同的文件时,对
with-open-file的常规调用仍然成功,并且我之前将目标目录设置为 777 只是为了检查它是否有帮助。你使用的是什么 CL 实现,你运行的是什么版本的 cl-pdf? (我从分形概念网站下载了“cl-pdf-current”压缩包,不确定它的最新程度) -
遗憾的是,Debian 存储库不是最新的(几乎没有 Linux 发行版的 CL 存储库,除了 Gentoo Lisp 覆盖)。我会建议获取当前的 SBCL。
-
从他们的项目页面(即 1.0.49)试用了最新的 SBCL 二进制文件,当我尝试定义和调用
example1时,它产生了同样的错误;this is not a binary stream。所以它不是(只是)SBCL 的版本。 -
我正在使用 SBCL,我的 cl-pdf 和 cl-typesetting 来自 svn,日期为 2009-08-07。
标签: lisp pdf-generation common-lisp outputstream