summaryrefslogtreecommitdiff
path: root/pdf/pdf_object.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-05-14 19:34:35 +0100
committerRobin Watts <robin.watts@artifex.com>2012-05-31 13:26:00 +0100
commit65b8ae915465849babc1fa712971c701136f4ed5 (patch)
tree9724b5951eb266f7192c647d4fb26a127cd901fd /pdf/pdf_object.c
parent97716e53a6fa6947a183ed88df54702f96ba97b5 (diff)
downloadmupdf-65b8ae915465849babc1fa712971c701136f4ed5.tar.xz
Add linearization to pdf_write function.
Extend mupdfclean to have a new -l file that writes the file linearized. This should still be considered experimental When writing a pdf file, analyse object use, flatten resource use, reorder the objects, generate a hintstream and output with linearisaton parameters. This is enough for Acrobat to accept the file as being optimised for Fast Web View. We ought to add more tables to the hintstream in some cases, but I doubt anyone actually uses it, the spec is so badly written. Certainly acrobat accepts the file as being optimised for 'Fast Web View'. Update fz_dict_put to allow for us adding a reference to the dictionary that is the sole owner of that reference already (i.e. don't drop then keep something that has a reference count of just 1). Update pdf_load_image_stream to use the stm_buf from the xref if there is one. Update pdf_close_document to discard any stm_bufs it may be holding. Update fz_dict_put to be pdf_dict_put - this was missed in a renaming ages ago and has been inconsistent since.
Diffstat (limited to 'pdf/pdf_object.c')
-rw-r--r--pdf/pdf_object.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c
index 2a5e6d78..cc5cc662 100644
--- a/pdf/pdf_object.c
+++ b/pdf/pdf_object.c
@@ -267,6 +267,13 @@ int pdf_to_str_len(pdf_obj *obj)
return obj->u.s.len;
}
+void pdf_set_int(pdf_obj *obj, int i)
+{
+ if (!obj || obj->kind != PDF_INT)
+ return;
+ obj->u.i = i;
+}
+
/* for use by pdf_crypt_obj_imp to decrypt AES string in place */
void pdf_set_str_len(pdf_obj *obj, int newlen)
{
@@ -634,7 +641,7 @@ pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
n = pdf_dict_len(obj);
dict = pdf_new_dict(ctx, n);
for (i = 0; i < n; i++)
- fz_dict_put(dict, pdf_dict_get_key(obj, i), pdf_dict_get_val(obj, i));
+ pdf_dict_put(dict, pdf_dict_get_key(obj, i), pdf_dict_get_val(obj, i));
return dict;
}
@@ -754,7 +761,7 @@ pdf_dict_getsa(pdf_obj *obj, char *key, char *abbrev)
}
void
-fz_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
+pdf_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
{
int location;
char *s;
@@ -790,8 +797,11 @@ fz_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
i = pdf_dict_finds(obj, s, &location);
if (i >= 0 && i < obj->u.d.len)
{
- pdf_drop_obj(obj->u.d.items[i].v);
- obj->u.d.items[i].v = pdf_keep_obj(val);
+ if (obj->u.d.items[i].v != val)
+ {
+ pdf_drop_obj(obj->u.d.items[i].v);
+ obj->u.d.items[i].v = pdf_keep_obj(val);
+ }
}
else
{
@@ -814,7 +824,7 @@ void
pdf_dict_puts(pdf_obj *obj, char *key, pdf_obj *val)
{
pdf_obj *keyobj = fz_new_name(obj->ctx, key);
- fz_dict_put(obj, keyobj, val);
+ pdf_dict_put(obj, keyobj, val);
pdf_drop_obj(keyobj);
}