[cl-pdf-devel] Questions about porting php Cpdf code to cl-pdf

Aleksandar Bakic a_bakic at yahoo.com
Sat Jan 14 09:12:31 UTC 2006


> Very well. Just generate the PDF in memory and then use it to make your HTTP
> reply. It's
> more an UCW or Araneida question IMO.

In SBCL with Unicode, you might need to dump it into a file, then read back,
because of character/byte issues. This is what I use (I intentionally do not
use ".pdf" extension):

(defun doc-to-uniq-tmpfile (doc)
  (let ((pathname
         (loop
            for name = (random-string 10)
            for pathname = (merge-pathnames
                            (make-pathname :directory '(:absolute "tmp"))
                            (make-pathname :name name)) ; NOTE: do not set type
            while (probe-file pathname)
            finally (return pathname))))
    (pdf:write-document pathname doc)
    pathname))

(defun doc-to-pdf (doc) ; sb-unicode is a pain...
  (let ((pathname (doc-to-uniq-tmpfile doc)))
    (prog1
        (with-open-file (in pathname :element-type :default)
          (let ((bytes (make-array
                        (file-length in) :element-type '(unsigned-byte 8))))
            (read-sequence bytes in)
            bytes))
      (delete-file pathname))))

Alex

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the cl-pdf-devel mailing list