[poppler] [RFC] PDF Modification in poppler

Julien Rebetez julien at fhtagn.net
Thu Aug 17 17:40:34 PDT 2006


Hello,
The goal of the attached patch is to provide a way to dynamically update
some parts of a PDF and save the updated file. It is usefull for things
like Form and Annotations.

It basically does two things:
- It adds an XRef::setModifiedObject(Object* o, Ref r) function, which
allow the client to 'redirect' XRef::fetch to the specified reference to
the specified Object. 
When you set an Object as 'modified' through this function, the next
call to XRef::fetch with the corresponding ref as parameter will return
your Object instead of re-reading it from the Stream.

- It adds two functions to PDFDoc : saveCompleteRewrite and
saveIncrementalUpdate. These functions allow the client to save the
modification he does (through setModifiedObject) either by rewriting the
whole document or using incremental update (this may be required for
digitally signed document for example).

There are a bunch of other internal functions added, mostly in PDFDoc,
but I think they are pretty self-explanatory.

One things that isn't implemented at the moment is the update of direct
Objects. For example, the Annotation may be direct Objects (directly
contained in the Page dict "Annots" entry). If the client updates a
direct Annotation, the whole first 'indirect-parent' Object (probably
the Page dict in our example) must be updated through setModifiedObject.
This is, at least, the only solution I see for direct Objects update,
but perhaps other people have other ideas.

I tested the saveCompleteRewrite function against some random PDF files
I have and it worked (all the rewrited files open without warnings in
both Evince and Acrobat 7.0), but I guess it has some bugs, leave me a
mail if you find one.


I think that's all, I write this email in the hope I'll get comments
(good or bad), so feel free to answer :-)

Thanks,
Julien


-------------- next part --------------
A non-text attachment was scrubbed...
Name: poppler_write_08172006_7.diff
Type: text/x-patch
Size: 26131 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/poppler/attachments/20060818/cb538937/poppler_write_08172006_7.bin


More information about the poppler mailing list