Piotr Chamera | 10 Jun 18:48 2011

Some problems with pdf-parser

I just started with cl-pdf and it works great for me :)
but I found some problems in pdf-parser and need advice
how to fix it. I am rather novice Lisper so I can be wrong
in my guesses below...

1. In file cl-pdf, function find-cross-reference-start

function searches for 'startxref' in buffer _from beginning_
and can find incorrect place if at end of file (in buffer)
are two such sections (eg small incremental change at end of file).

Proposition: change

     (let ((position (search "startxref" buffer)))


     (let ((position (search "startxref" buffer :from-end t)))

2. In file cl-pdf, function make-indirect-object:

(defun make-indirect-object (obj-number gen-number position)
   (let ((object (or (car (gethash (cons obj-number gen-number) 
		    (make-instance 'indirect-object
				   :obj-number obj-number
				   :gen-number gen-number
				   :content :unread
				   :no-link t))))
(Continue reading)

Piotr Chamera | 10 Jun 20:12 2011

Re: Some problems with pdf-parser

Some corrections to previous post

Ad 2. In file cl-pdf, function make-indirect-object

This code seems to work for me correcting unexpected behaviour
but I am not sure it is correct in every case (added some formats for 

(defun make-indirect-object (obj-number gen-number position)
   (let ((object (gethash (cons obj-number gen-number) *indirect-objects*)))
     (if object
       (format T "obj alredy present: ~s ~s at position ~s" obj-number 
gen-number(cdr object))
       (if (zerop (cdr object)) ; some objects are created and marked 
with invalid position = 0
         (format T " (marked for update with position=0), update 
position to ~s~%" position)
         (setf (gethash (cons obj-number gen-number) *indirect-objects*)
               (cons (car object) position)))
            (format T " (dropped older one at position ~s)~%" position))
         (car object))
       (format T "making obj: ~s ~s position ~s ~%" obj-number 
gen-number position)
       (let ((new-object (make-instance 'indirect-object
                        :obj-number obj-number
                        :gen-number gen-number
                        :content :unread
(Continue reading)