Tamas Papp | 12 Feb 2012 12:04
Picon

embedding PDF

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

_______________________________________________
cl-pdf-devel site list
cl-pdf-devel@...
http://common-lisp.net/mailman/listinfo/cl-pdf-devel

Dmitriy Ivanov | 12 Feb 2012 16:36
Picon
Favicon

Re: embedding PDF

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

_______________________________________________
cl-pdf-devel site list
cl-pdf-devel@...
http://common-lisp.net/mailman/listinfo/cl-pdf-devel

Paul Tarvydas | 12 Feb 2012 17:35
Favicon

Re: embedding PDF

> 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

_______________________________________________
cl-pdf-devel site list
cl-pdf-devel@...
http://common-lisp.net/mailman/listinfo/cl-pdf-devel

Marc Battyani | 12 Feb 2012 18:17

Re: embedding PDF

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)))
(Continue reading)


Gmane