Piotr Chamera | 10 Jun 18:48 2011
Picon

Some problems with pdf-parser

Hi,
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)))

to

     (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) 
*indirect-objects*))
		    (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
Picon

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 
debugging):

(defun make-indirect-object (obj-number gen-number position)
   (let ((object (gethash (cons obj-number gen-number) *indirect-objects*)))
     (if object
     (progn
       (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
           (progn
         (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))
     (progn
       (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)


Gmane