[cl-pdf-devel] Concatenating PDF files

Tim Daly Jr. tim at tenkan.org
Mon Nov 14 22:07:55 UTC 2005


On Mon, 2005-11-14 at 21:08 +0100, Edi Weitz wrote:
...
> Nevertheless, at the moment I don't even know enough of CL-PDF to be
> able to concatenate the files without wading through the source code
> for a couple of hours.  So, if someone could provide me with some
> lines of example code to get me started I'd be /very/ thankful.

Something like this would be a start, I think:


    (require :cl-pdf)
    (require :cl-pdf-parser)
    (in-package :pdf)

    (defun concat-pdfs (out-file &rest in-files)
      (with-document ()
        (dolist (in-file in-files)
          (let* ((doc (read-pdf-file in-file))
                 (root (root-page doc)))
            (loop for page across (pages root) do
                  (with-page ()
                    (let ((template (make-template-from-page page)))
                      (add-templates-to-page template)
                      (draw-template template))))))
        (write-document out-file)))


> but I'd rather do it all in Lisp if possible.

Amen, brother Maynard!

--
-Tim






More information about the cl-pdf-devel mailing list