File: png-example.lisp

package info (click to toggle)
cl-pdf 117-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,860 kB
  • ctags: 844
  • sloc: lisp: 8,897; makefile: 39
file content (60 lines) | stat: -rw-r--r-- 2,823 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;;
;;; PNG imaging example
;;;

(defvar *test-png-pathname* (when *load-pathname*
                               (merge-pathnames #P"get_adobe_reader.png" *load-pathname*)))

(defun ex-png (&optional (file #P"/tmp/ex-png.pdf"))
  (pdf:with-document ()
    (let ((png-image (pdf::make-image *test-png-pathname*))
          (pal-opaq  (pdf::make-image(merge-pathnames "ys-pal-opaq" *test-png-pathname*)))
          (gray-opaq (pdf::make-image(merge-pathnames "ys-gray-opaq" *test-png-pathname*)))
          (mono-opaq (pdf::make-image(merge-pathnames "ys-mono-opaq" *test-png-pathname*)))
          (pal-tran  (pdf::make-image(merge-pathnames "ys-pal-tran" *test-png-pathname*)))
          (gray-tran (pdf::make-image(merge-pathnames "ys-gray-tran" *test-png-pathname*)))
          (mono-tran (pdf::make-image(merge-pathnames "ys-mono-tran" *test-png-pathname*)))
	  (helvetica (pdf:get-font "Helvetica")))
      (pdf:with-page ()
        (pdf:add-images-to-page png-image
                                pal-opaq gray-opaq mono-opaq
                                pal-tran gray-tran mono-tran)
        (pdf:with-outline-level ("Page 1" (pdf:register-page-reference))
          (pdf:with-saved-state 
            (pdf:set-rgb-fill 1 1 0)
            (pdf:basic-rect 20 580 450 100)
            (pdf:fill-path))
          (pdf:in-text-mode
            (pdf:set-font helvetica 36.0)
            (pdf:move-text 100 800)
            (pdf:draw-text "PNG Images Test")
   
            (pdf:set-font helvetica 12.0)
            (pdf:move-text -10 -30)
            (pdf:draw-text "Palette-256              Gray                     Mono       - OPAQUE")
            (pdf:move-text 30 -20)
            (pdf:set-text-leading 20)
            (pdf:show-text-on-next-line "ABCDIFGHIJKLMNOPQRSTUVWXYZ")
            (pdf:show-text-on-next-line "abcdifghijklmnopqrstuvwxyz")

            (pdf:move-text -30 -40)
            (pdf:draw-text "Palette-256              Gray                      Mono     - TRANSPARENT")
            (pdf:move-text 30 -20)
            (pdf:set-text-leading 20)
            (pdf:show-text-on-next-line "ABCDIFGHIJKLMNOPQRSTUVWXYZ")
            (pdf:show-text-on-next-line "abcdifghijklmnopqrstuvwxyz")
          )
          (pdf:draw-image pal-opaq   30 700 125 66 0 t)
          (pdf:draw-image gray-opaq 180 700 100 66 0 t)
          (pdf:draw-image mono-opaq 300 700  75 66 0 t)
          (pdf:add-URI-link 30 700 125 66 "http://www.ystok.ru")

          (pdf:draw-image pal-tran   30 600 125 66 0 t)
          (pdf:draw-image gray-tran 180 600 100 66 0 t)
          (pdf:draw-image mono-tran 300 600  75 66 0 t)
          (pdf:add-URI-link 30 600 125 66 "http://www.ystok.ru")

          (pdf:draw-image png-image 30 10 88 31 0 t))))
    (pdf:write-document file)))

;(ex-png (current-pathname "ex-png.pdf"))