From: Zoltan B. <zb...@du...> - 2006-01-17 09:32:19
|
Hi, as I just noticed, both forward and backward and even circular references are allowed between objects in a PDF file. RPDF now was made in a way so certain objects get fixed object numbers. The attached patch alters this, so the object numbering becomes dynamic. This is needed later to allow font embedding, since embedded fonts are made up of more than one objects, so mechanically adding numbers of annotations, pages, fonts and images isn't correct anymore. The patch does the following: - struct rpdf_page_info, struct rpdf_font_object and struct rpdf_object gained a new member: gint object_number - rpdf_object_append() returns the object number it just added - Two new static functions introduced that are used to keep track of forward/circular references: gint rpdf_object_number_skip(struct rpdf *pdf); void rpdf_object_insert(struct rpdf *pdf, gint object_number, gboolean put_wrapper, GString *contents, gchar *stream, gint stream_length); - rpdf_finalize_objects() now uses the object_number field, instead of the pdf->object_count that was also incremented here. - rpdf_make_page_images() and rpdf_make_page_annot_list() aren't needed anymore, what they did are now done in rpdf_make_page_image_obj() and rpdf_make_page_annot_obj(), respectively. - rpdf_finalize() was rearranged/rewritten so it uses dynamic object numbering. - Warnings about unused local variables were silenced in obj_concat() and rpdf_make_page_stream(). Usage of the: rpdf_object_number_skip() and rpdf_object_insert(): 1. Assign object numbers at your will with rpdf_object_number_skip(). 2. Use these object numbers later in rpdf_object_insert() after some or every rpdf_object_append() occurences. Occurences of rpdf_object_insert() have to be in the same order as the occurences of rpdf_object_number_skip(), e.g.: obj1 =3D rpdf_object_number_skip(); obj2 =3D rpdf_object_number_skip(); obj3 =3D rpdf_object_number_skip(); // ... rpdf_object_append(); ... rpdf_object_insert(..., obj1, ...); rpdf_object_insert(..., obj2, ...); rpdf_object_insert(..., obj3, ...); The test program rlib/rpdf/test.c (URL link, image embedding, basic font usage) and some reports of mine I tested still work correctly. Please review. Best regards, Zolt=C3=A1n B=C3=B6sz=C3=B6rm=C3=A9nyi |