diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-26 13:32:36 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-26 13:32:36 +0000 |
commit | 37211633cf44cc8fead75933e9f594a030998a33 (patch) | |
tree | 3082ca325ef9ece62651751197bfcb1b355844b8 | |
parent | 79cadb339e01176133279790a0df08a06f757235 (diff) | |
download | mupdf-37211633cf44cc8fead75933e9f594a030998a33.tar.xz |
Add function to update an object in the xref (for pdfclean).
-rw-r--r-- | mupdf/mupdf.h | 1 | ||||
-rw-r--r-- | mupdf/pdf_xref.c | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/mupdf/mupdf.h b/mupdf/mupdf.h index 3c247bc0..abd9c9ec 100644 --- a/mupdf/mupdf.h +++ b/mupdf/mupdf.h @@ -150,6 +150,7 @@ struct pdf_xrefentry_s fz_error pdf_cacheobject(pdf_xref *, int num, int gen); fz_error pdf_loadobject(fz_obj **objp, pdf_xref *, int num, int gen); +void pdf_updateobject( pdf_xref *xref, int num, int gen, fz_obj *newobj); int pdf_isstream(pdf_xref *xref, int num, int gen); fz_filter * pdf_buildinlinefilter(pdf_xref *xref, fz_obj *stmobj, int length); diff --git a/mupdf/pdf_xref.c b/mupdf/pdf_xref.c index eba185e3..9dec068c 100644 --- a/mupdf/pdf_xref.c +++ b/mupdf/pdf_xref.c @@ -946,6 +946,28 @@ pdf_loadobject(fz_obj **objp, pdf_xref *xref, int num, int gen) return fz_okay; } +/* Replace numbered object -- for use by pdfclean and similar tools */ +void +pdf_updateobject(pdf_xref *xref, int num, int gen, fz_obj *newobj) +{ + pdf_xrefentry *x; + + if (num < 0 || num >= xref->len) + { + fz_warn("object out of range (%d %d R); xref size %d", num, gen, xref->len); + return; + } + + x = &xref->table[num]; + + if (x->obj) + fz_dropobj(x->obj); + + x->obj = fz_keepobj(newobj); + x->type = 'n'; + x->ofs = 0; +} + /* * Convenience function to open a file then call pdf_openxrefwithstream. */ |