[poppler] Write support

Leonard Rosenthol leonardr at pdfsages.com
Tue May 23 12:11:49 PDT 2006


At 02:35 PM 5/23/2006, P. Henrique Silva wrote:
>Yesterday I started a discussion with krh, tsdgeos on #poppler about
>how to add write support on poppler (on the PDF backend).

         Having written two different sets of code to add writing to 
Xpdf, let me add some comments...


>We have 2 modes of updating a PDF: 1) just update the relevant Object,
>update the xref section (with a 'delta' bytes offset) and flush the
>file.

         This won't work the way you think it will, for a variety of 
reasons.  Don't bother.


>2) use incremental update feature[1] of PDF, that just append
>Object's to the file and add a new xref and trailer section.

         That's certainly a great solution and one that many have 
taken along the way on their first "pdf modifier".   This method, 
however, will require you to track what objects are modified and 
which ones are not.


         HOWEVER, don't forget there is also a third method - 
rewriting the entire PDF based on the entire object collection at the 
time.   This is actually (IMO) the easiest to implement since you 
just start from scratch running the object list, building an Xref as you go.


         Two other things of note:

1) Most Xpdf objects do NOT keep their original Object around - so 
you may want to consider adding lots of stuff "under the hood" to 
make sure you can go between a Page and it's Object (for example).
2) You will also want/need to consider providing methods to ADD and 
DELETE Objects.  There is NO notion of this in Xpdf and will also 
take some thought on how best to do so.


Leonard

---------------------------------------------------------------------------
Leonard Rosenthol                            <mailto:leonardr at pdfsages.com>
Chief Technical Officer                      <http://www.pdfsages.com>
PDF Sages, Inc.                              215-938-7080 (voice)
                                              215-938-0880 (fax)



More information about the poppler mailing list