diff options
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pdfdoc.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfdoc.c | 121 |
1 files changed, 23 insertions, 98 deletions
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c index 5826a006ee7..eca1fad797d 100644 --- a/Build/source/texk/dvipdfm-x/pdfdoc.c +++ b/Build/source/texk/dvipdfm-x/pdfdoc.c @@ -29,8 +29,6 @@ #include <config.h> #endif -#include <time.h> - #include "system.h" #include "mem.h" #include "error.h" @@ -418,72 +416,6 @@ pdf_doc_set_eop_content (const char *content, unsigned length) return; } -#ifndef HAVE_TM_GMTOFF -#ifndef HAVE_TIMEZONE - -/* auxiliary function to compute timezone offset on - systems that do not support the tm_gmtoff in struct tm, - or have a timezone variable. Such as i386-solaris. */ - -static int32_t -compute_timezone_offset() -{ - time_t now; - struct tm tm; - struct tm local; - time_t gmtoff; - - now = get_unique_time_if_given(); - if (now == INVALID_EPOCH_VALUE) { - now = time(NULL); - localtime_r(&now, &local); - gmtime_r(&now, &tm); - return (mktime(&local) - mktime(&tm)); - } else { - return(0); - } -} - -#endif /* HAVE_TIMEZONE */ -#endif /* HAVE_TM_GMTOFF */ - -/* - * Docinfo - */ -static int -asn_date (char *date_string) -{ - int32_t tz_offset; - time_t current_time; - struct tm *bd_time; - - current_time = get_unique_time_if_given(); - if (current_time == INVALID_EPOCH_VALUE) { - time(¤t_time); - bd_time = localtime(¤t_time); - -#ifdef HAVE_TM_GMTOFF - tz_offset = bd_time->tm_gmtoff; -#else -# ifdef HAVE_TIMEZONE - tz_offset = -timezone; -# else - tz_offset = compute_timezone_offset(); -# endif /* HAVE_TIMEZONE */ -#endif /* HAVE_TM_GMTOFF */ - } else { - bd_time = gmtime(¤t_time); - tz_offset = 0; - } - sprintf(date_string, "D:%04d%02d%02d%02d%02d%02d%c%02d'%02d'", - bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday, - bd_time->tm_hour, bd_time->tm_min, bd_time->tm_sec, - (tz_offset > 0) ? '+' : '-', abs(tz_offset) / 3600, - (abs(tz_offset) / 60) % 60); - - return strlen(date_string); -} - static void pdf_doc_init_docinfo (pdf_doc *p) { @@ -547,7 +479,7 @@ pdf_doc_close_docinfo (pdf_doc *p) if (!pdf_lookup_dict(docinfo, "CreationDate")) { char now[32]; - asn_date(now); + dpx_util_format_asn_date(now, 1); pdf_add_dict(docinfo, pdf_new_name ("CreationDate"), pdf_new_string(now, strlen(now))); @@ -2558,23 +2490,23 @@ pdf_doc_add_page_content (const char *buffer, unsigned length) return; } -static char *doccreator = NULL; /* Ugh */ - void -pdf_open_document (const char *filename, - int enable_encrypt, int enable_objstm, - double media_width, double media_height, - double annot_grow_amount, int bookmark_open_depth, - int check_gotos) +pdf_open_document (const char *filename, const char **ids, struct pdf_setting settings) { pdf_doc *p = &pdoc; - pdf_out_init(filename, enable_encrypt, enable_objstm); + pdf_enc_compute_id_string(ids[0], ids[1], ids[2]); + if (settings.enable_encrypt) + pdf_init_encryption(settings.encrypt); + + pdf_out_init(filename, settings.enable_encrypt, + settings.object.enable_objstm, settings.object.enable_predictor); + pdf_files_init(); pdf_doc_init_catalog(p); - p->opt.annot_grow = annot_grow_amount; - p->opt.outline_open_depth = bookmark_open_depth; + p->opt.annot_grow = settings.annot_grow_amount; + p->opt.outline_open_depth = settings.outline_open_depth; pdf_init_resources(); pdf_init_colors(); @@ -2583,21 +2515,20 @@ pdf_open_document (const char *filename, pdf_init_images(); pdf_doc_init_docinfo(p); - if (doccreator) { + if (ids[3]) { pdf_add_dict(p->info, pdf_new_name("Creator"), - pdf_new_string(doccreator, strlen(doccreator))); - RELEASE(doccreator); doccreator = NULL; + pdf_new_string(ids[3], strlen(ids[3]))); } - pdf_doc_init_bookmarks(p, bookmark_open_depth); + pdf_doc_init_bookmarks(p, settings.outline_open_depth); pdf_doc_init_articles (p); - pdf_doc_init_names (p, check_gotos); - pdf_doc_init_page_tree(p, media_width, media_height); + pdf_doc_init_names (p, settings.check_gotos); + pdf_doc_init_page_tree(p, settings.media_width, settings.media_height); pdf_doc_set_bgcolor(NULL); - if (enable_encrypt) { + if (settings.enable_encrypt) { pdf_obj *encrypt = pdf_encrypt_obj(); pdf_set_encrypt(encrypt); pdf_release_obj(encrypt); @@ -2618,27 +2549,20 @@ pdf_open_document (const char *filename, } p->pending_forms = NULL; - - return; -} -void -pdf_doc_set_creator (const char *creator) -{ - if (!creator || - creator[0] == '\0') - return; + pdf_init_device(settings.device.dvi2pts, settings.device.precision, + settings.device.ignore_colors); - doccreator = NEW(strlen(creator)+1, char); - strcpy(doccreator, creator); /* Ugh */ + return; } - void pdf_close_document (void) { pdf_doc *p = &pdoc; + pdf_close_device(); + /* * Following things were kept around so user can add dictionary items. */ @@ -2656,6 +2580,7 @@ pdf_close_document (void) pdf_close_resources(); /* Should be at last. */ + pdf_files_close(); pdf_out_flush(); if (thumb_basename) |