Skip to content

Commit

Permalink
Add indirect object helper method.
Browse files Browse the repository at this point in the history
Also make use of it.
  • Loading branch information
sebras committed Sep 19, 2024
1 parent e96addc commit a29a12b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/mupdf/pdf/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void pdf_dict_put_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key, double x);
void pdf_dict_put_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
void pdf_dict_put_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x, size_t n);
void pdf_dict_put_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
void pdf_dict_put_indirect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int num);
void pdf_dict_put_point(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_point x);
void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_rect x);
void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_matrix x);
Expand Down
5 changes: 5 additions & 0 deletions source/pdf/pdf-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -3828,6 +3828,11 @@ void pdf_dict_put_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, cons
pdf_dict_put_drop(ctx, dict, key, pdf_new_text_string(ctx, x));
}

void pdf_dict_put_indirect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int num)
{
pdf_dict_put_drop(ctx, dict, key, pdf_new_indirect(ctx, pdf_get_bound_document(ctx, dict), num, 0));
}

void pdf_dict_put_point(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_point x)
{
pdf_dict_put_drop(ctx, dict, key, pdf_new_point(ctx, pdf_get_bound_document(ctx, dict), x));
Expand Down
4 changes: 2 additions & 2 deletions source/pdf/pdf-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
/* If the encryption dictionary used to be an indirect reference from the trailer,
store it the same way in the trailer in the saved file. */
if (pdf_is_indirect(ctx, opts->crypt_obj))
pdf_dict_put_drop(ctx, trailer, PDF_NAME(Encrypt), pdf_new_indirect(ctx, doc, opts->crypt_object_number, 0));
pdf_dict_put_indirect(ctx, trailer, PDF_NAME(Encrypt), opts->crypt_object_number);
else
pdf_dict_put(ctx, trailer, PDF_NAME(Encrypt), opts->crypt_obj);
}
Expand Down Expand Up @@ -2398,7 +2398,7 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_state
/* If the encryption dictionary used to be an indirect reference from the trailer,
store it the same way in the xref stream in the saved file. */
if (pdf_is_indirect(ctx, opts->crypt_obj))
pdf_dict_put_drop(ctx, dict, PDF_NAME(Encrypt), pdf_new_indirect(ctx, doc, opts->crypt_object_number, 0));
pdf_dict_put_indirect(ctx, dict, PDF_NAME(Encrypt), opts->crypt_object_number);
else
pdf_dict_put(ctx, dict, PDF_NAME(Encrypt), opts->crypt_obj);
}
Expand Down

0 comments on commit a29a12b

Please sign in to comment.