From tkpapp at gmail.com Sun Feb 12 11:04:26 2012 From: tkpapp at gmail.com (Tamas Papp) Date: Sun, 12 Feb 2012 12:04:26 +0100 Subject: [cl-pdf-devel] embedding PDF Message-ID: <20120212110426.GA25070@daedalus> Hi, Is it possible to embed another PDF file (ie render it contents at a particular coordinate) in a document generated by CL-PDF? Thanks, Tamas From ystok-systema at rambler.ru Sun Feb 12 15:36:01 2012 From: ystok-systema at rambler.ru (Dmitriy Ivanov) Date: Sun, 12 Feb 2012 19:36:01 +0400 Subject: [cl-pdf-devel] embedding PDF References: <20120212110426.GA25070@daedalus> Message-ID: <000001cce99c$0a1d8ae0$8100a8c0@digo> Tamas Papp wrote on Sun, 12 Feb 2012 12:04:26 +0100 15:04: | Is it possible to embed another PDF file (ie render it contents at a | particular coordinate) in a document generated by CL-PDF? You can embed any file as a binary object and specify the corresponding MIME type for it. I am not sure about the way a typical PDF viewer will render such an embedded PDF file. In all probability, the viewer will open it in another window. OTOH, you could parse the emended file and include its contents as you wanted. -- Sincerely, Dmitriy Ivanov lisp.ystok.ru From paul.tarvydas at rogers.com Sun Feb 12 16:35:31 2012 From: paul.tarvydas at rogers.com (Paul Tarvydas) Date: Sun, 12 Feb 2012 11:35:31 -0500 Subject: [cl-pdf-devel] embedding PDF In-Reply-To: <20120212110426.GA25070@daedalus> References: <20120212110426.GA25070@daedalus> Message-ID: <201202121135.31737.paul.tarvydas@rogers.com> > Hi, > > Is it possible to embed another PDF file (ie render it contents at a > particular coordinate) in a document generated by CL-PDF? I haven't played with this, but, looking at the cl-pdf source, I see a file name pdf-parser.lisp, containing intriguiing function names like read-pdf and insert-original-page-content. Read through and try out the #|'ed out test section at the bottom of the file. It helps to know a bit about the internal structure of a pdf document. There are also various command-line tools - google for "pdf merge", "pdf tools", "pdf parser", etc. pt From marc.battyani at fractalconcept.com Sun Feb 12 17:17:25 2012 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 12 Feb 2012 12:17:25 -0500 Subject: [cl-pdf-devel] embedding PDF In-Reply-To: <20120212110426.GA25070@daedalus> References: <20120212110426.GA25070@daedalus> Message-ID: <4F37F425.4050701@fractalconcept.com> On 2/12/2012 6:04 AM, Tamas Papp wrote: > Hi, > > Is it possible to embed another PDF file (ie render it contents at a > particular coordinate) in a document generated by CL-PDF? pdf-templates.lisp has code to print pages extracted from a pdf to some position/size on a new page. Here is the example from this file: ;;;## Example Usage ;;; Try something like this after loading pdf-template.lisp: ;;; ;;; (pdf:test-template "/tmp/ex7.pdf" 1 "/tmp/template.pdf") (defun test-template (in-file page-number out-file) "Create a new PDF with the given file and page number drawn several times. This test requires pdf-parser to be loaded." (let* ((old-doc (read-pdf-file in-file)) (old-root (root-page old-doc)) (old-page (aref (pages old-root) page-number)) (old-page-bounds (or (resolve-page-dict-value (content old-page) "/MediaBox") *default-template-size*)) (width (svref old-page-bounds 2)) (height (svref old-page-bounds 3))) (with-document () (with-page (:bounds old-page-bounds) (let ((top-template (make-template-from-page old-page :scale 2/5 :translate-x (* 3/10 width) :translate-y (* 3/5 height))) (right-template (make-template-from-page old-page :scale 2/5 :rotate 90 :translate-x (* 3/5 width) :translate-y (* 3/10 height))) (left-template (make-template-from-page old-page :scale 2/5 :rotate -90 :translate-y (* 3/10 height ))) (bottom-template (make-template-from-page old-page :scale 2/5 :rotate 180 :translate-x (* 3/10 width)))) (add-templates-to-page top-template right-template left-template bottom-template) (draw-template top-template) (draw-template bottom-template) (draw-template left-template) (draw-template right-template))) (write-document out-file)))) Marc