[cl-pdf-devel] Representation of basic PDF objects

Marc Battyani marc.battyani at fractalconcept.com
Mon Apr 26 14:31:34 UTC 2004


"Arthur Lemmens" <alemmens at xs4all.nl> wrote:

> I've started work on the PDF parser.

Good.

> My first idea was to use the following mapping from the basic PDF
> objects to Lisp objects:
>   - true -> :true
>   - false -> :false
>   - number -> number
>   - string -> string
>   - name -> symbol in the PDF package
>   - array -> vector
>   - dictionary -> property list
>   - stream -> pdf-stream
>   - null -> nil
>
> Mapping names to symbols, dictionaries to property lists
> and null to nil would make for a more elegant mapping than
> what CL-PDF seems to be using now, I think. CL-PDF seems to
> use Lisp strings for names, and :null for NIL.

Hum... I prefer the current mapping.
Names are case sensitive so symbols are not a good representation (except
for Franz modern mode fan ;-)
Also you have to generate names for fonts and other temporary pdf objects.
You would end up with lots of symbols! (and symbols are heavy weight objects
compared to string)
Alists are as nice as property lists IMO but they work with strings.
The true/false is not a real problem, IIRC there is only one place where a
true is used and none with false.

> Using :null instead of NIL means that you would have to
> insert some special checks when reading/changing dictionary
> values. (Because a :null value in a dictionary should be
> equivalent to having to omitting the key from the dictionary.
> This is exactly equivalent to having a NIL value in a Lisp
> property list.) These checks seem to be missing from CL-PDF
> at the moment.

It has probably never be needed so far. (There is no "null" in the cl-pdf
sources.)

> Also, using two separate Lisp types (strings and symbols) for
> two separate PDF types (strings and names) seems more elegant
> to me than using Lisp strings for both strings and names.
>
> Do you agree with this or am I missing something?

No! (I mean I don't agree ;-)

I think the best way is to use the current cl-pdf representation if you want
to be able to use it to write into the parsed pdf.

Marc





More information about the cl-pdf-devel mailing list