From d04a7cc7246cba3682a112f975afe4a5748a3ef5 Mon Sep 17 00:00:00 2001 From: scuri Date: Tue, 20 Oct 2009 18:14:16 +0000 Subject: *** empty log message *** --- src/cd_pdflib.mak | 7 +- src/pdflib/pdflib/p_3d.c | 2 +- src/pdflib/pdflib/p_actions.c | 150 +++++++++---- src/pdflib/pdflib/p_afm.c | 4 +- src/pdflib/pdflib/p_annots.c | 472 ++++++++++++++++++++++++++++++++++++----- src/pdflib/pdflib/p_block.c | 4 +- src/pdflib/pdflib/p_bmp.c | 4 +- src/pdflib/pdflib/p_ccitt.c | 2 +- src/pdflib/pdflib/p_cid.c | 2 +- src/pdflib/pdflib/p_color.c | 131 ++++++++---- src/pdflib/pdflib/p_color.h | 2 +- src/pdflib/pdflib/p_defopt.h | 36 ++-- src/pdflib/pdflib/p_document.c | 311 ++++++++++++++++++++------- src/pdflib/pdflib/p_draw.c | 2 +- src/pdflib/pdflib/p_encoding.c | 16 +- src/pdflib/pdflib/p_fields.c | 2 +- src/pdflib/pdflib/p_filter.c | 2 +- src/pdflib/pdflib/p_font.c | 200 ++++++++++++----- src/pdflib/pdflib/p_font.h | 13 +- src/pdflib/pdflib/p_generr.h | 67 +++++- src/pdflib/pdflib/p_gif.c | 7 +- src/pdflib/pdflib/p_gstate.c | 43 ++-- src/pdflib/pdflib/p_hkscmyk.h | 2 +- src/pdflib/pdflib/p_hkslab.h | 2 +- src/pdflib/pdflib/p_hyper.c | 62 ++++-- src/pdflib/pdflib/p_icc.c | 2 +- src/pdflib/pdflib/p_icc.h | 2 +- src/pdflib/pdflib/p_icc9809.h | 2 +- src/pdflib/pdflib/p_icclib.c | 10 +- src/pdflib/pdflib/p_icclib.h | 9 +- src/pdflib/pdflib/p_image.c | 109 +++++++--- src/pdflib/pdflib/p_image.h | 10 +- src/pdflib/pdflib/p_intern.h | 52 +++-- src/pdflib/pdflib/p_jpeg.c | 5 +- src/pdflib/pdflib/p_jpx.c | 2 +- src/pdflib/pdflib/p_kerning.c | 2 +- src/pdflib/pdflib/p_keyconn.h | 60 ++++-- src/pdflib/pdflib/p_layer.c | 4 +- src/pdflib/pdflib/p_layer.h | 2 +- src/pdflib/pdflib/p_mbox.c | 76 ++++--- src/pdflib/pdflib/p_object.c | 27 +-- src/pdflib/pdflib/p_opi.c | 2 +- src/pdflib/pdflib/p_page.c | 149 ++++++------- src/pdflib/pdflib/p_page.h | 2 +- src/pdflib/pdflib/p_pantlab.h | 2 +- src/pdflib/pdflib/p_params.c | 66 ++++-- src/pdflib/pdflib/p_params.h | 422 ++++++++++++++++++------------------ src/pdflib/pdflib/p_pattern.c | 8 +- src/pdflib/pdflib/p_pdi.c | 3 +- src/pdflib/pdflib/p_pfm.c | 44 ++-- src/pdflib/pdflib/p_photoshp.c | 2 +- src/pdflib/pdflib/p_png.c | 426 ++++++++----------------------------- src/pdflib/pdflib/p_shading.c | 12 +- src/pdflib/pdflib/p_subsett.c | 2 +- src/pdflib/pdflib/p_table.c | 2 +- src/pdflib/pdflib/p_tagged.c | 4 +- src/pdflib/pdflib/p_tagged.h | 2 +- src/pdflib/pdflib/p_template.c | 23 +- src/pdflib/pdflib/p_text.c | 421 +++++++++++++++++++++++------------- src/pdflib/pdflib/p_textflow.c | 2 +- src/pdflib/pdflib/p_tiff.c | 128 +++++++---- src/pdflib/pdflib/p_truetype.c | 9 +- src/pdflib/pdflib/p_type1.c | 126 ++++++----- src/pdflib/pdflib/p_type3.c | 15 +- src/pdflib/pdflib/p_util.c | 253 ++++++++++++++++++---- src/pdflib/pdflib/p_xgstate.c | 16 +- src/pdflib/pdflib/p_xmp.c | 7 +- src/pdflib/pdflib/pdflib.c | 172 +++++++++++---- src/pdflib/pdflib/pdflib.h | 9 +- src/sim/cd_truetype.c | 3 +- 70 files changed, 2724 insertions(+), 1527 deletions(-) (limited to 'src') diff --git a/src/cd_pdflib.mak b/src/cd_pdflib.mak index 194c36a..a185d19 100644 --- a/src/cd_pdflib.mak +++ b/src/cd_pdflib.mak @@ -14,14 +14,9 @@ ifeq ($(TEC_UNAME), sparc) DEFINES = WORDS_BIGENDIAN endif -# Changes to PDFlib-Lite-7.0.0p3 (search for CDPDF): +# Changes to PDFlib-Lite-7.0.4p4 (search for CDPDF): # pdflib/pdcore/pc_config.h - added default PDF_PLATFORM # pdflib/pdflib/p_intern.h - removed support for other image formats, leave this to IM */ -# pdflib/pdflib/p_png.c - added some type casts, fixed position of pdf_png_read_data, renamed flate to pdf_comp_flate. -# pdflib/pdflib/p_gif.c - added missing pdf_cleanup_gif -# pdflib/pdflib/p_jpeg.c - added missing pdf_cleanup_jpeg -# pdflib/pdflib/p_tiff.c - fixed pdf_is_TIFF_file definition -# pdflib/pdflib/p_image.h - replaced toff_t by pdc_uint32 srcdir := pdflib/font INCLUDES := $(INCLUDES) $(srcdir) diff --git a/src/pdflib/pdflib/p_3d.c b/src/pdflib/pdflib/p_3d.c index 033c834..3a14306 100644 --- a/src/pdflib/pdflib/p_3d.c +++ b/src/pdflib/pdflib/p_3d.c @@ -9,7 +9,7 @@ | available, please check http://www.pdflib.com. | *---------------------------------------------------------------------------*/ -/* $Id: p_3d.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_3d.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib 3D functions routines * diff --git a/src/pdflib/pdflib/p_actions.c b/src/pdflib/pdflib/p_actions.c index f3c42fc..fb15ca7 100644 --- a/src/pdflib/pdflib/p_actions.c +++ b/src/pdflib/pdflib/p_actions.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_actions.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_actions.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib actions handling routines * @@ -36,7 +36,8 @@ typedef enum pdf_javascript = (1<<9), pdf_setocgstate = (1<<10), pdf_trans = (1<<11), - pdf_goto3dview = (1<<12) + pdf_goto3dview = (1<<12), + pdf_movie = (1<<13) } pdf_actiontype; @@ -55,6 +56,7 @@ static const pdc_keyconn pdf_action_pdfkeylist[] = {"SetOCGState", pdf_setocgstate}, {"Trans", pdf_trans}, {"GoTo3DView", pdf_goto3dview}, + {"Movie", pdf_movie}, {NULL, 0} }; @@ -116,10 +118,20 @@ static const pdc_keyconn pdf_filename_keylist[] = {NULL, 0} }; +#define PDF_MIN_MOVIEKEY 3 + static const pdc_keyconn pdf_operation_pdfkeylist[] = { + /* Launch */ {"open", 1}, {"print", 2}, + + /* Movie */ + {"Play", PDF_MIN_MOVIEKEY}, + {"Stop", 4}, + {"Pause", 5}, + {"Resume", 6}, + {NULL, 0} }; @@ -131,6 +143,9 @@ static const pdc_keyconn pdf_3dview_keylist[] = + + + #define PDF_LAYER_FLAG PDC_OPT_UNSUPP #define PDF_JAVASCRIPT_FLAG PDC_OPT_UNSUPP @@ -139,7 +154,7 @@ static const pdc_keyconn pdf_3dview_keylist[] = static const pdc_defopt pdf_create_action_options[] = { /* deprecated */ - {"actionwarning", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + {"actionwarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, 0.0, 0.0, NULL}, {"hypertextencoding", pdc_stringlist, PDC_OPT_NONE, 1, 1, @@ -170,7 +185,7 @@ static const pdc_defopt pdf_create_action_options[] = 0.0, PDC_USHRT_MAX, NULL}, {"script", pdc_stringlist, PDF_JAVASCRIPT_FLAG, 1, 1, - 0.0, PDC_USHRT_MAX, NULL}, + 0.0, PDC_INT_MAX, NULL}, {"scriptname", pdc_stringlist, PDF_JAVASCRIPT_FLAG, 1, 1, 0.0, PDC_USHRT_MAX, NULL}, @@ -208,7 +223,7 @@ static const pdc_defopt pdf_create_action_options[] = {"3dview", pdc_3dviewhandle, PDF_3DVIEW_FLAG, 1, 1, 0.0, 0.0, pdf_3dview_keylist}, - {"target", pdc_stringlist, PDF_3DVIEW_FLAG, 1, 1, + {"target", pdc_stringlist, PDC_OPT_NONE, 1, 1, 0.0, PDC_USHRT_MAX, NULL}, {"transition", pdc_keywordlist, PDC_OPT_PDC_1_5, 1, 1, @@ -229,6 +244,7 @@ typedef struct pdf_action_s pdf_dest *dest; pdc_encoding hypertextencoding; char *filename; + char *nativefilename; char *parameters; char *operation; char *defaultdir; @@ -259,6 +275,7 @@ pdf_reclaim_action(void *item) action->dest = NULL; action->hypertextencoding = pdc_invalidenc; action->filename = NULL; + action->nativefilename = NULL; action->parameters = NULL; action->operation = NULL; action->defaultdir = NULL; @@ -285,6 +302,7 @@ pdf_release_action(void *context, void *item) pdf_action *action = (pdf_action *) item; pdf_cleanup_destination(p, action->dest); + action->dest = NULL; if (action->filename) { @@ -292,6 +310,12 @@ pdf_release_action(void *context, void *item) action->filename = NULL; } + if (action->nativefilename) + { + pdc_free(p->pdc, action->nativefilename); + action->nativefilename = NULL; + } + if (action->parameters) { pdc_free(p->pdc, action->parameters); @@ -322,6 +346,7 @@ pdf_release_action(void *context, void *item) action->namelist = NULL; } + } static pdc_ced pdf_action_ced = @@ -466,20 +491,26 @@ pdf__create_action(PDF *p, const char *type, const char *optlist) for (i = 0; ; i++) { keyword = pdf_filename_keylist[i].word; - if (keyword) - { - if (pdc_get_optvalues(keyword, resopts, NULL, &strlist)) - { - if (!pdf_opt_effectless(p, keyword, atype, - (pdf_actiontype) pdf_filename_keylist[i].code)) - { - action->filename = - (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); - } - } - } - else + if (keyword == NULL) break; + + if (!pdc_get_optvalues(keyword, resopts, NULL, NULL) || + pdf_opt_effectless(p, keyword, atype, + (pdf_actiontype) pdf_filename_keylist[i].code)) + continue; + + /* DON'T change order */ + + /* native filename */ + if (!i) + action->nativefilename = pdf_get_opt_filename(p, keyword, resopts, + htenc, htcp); + + /* Unicode filename */ + pdf_get_opt_textlist(p, keyword, resopts, htenc, htcp, pdc_true, + NULL, &action->filename, NULL); + + pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); } keyword = "parameters"; @@ -490,9 +521,18 @@ pdf__create_action(PDF *p, const char *type, const char *optlist) keyword = "operation"; if (pdc_get_optvalues(keyword, resopts, &k, NULL) && - !pdf_opt_effectless(p, keyword, atype, pdf_launch)) + !pdf_opt_effectless(p, keyword, atype, + (pdf_actiontype) (pdf_launch | pdf_movie))) + { + if ((atype == pdf_launch && k >= PDF_MIN_MOVIEKEY) || + (atype == pdf_movie && k < PDF_MIN_MOVIEKEY)) + { + pdc_error(p->pdc, PDC_E_OPT_ILLKEYWORD, keyword, + pdc_get_keyword(k, pdf_operation_pdfkeylist), 0, 0); + } action->operation = (char *) pdc_get_keyword(k, pdf_operation_pdfkeylist); + } keyword = "defaultdir"; if (pdc_get_optvalues(keyword, resopts, NULL, NULL) && @@ -648,12 +688,18 @@ pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) /* Windows-specific launch parameters */ pdc_puts(p->out, "/Win"); pdc_begin_dict(p->out); /* Win dict */ - pdc_printf(p->out, "/F"); - pdf_put_hypertext(p, action->filename); + pdc_puts(p->out, "/F"); + pdf_put_pdffilename(p, action->nativefilename); pdc_puts(p->out, "\n"); + if (p->compatibility >= PDC_1_7) + { + pdc_puts(p->out, "/UF"); + pdf_put_pdfunifilename(p, action->filename); + pdc_puts(p->out, "\n"); + } if (action->parameters) { - pdc_printf(p->out, "/P"); + pdc_puts(p->out, "/P"); pdf_put_hypertext(p, action->parameters); pdc_puts(p->out, "\n"); pdc_free(p->pdc, action->parameters); @@ -661,14 +707,14 @@ pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) } if (action->operation) { - pdc_printf(p->out, "/O"); + pdc_puts(p->out, "/O"); pdf_put_hypertext(p, action->operation); pdc_puts(p->out, "\n"); action->operation = NULL; } if (action->defaultdir) { - pdc_printf(p->out, "/D"); + pdc_puts(p->out, "/D"); pdf_put_hypertext(p, action->defaultdir); pdc_puts(p->out, "\n"); pdc_free(p->pdc, action->defaultdir); @@ -681,9 +727,15 @@ pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) pdc_puts(p->out, "/F"); pdc_begin_dict(p->out); /* F dict */ pdc_puts(p->out, "/Type/Filespec\n"); - pdc_printf(p->out, "/F"); - pdf_put_pdffilename(p, action->filename); + pdc_puts(p->out, "/F"); + pdf_put_pdffilename(p, action->nativefilename); pdc_puts(p->out, "\n"); + if (p->compatibility >= PDC_1_7) + { + pdc_puts(p->out, "/UF"); + pdf_put_pdfunifilename(p, action->filename); + pdc_puts(p->out, "\n"); + } pdc_end_dict(p->out); /* F dict */ } @@ -711,7 +763,7 @@ pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) switch (action->atype) { case pdf_named: - pdc_printf(p->out, "/N"); + pdc_puts(p->out, "/N"); pdf_put_pdfname(p, action->menuname); pdc_puts(p->out, "\n"); @@ -801,6 +853,7 @@ pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) break; } + /* Movie */ pdc_end_dict(p->out); /* Action dict */ @@ -822,19 +875,27 @@ static const pdc_keyconn pdf_annotevent_keylist[] = {"up", 4}, {"focus", 5}, {"blur", 6}, + {"open", 7}, + {"close", 8}, + {"visible", 9}, + {"invisible", 10}, {NULL, 0} }; static const pdc_keyconn pdf_annotevent_pdfkeylist[] = { - {"A", 0}, - {"E", 1}, - {"X", 2}, - {"D", 3}, - {"U", 4}, - {"Fo", 5}, - {"Bl", 6}, - {NULL, 0} + {"A", 0}, + {"E", 1}, + {"X", 2}, + {"D", 3}, + {"U", 4}, + {"Fo", 5}, + {"Bl", 6}, + {"PO", 7}, + {"PC", 8}, + {"PV", 9}, + {"PI", 10}, + {NULL, 0} }; static int pdf_annotevent_beginjava = 99; @@ -862,6 +923,18 @@ static const pdc_defopt pdf_annotevent_options[] = {"blur", pdc_actionhandle, PDC_OPT_NONE, 1, PDC_USHRT_MAX, 0.0, 0.0, NULL}, + {"open", pdc_actionhandle, PDC_OPT_PDC_1_5, 1, PDC_USHRT_MAX, + 0.0, 0.0, NULL}, + + {"close", pdc_actionhandle, PDC_OPT_PDC_1_5, 1, PDC_USHRT_MAX, + 0.0, 0.0, NULL}, + + {"visible", pdc_actionhandle, PDC_OPT_PDC_1_5, 1, PDC_USHRT_MAX, + 0.0, 0.0, NULL}, + + {"invisible", pdc_actionhandle, PDC_OPT_PDC_1_5, 1, PDC_USHRT_MAX, + 0.0, 0.0, NULL}, + PDC_OPT_TERMINATE }; @@ -884,7 +957,7 @@ static int pdf_bookmarkevent_beginjava = 99; static const pdc_defopt pdf_bookmarkevent_options[] = { - {"activate", pdc_actionhandle, PDC_OPT_NONE, 1, 1, + {"activate", pdc_actionhandle, PDC_OPT_NONE, 1, PDC_USHRT_MAX, 0.0, 0.0, NULL}, PDC_OPT_TERMINATE @@ -1059,12 +1132,13 @@ pdf_parse_and_write_actionlist(PDF *p, pdf_event_object eventobj, /* write action objects */ if (act_idlist != NULL) { + ret_id = PDC_BAD_ID; if (nsact == 1) { action = (pdf_action *) &pdc_vtr_at(p->actions, actlist[0], pdf_action); if (action->obj_id == PDC_BAD_ID) - ret_id = pdf_write_action(p, action, PDC_BAD_ID); + ret_id = pdf_write_action(p, action, ret_id); else ret_id = action->obj_id; } @@ -1077,8 +1151,6 @@ pdf_parse_and_write_actionlist(PDF *p, pdf_event_object eventobj, ret_id = pdf_write_action(p, action, ret_id); } } - else - ret_id = PDC_BAD_ID; act_idlist[code] = ret_id; } } diff --git a/src/pdflib/pdflib/p_afm.c b/src/pdflib/pdflib/p_afm.c index 8de04a5..8b7c957 100644 --- a/src/pdflib/pdflib/p_afm.c +++ b/src/pdflib/pdflib/p_afm.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_afm.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_afm.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib AFM parsing routines * @@ -218,7 +218,7 @@ pdf_parse_afm( static const char fn[] = "pdf_parse_afm"; fnt_font_metric *ftm = &font->ft.m; const char *afmtype = NULL; - char **wordlist, *keyword, *arg1; + char **wordlist = NULL, *keyword, *arg1; char line[AFM_LINEBUF]; int i, cmp, lo, hi, nwords, nglyphs = 0, nline = 0; int tablen = ((sizeof keyStrings) / (sizeof (char *))); diff --git a/src/pdflib/pdflib/p_annots.c b/src/pdflib/pdflib/p_annots.c index b38da91..a8b74d7 100644 --- a/src/pdflib/pdflib/p_annots.c +++ b/src/pdflib/pdflib/p_annots.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_annots.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_annots.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib routines for annnotations * @@ -45,7 +45,8 @@ typedef enum ann_polyline = (1<<13), ann_popup = (1<<14), ann_fileattachment = (1<<15), - ann_3d = (1<<16) + ann_3d = (1<<16), + ann_movie = (1<<17) } pdf_annottype; @@ -68,6 +69,7 @@ static const pdc_keyconn pdf_annottype_pdfkeylist[] = {"Popup", ann_popup}, {"FileAttachment", ann_fileattachment}, {"3D", ann_3d}, + {"Movie", ann_movie}, {NULL, 0} }; @@ -98,20 +100,21 @@ typedef enum anndict_inklist = (1<<8), anndict_l = (1<<9), anndict_le = (1<<10), - anndict_name = (1<<11), - anndict_nm = (1<<12), - anndict_open = (1<<13), - anndict_parent = (1<<14), - anndict_popup = (1<<15), - anndict_q = (1<<16), - anndict_quadpoints = (1<<17), - anndict_rect = (1<<18), - anndict_subtype = (1<<19), - anndict_t = (1<<20), - anndict_vertices = (1<<21), - anndict_3dd = (1<<22), - anndict_3da = (1<<23), - anndict_3dv = (1<<24) + anndict_movie = (1<<11), + anndict_name = (1<<12), + anndict_nm = (1<<13), + anndict_open = (1<<14), + anndict_parent = (1<<15), + anndict_popup = (1<<16), + anndict_q = (1<<17), + anndict_quadpoints = (1<<18), + anndict_rect = (1<<19), + anndict_subtype = (1<<20), + anndict_t = (1<<21), + anndict_vertices = (1<<22), + anndict_3dd = (1<<23), + anndict_3da = (1<<24), + anndict_3dv = (1<<25) } pdf_anndictentries; @@ -136,6 +139,7 @@ static const pdc_keyconn pdf_forb_entries_pdfkeylist[] = {"InkList", anndict_inklist}, {"L", anndict_l}, {"LE", anndict_le}, + {"Movie", anndict_movie}, {"Parent", anndict_parent}, {"Popup", anndict_popup}, {"Q", anndict_q}, @@ -263,6 +267,46 @@ static const pdc_keyconn pdf_3dview_keylist[] = }; +typedef enum +{ + movieposter_none = -1, + movieposter_auto = -2 +} +pdf_movieposter_states; + +static const pdc_keyconn pdf_movieposter_keylist[] = +{ + {"none", movieposter_none}, + {"auto", movieposter_auto}, + {NULL, 0} +}; + +typedef enum +{ + playmode_once, + playmode_open, + playmode_repeat, + playmode_palindrome +} +pdf_playmode_states; + +static const pdc_keyconn pdf_playmode_pdfkeylist[] = +{ + {"Once", playmode_once}, + {"Open", playmode_open}, + {"Repeat", playmode_repeat}, + {"Palindrome", playmode_palindrome}, + {NULL, 0} +}; + +#define PDF_ANN_FULLSCREEN -9999 + +static const pdc_keyconn pdf_windowscale_keylist[] = +{ + {"fullscreen", PDF_ANN_FULLSCREEN}, + {NULL, 0} +}; + #define PDF_LAYER_FLAG PDC_OPT_UNSUPP @@ -270,7 +314,7 @@ static const pdc_keyconn pdf_3dview_keylist[] = static const pdc_defopt pdf_create_annot_options[] = { /* deprecated */ - {"annotwarning", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + {"annotwarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, 0.0, 0.0, NULL}, {"usercoordinates", pdc_booleanlist, PDC_OPT_NONE, 1, 1, @@ -411,6 +455,24 @@ static const pdc_defopt pdf_create_annot_options[] = {"3dinitialview", pdc_3dviewhandle, PDF_3DANNOT_FLAG, 1, 1, 0.0, 0.0, pdf_3dview_keylist}, + {"movieposter", pdc_templatehandle, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, pdf_movieposter_keylist}, + + {"showcontrols", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, NULL}, + + {"playmode", pdc_keywordlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, pdf_playmode_pdfkeylist}, + + {"windowscale", pdc_scalarlist, PDC_OPT_NONE, 1, 1, + PDC_FLOAT_PREC, PDC_FLOAT_MAX, pdf_windowscale_keylist}, + + {"windowposition", pdc_scalarlist, PDC_OPT_NONE, 1, 2, + 0.0, 100.0, pdf_position_keylist}, + + {"soundvolume", pdc_scalarlist, PDC_OPT_NONE, 1, 1, + -1.0, 1.0, NULL}, + PDC_OPT_TERMINATE }; @@ -454,6 +516,7 @@ typedef struct pdf_annot_s char *subject; char *contents; char *filename; + char *nativefilename; char *mimetype; const char *iconname; pdc_off_t filesize; @@ -465,6 +528,13 @@ typedef struct pdf_annot_s char *action; + + pdc_id movieposter; + pdc_bool showcontrols; + pdf_playmode_states playmode; + pdc_scalar windowscale; + pdc_scalar windowposition[2]; + pdc_scalar soundvolume; } pdf_annot; @@ -511,6 +581,7 @@ pdf_reclaim_annot(void *item) ann->subject = NULL; ann->contents = NULL; ann->filename = NULL; + ann->nativefilename = NULL; ann->mimetype = NULL; ann->iconname = NULL; ann->filesize = 0; @@ -524,6 +595,14 @@ pdf_reclaim_annot(void *item) + + ann->movieposter = PDC_BAD_ID /* = movieposter_none */; + ann->showcontrols = pdc_false; + ann->playmode = playmode_once; + ann->windowscale = 0; + ann->windowposition[0] = 50.0; + ann->windowposition[1] = 50.0; + ann->soundvolume = 1.0; } static void @@ -573,6 +652,11 @@ pdf_release_annot(void *context, void *item) pdc_free(p->pdc, ann->filename); ann->filename = NULL; } + if (ann->nativefilename) + { + pdc_free(p->pdc, ann->nativefilename); + ann->nativefilename = NULL; + } if (ann->mimetype) { pdc_free(p->pdc, ann->mimetype); @@ -848,6 +932,7 @@ pdf__create_annotation(PDF *p, char **strlist = NULL; pdc_scalar *line; int i, j, k, ns, nss[2]; + pdf_colortype maxcs = color_rgb; pdf_ppt *ppt = p->curr_ppt; pdc_matrix *ctm = &ppt->gstate[ppt->sl].ctm; @@ -873,6 +958,9 @@ pdf__create_annotation(PDF *p, pdc_get_pdfversion(p->pdc, PDC_1_5), 0, 0); } + if (p->compatibility >= PDC_1_6) + maxcs = color_cmyk; + /* Parsing option list */ pdf_set_clientdata(p, &cdata); resopts = pdc_parse_optionlist(p->pdc, optlist, pdf_create_annot_options, @@ -931,7 +1019,7 @@ pdf__create_annotation(PDF *p, ns = pdc_get_optvalues(keyword, resopts, NULL, &strlist); if (ns) { - pdf_parse_coloropt(p, keyword, strlist, ns, (int) color_rgb, + pdf_parse_coloropt(p, keyword, strlist, ns, (int) maxcs, &ann->annotcolor); } @@ -1017,7 +1105,7 @@ pdf__create_annotation(PDF *p, keyword = "orientate"; if (pdc_get_optvalues(keyword, resopts, &ann->orientate, NULL)) pdf_opt_effectless(p, keyword, atype, - (pdf_annottype) (ann_freetext | ann_stamp)); + (pdf_annottype) (ann_freetext | ann_stamp)); keyword = "contents"; if (atype == ann_freetext) @@ -1069,10 +1157,22 @@ pdf__create_annotation(PDF *p, keyword = "filename"; if (pdc_get_optvalues(keyword, resopts, NULL, NULL) && - !pdf_opt_effectless(p, keyword, atype, ann_fileattachment)) + !pdf_opt_effectless(p, keyword, atype, + (pdf_annottype) (ann_fileattachment | ann_movie))) { - ann->filename = (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); - ann->filesize = pdf_check_file(p, ann->filename, pdc_true); + /* DON'T change order */ + + /* native filename */ + ann->nativefilename = pdf_get_opt_filename(p, keyword, resopts, + ann->hypertextencoding, ann->hypertextcodepage); + + pdf_get_opt_textlist(p, keyword, resopts, ann->hypertextencoding, + ann->hypertextcodepage, pdc_true, + NULL, &ann->filename, NULL); + pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); + + if (atype == ann_fileattachment) + ann->filesize = pdf_check_file(p, ann->filename, pdc_true); } keyword = "mimetype"; @@ -1115,7 +1215,7 @@ pdf__create_annotation(PDF *p, (pdf_annottype) (ann_line | ann_polyline | ann_square | ann_circle))) { - pdf_parse_coloropt(p, keyword, strlist, ns, (int) color_rgb, + pdf_parse_coloropt(p, keyword, strlist, ns, (int) maxcs, &ann->interiorcolor); } @@ -1173,6 +1273,24 @@ pdf__create_annotation(PDF *p, keyword = "action"; if (pdc_get_optvalues(keyword, resopts, NULL, &strlist)) { + /* + * PDF 1.7 allows the A action dictionary only for annotation types + * link, widget and screen. Widget is handled elsewhere, and screen + * is not yet implemented, so only link is allowed with compatiblity + * 1.7. + * Must be extended that also screen annotation is accepted here + * once it is implemented. + */ + if (p->compatibility >= PDC_1_7) + { + if (ann->atype != ann_link) + { + pdc_error(p->pdc, PDF_E_ANN_ACTIONNOTALLOWED, + pdc_get_keyword(ann->atype, pdf_annottype_pdfkeylist), + 0, 0, 0); + } + } + if (ann->dest) { pdf_cleanup_destination(p, ann->dest); @@ -1188,15 +1306,83 @@ pdf__create_annotation(PDF *p, + keyword = "movieposter"; + if (pdc_get_optvalues(keyword, resopts, &ns, NULL)) + { + pdf_opt_effectless(p, keyword, atype, ann_movie); + if (ns < 0) + { + ann->movieposter = (pdc_id) ns; + } + else + { +#if 0 + int cstype = pdf_get_image_colorspace(p, ns); + + if (cstype != (int) DeviceGray && cstype != (int) DeviceRGB) + pdc_error(p->pdc, PDF_E_ANN_ILLTEMPLATE, 0, 0, 0, 0); +#endif + ann->movieposter = pdf_get_xobject(p, ns); + } + } + + keyword = "showcontrols"; + if (pdc_get_optvalues(keyword, resopts, &ann->showcontrols, NULL)) + pdf_opt_effectless(p, keyword, atype, ann_movie); + + keyword = "playmode"; + if (pdc_get_optvalues(keyword, resopts, &ns, NULL)) + { + pdf_opt_effectless(p, keyword, atype, ann_movie); + ann->playmode = (pdf_playmode_states) ns; + } + + keyword = "windowscale"; + if (pdc_get_optvalues(keyword, resopts, &ann->windowscale, NULL)) + pdf_opt_effectless(p, keyword, atype, ann_movie); + + keyword = "windowposition"; + ns = pdc_get_optvalues(keyword, resopts, ann->windowposition, NULL); + if (ns) + { + pdf_opt_effectless(p, keyword, atype, ann_movie); + pdf_set_position_values(p, ann->windowposition, ns); + } + + keyword = "soundvolume"; + if (pdc_get_optvalues(keyword, resopts, &ann->soundvolume, NULL)) + pdf_opt_effectless(p, keyword, atype, ann_movie); + + /* named annotation, to be accessible by a GoTo3DView or Movie action */ + if ((atype == ann_3d || atype == ann_movie) && ann->name != NULL) + { + char *name = (char *) pdc_strdup(p->pdc, ann->name); + + ann->obj_id = pdc_alloc_id(p->out); + pdf_insert_name(p, name, names_annots, ann->obj_id); + } + + /* work-around for Acrobat 8 (see bug #1225) */ + if (ann->annotcolor.type == (int) color_none && + (atype == ann_square || atype == ann_circle)) + { + ann->annotcolor.type = (int) color_rgb; + ann->annotcolor.value[0] = 1.0; + ann->annotcolor.value[1] = 1.0; + ann->annotcolor.value[2] = 1.0; + } + /* required options */ keyword = NULL; - if (ann->contents == NULL && atype != ann_link && atype != ann_popup) + if (ann->contents == NULL && + atype != ann_link && atype != ann_popup && atype != ann_movie) keyword = "contents"; if (ann->fontsize == 0 && atype == ann_freetext) keyword = "fontsize"; if (ann->font == -1 && atype == ann_freetext) keyword = "font"; - if (ann->filename == NULL && atype == ann_fileattachment) + if (ann->filename == NULL && + (atype == ann_fileattachment || atype == ann_movie)) keyword = "filename"; if (ann->line == NULL && atype == ann_line) keyword = "line"; @@ -1302,12 +1488,10 @@ pdf_write_annots_root(PDF *p, pdc_vtr *annots, pdf_widget *widgetlist) return result; } -#define BUFSIZE 256 - static void pdf_write_defappstring(PDF *p, pdf_annot *ann) { - char buf[BUFSIZE], *bufc; + char buf[PDC_GEN_BUFSIZE], *bufc; pdf_coloropt *fs; int ct; @@ -1348,6 +1532,57 @@ pdf_write_defappstring(PDF *p, pdf_annot *ann) pdc_puts(p->out, "\n"); } +static void +pdf_write_colorentry(PDF *p, const char *keyname, pdf_coloropt *coloropt) +{ + if (p->compatibility < PDC_1_6) + { + if (coloropt->type != (int) color_none) + { + pdc_printf(p->out, "%s[%f %f %f]\n", + keyname, + coloropt->value[0], + coloropt->value[1], + coloropt->value[2]); + } + } + else + { + switch (coloropt->type) + { + case color_none: + /* this doesn't work in Acrobat 8 + pdc_printf(p->out, "%s[0]\n", + keyname); + */ + break; + + case color_gray: + pdc_printf(p->out, "%s[%f]\n", + keyname, + coloropt->value[0]); + break; + + case color_rgb: + pdc_printf(p->out, "%s[%f %f %f]\n", + keyname, + coloropt->value[0], + coloropt->value[1], + coloropt->value[2]); + break; + + case color_cmyk: + pdc_printf(p->out, "%s[%f %f %f %f]\n", + keyname, + coloropt->value[0], + coloropt->value[1], + coloropt->value[2], + coloropt->value[3]); + break; + } + } +} + void pdf_write_page_annots(PDF *p, pdc_vtr *annots) { @@ -1449,11 +1684,7 @@ pdf_write_page_annots(PDF *p, pdc_vtr *annots) } /* Annotation color */ - if (ann->annotcolor.type != (int) color_none) - { - pdc_printf(p->out, "/C[%f %f %f]\n", ann->annotcolor.value[0], - ann->annotcolor.value[1], ann->annotcolor.value[2]); - } + pdf_write_colorentry(p, "/C", &ann->annotcolor); /* Title */ if (ann->title && *ann->title) @@ -1608,7 +1839,7 @@ pdf_write_page_annots(PDF *p, pdc_vtr *annots) case ann_stamp: case ann_freetext: if (ann->orientate) - pdc_printf(p->out, "/Rotate %d", ann->orientate); + pdc_printf(p->out, "/Rotate %d\n", ann->orientate); break; default: @@ -1622,13 +1853,7 @@ pdf_write_page_annots(PDF *p, pdc_vtr *annots) case ann_polyline: case ann_square: case ann_circle: - if (ann->interiorcolor.type != (int) color_none) - { - pdc_printf(p->out, "/IC[%f %f %f]\n", - ann->interiorcolor.value[0], - ann->interiorcolor.value[1], - ann->interiorcolor.value[2]); - } + pdf_write_colorentry(p, "/IC", &ann->interiorcolor); break; /* Parent Annotation */ @@ -1651,12 +1876,21 @@ pdf_write_page_annots(PDF *p, pdc_vtr *annots) /* File specification */ case ann_fileattachment: { + /* see bug #1439 */ + const char *basename = pdc_file_strip_dirs(ann->nativefilename); + pdc_puts(p->out, "/FS"); pdc_begin_dict(p->out); /* FS dict */ pdc_puts(p->out, "/Type/Filespec\n"); pdc_puts(p->out, "/F"); - pdf_put_pdffilename(p, ann->filename); + pdf_put_pdffilename(p, basename); pdc_puts(p->out, "\n"); + if (p->compatibility >= PDC_1_7) + { + pdc_puts(p->out, "/UF"); + pdf_put_pdfunifilename(p, basename); + pdc_puts(p->out, "\n"); + } /* alloc id for the actual embedded file stream */ ann->obj_id = pdc_alloc_id(p->out); @@ -1669,6 +1903,110 @@ pdf_write_page_annots(PDF *p, pdc_vtr *annots) break; + case ann_movie: + { + pdc_puts(p->out, "/Movie"); + pdc_begin_dict(p->out); /* Movie dict */ + + /* File specification */ + pdc_puts(p->out, "/F"); + pdc_begin_dict(p->out); /* F dict */ + pdc_puts(p->out, "/Type/Filespec\n"); + pdc_puts(p->out, "/F"); + pdf_put_pdffilename(p, ann->nativefilename); + pdc_puts(p->out, "\n"); + if (p->compatibility >= PDC_1_7) + { + pdc_puts(p->out, "/UF"); + pdf_put_pdfunifilename(p, ann->filename); + pdc_puts(p->out, "\n"); + } + pdc_end_dict(p->out); /* F dict */ + + /* Aspect - not supported by Acrobat */ + /* Rotate - doesn't work */ + + /* Poster */ + if (ann->movieposter != movieposter_none) + { + if (ann->movieposter == movieposter_auto) + pdc_puts(p->out, "/Poster true"); + else + pdc_objref(p->out, "/Poster", ann->movieposter); + } + + pdc_end_dict(p->out); /* Movie dict */ + + if (ann->soundvolume != 1.0 || + ann->showcontrols || + ann->playmode != playmode_once || + ann->windowscale != 0) + { + pdc_puts(p->out, "/A"); + pdc_begin_dict(p->out); /* Activation dict */ + + /* Start, Duration, Rate, Synchronus - not supported */ + + /* Volume */ + if (ann->soundvolume != 1.0) + pdc_printf(p->out, "/Volume %f\n", ann->soundvolume); + + /* ShowControls */ + if (ann->showcontrols) + pdc_puts(p->out, "/ShowControls true\n"); + + /* Mode */ + if (ann->playmode != playmode_once) + pdc_printf(p->out, "/Mode/%s\n", + pdc_get_keyword(ann->playmode, + pdf_playmode_pdfkeylist)); + + /* window */ + if (ann->windowscale != 0) + { + int sx, sy; + + if (ann->windowscale == PDF_ANN_FULLSCREEN) + { + /* see PDF Reference 1.7, Appendix H, 153. */ + sx = 999; + sy = 1; + } + else + { + pdc_scalar sf, sp; + + sp = 1; + for (i = 0; ; i++) + { + sf = sp * ann->windowscale; + if (sf == (double) (int) (sf) || i == 5) + break; + sp *= 10; + } + + sx = (int) sf; + sy = (int) sp; + } + + /* FWScale */ + pdc_printf(p->out, "/FWScale[%d %d]\n", sx, sy); + + /* FWPosition */ + if (ann->windowposition[0] != 50.0 || + ann->windowposition[1] != 50.0) + { + pdc_printf(p->out, "/FWPosition[%f %f]\n", + ann->windowposition[0] / 100.0, + 1.0 - ann->windowposition[1] / 100.0); + } + } + + pdc_end_dict(p->out); /* Activation dict */ + } + } + break; + default: break; } @@ -1704,21 +2042,21 @@ pdf_create_link( const char *utext, int len) { - char optlist[2048]; + static const char *fn = "pdf_create_link"; + char *optlist; char *name; int acthdl; + name = pdf_convert_name(p, utext, len, PDC_CONV_WITHBOM); + optlist = (char *) pdc_malloc(p->pdc, strlen(name) + 80, fn); + if (!pdc_stricmp(type, "URI")) strcpy(optlist, "url {"); else if (!pdc_stricmp(type, "GoTo")) strcpy(optlist, "destname {"); else if (!pdc_stricmp(type, "GoToR")) strcpy(optlist, "destination {page 1} filename {"); - - name = pdf_convert_name(p, utext, len, PDC_CONV_WITHBOM); strcat(optlist, name); - pdc_free(p->pdc, name); - strcat(optlist, "}"); acthdl = pdf__create_action(p, type, optlist); @@ -1730,6 +2068,9 @@ pdf_create_link( strcat(optlist, annopts); pdf__create_annotation(p, llx, lly, urx, ury, "Link", optlist); } + + pdc_free(p->pdc, optlist); + pdc_free(p->pdc, name); } void @@ -1830,6 +2171,7 @@ pdf__attach_file( pdf_init_rectangle(p, ann, llx, lly, urx, ury, NULL); pdf_insert_annot_params(p, ann); ann->filename = pdc_strdup(p->pdc, filename); + ann->nativefilename = pdc_strdup(p->pdc, filename); ann->filesize = pdf_check_file(p, ann->filename, pdc_true); ann->contents = pdf_convert_hypertext_depr(p, description, len_descr); ann->title = pdf_convert_hypertext_depr(p, author, len_auth); @@ -1891,18 +2233,25 @@ pdf__add_pdflink( int page, const char *optlist) { - char actoptlist[2048], *sopt; + static const char *fn = "pdf__add_pdflink"; + char *actoptlist, *sopt; pdf_annot *ann; int acthdl; + size_t size; if (filename == NULL || *filename == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + if (optlist == NULL) + optlist = ""; + + size = strlen(filename) + strlen(optlist) + 80; + actoptlist = (char *) pdc_malloc(p->pdc, size, fn); + /* creating a GoToR action */ actoptlist[0] = 0; sopt = actoptlist; sopt += pdc_sprintf(p->pdc, pdc_false, sopt, "filename {%s} ", filename); - if (optlist == NULL) optlist = ""; sopt += pdc_sprintf(p->pdc, pdc_false, sopt, "destination {%s page %d} ", optlist, page); acthdl = pdf__create_action(p, "GoToR", actoptlist); @@ -1919,6 +2268,8 @@ pdf__add_pdflink( ann->action = pdc_strdup(p->pdc, actoptlist); ann->display = disp_noprint; } + + pdc_free(p->pdc, actoptlist); } void @@ -1930,12 +2281,22 @@ pdf__add_launchlink( pdc_scalar ury, const char *filename) { - char actoptlist[2048], *sopt; + static const char *fn = "pdf__add_launchlink"; + char *actoptlist, *sopt; pdf_annot *ann; int acthdl; + size_t size; if (filename == NULL || *filename == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + size = strlen(filename) + 80; + if (p->launchlink_parameters) + size += strlen(p->launchlink_parameters); + if (p->launchlink_operation) + size += strlen(p->launchlink_operation); + if (p->launchlink_defaultdir) + size += strlen(p->launchlink_defaultdir); + actoptlist = (char *) pdc_malloc(p->pdc, size, fn); /* creating a Launch action */ actoptlist[0] = 0; @@ -1976,6 +2337,8 @@ pdf__add_launchlink( ann->action = pdc_strdup(p->pdc, actoptlist); ann->display = disp_noprint; } + + pdc_free(p->pdc, actoptlist); } void @@ -2008,12 +2371,14 @@ pdf__add_weblink( pdc_scalar ury, const char *url) { - char actoptlist[2048]; + static const char *fn = "pdf__add_weblink"; + char *actoptlist; pdf_annot *ann; int acthdl; if (url == NULL || *url == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "url", 0, 0, 0); + actoptlist = (char *) pdc_malloc(p->pdc, strlen(url) + 80, fn); /* creating a URI action */ pdc_sprintf(p->pdc, pdc_false, actoptlist, "url {%s} ", url); @@ -2031,6 +2396,8 @@ pdf__add_weblink( ann->action = pdc_strdup(p->pdc, actoptlist); ann->display = disp_noprint; } + + pdc_free(p->pdc, actoptlist); } void @@ -2073,6 +2440,3 @@ pdf__set_border_dash(PDF *p, pdc_scalar b, pdc_scalar w) p->border_dash1 = b; p->border_dash2 = w; } - - - diff --git a/src/pdflib/pdflib/p_block.c b/src/pdflib/pdflib/p_block.c index 24a55a8..ee755d1 100644 --- a/src/pdflib/pdflib/p_block.c +++ b/src/pdflib/pdflib/p_block.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* | PDFlib - A library for generating PDF on the fly | +---------------------------------------------------------------------------+ - | Copyright (c) 1997-2007 Thomas Merz and PDFlib GmbH. All rights reserved. | + | Copyright (c) 1997-2009 Thomas Merz and PDFlib GmbH. All rights reserved. | +---------------------------------------------------------------------------+ | | | This software is subject to the PDFlib license. It is NOT in the | @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_block.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_block.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Block processing routines (require the PDI library) * diff --git a/src/pdflib/pdflib/p_bmp.c b/src/pdflib/pdflib/p_bmp.c index ac6a974..80c7f0b 100644 --- a/src/pdflib/pdflib/p_bmp.c +++ b/src/pdflib/pdflib/p_bmp.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_bmp.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_bmp.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * BMP processing for PDFlib * @@ -36,7 +36,7 @@ pdf_process_BMP_data( PDF *p, int imageslot) { - pdf_image *image = &p->images[imageslot]; + (void) imageslot; pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "BMP", 0, 0, 0); diff --git a/src/pdflib/pdflib/p_ccitt.c b/src/pdflib/pdflib/p_ccitt.c index ce028b7..28b6239 100644 --- a/src/pdflib/pdflib/p_ccitt.c +++ b/src/pdflib/pdflib/p_ccitt.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_ccitt.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_ccitt.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * CCITT (Fax G3 and G4) processing for PDFlib * diff --git a/src/pdflib/pdflib/p_cid.c b/src/pdflib/pdflib/p_cid.c index 6d7766c..9e03af3 100644 --- a/src/pdflib/pdflib/p_cid.c +++ b/src/pdflib/pdflib/p_cid.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_cid.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_cid.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib CID font handling routines * diff --git a/src/pdflib/pdflib/p_color.c b/src/pdflib/pdflib/p_color.c index d996d06..5591da1 100644 --- a/src/pdflib/pdflib/p_color.c +++ b/src/pdflib/pdflib/p_color.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_color.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_color.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib color routines * @@ -162,10 +162,9 @@ pdf_color_components(PDF *p, int slot) static void pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode drawmode) { - static const char *fn = "pdf_write_color_values"; + static const char fn[] = "pdf_write_color_values"; + pdf_colorspace * cs = &p->colorspaces[color->cs]; - int cs_bias = p->curr_ppt->cs_bias; - int pt_bias = p->curr_ppt->pt_bias; switch (cs->type) { @@ -219,12 +218,13 @@ pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode drawmode) } else if (p->pattern[color->val.pattern].painttype == 2) { - pdc_printf(p->out, "/C%d cs ", cs_bias + color->cs); - pdf_write_color_values(p, - &p->curr_ppt->cstate[p->curr_ppt->sl].fill, pdf_none); + pdf_color *fillcolor = pdf_get_cstate(p, pdf_fill); + + pdc_printf(p->out, "/C%d cs ", color->cs); + pdf_write_color_values(p, fillcolor, pdf_none); } - pdc_printf(p->out, "/P%d scn\n", pt_bias + color->val.pattern); + pdc_printf(p->out, "/P%d scn\n", color->val.pattern); } else if (drawmode == pdf_stroke) { @@ -234,12 +234,13 @@ pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode drawmode) } else if (p->pattern[color->val.pattern].painttype == 2) { - pdc_printf(p->out, "/C%d CS ", cs_bias + color->cs); - pdf_write_color_values(p, - &p->curr_ppt->cstate[p->curr_ppt->sl].stroke, pdf_none); + pdf_color *strokecolor = pdf_get_cstate(p, pdf_stroke); + + pdc_printf(p->out, "/C%d CS ", color->cs); + pdf_write_color_values(p, strokecolor, pdf_none); } - pdc_printf(p->out, "/P%d SCN\n", pt_bias + color->val.pattern); + pdc_printf(p->out, "/P%d SCN\n", color->val.pattern); } p->pattern[color->val.pattern].used_on_current_page = pdc_true; @@ -429,41 +430,44 @@ pdf_add_colorspace(PDF *p, pdf_colorspace *cs, pdc_bool inuse) static void -pdf_set_color_values(PDF *p, pdf_color *c, pdf_drawmode drawmode) +pdf_set_color_values(PDF *p, pdf_color *cfill, pdf_color *cstroke, + pdf_drawmode drawmode) { - pdf_color *current; pdf_colorspace *cs; - cs = &p->colorspaces[c->cs]; - if (drawmode == pdf_stroke || drawmode == pdf_fillstroke) { - current = &p->curr_ppt->cstate[p->curr_ppt->sl].stroke; + pdf_color *strokecolor = pdf_get_cstate(p, pdf_stroke); - if (!pdf_color_equal(p, current, c) || PDF_FORCE_OUTPUT()) - { - if (PDF_GET_STATE(p) != pdf_state_document) - pdf_write_color_values(p, c, pdf_stroke); + if (!pdf_color_equal(p, strokecolor, cstroke) || PDF_FORCE_OUTPUT()) + { + if (PDF_GET_STATE(p) != pdf_state_document) + pdf_write_color_values(p, cstroke, pdf_stroke); - *current = *c; - } + *strokecolor = *cstroke; + } + + cs = &p->colorspaces[cstroke->cs]; + if (!PDF_SIMPLE_COLORSPACE(cs)) + cs->used_on_current_page = pdc_true; } + if (drawmode == pdf_fill || drawmode == pdf_fillstroke) { - current = &p->curr_ppt->cstate[p->curr_ppt->sl].fill; + pdf_color *fillcolor = pdf_get_cstate(p, pdf_fill); - if (!pdf_color_equal(p, current, c) || PDF_FORCE_OUTPUT()) - { - if (PDF_GET_STATE(p) != pdf_state_document) - pdf_write_color_values(p, c, pdf_fill); + if (!pdf_color_equal(p, fillcolor, cfill) || PDF_FORCE_OUTPUT()) + { + if (PDF_GET_STATE(p) != pdf_state_document) + pdf_write_color_values(p, cfill, pdf_fill); - *current = *c; - } - } + *fillcolor = *cfill; + } - /* simple colorspaces don't get written */ - if (!PDF_SIMPLE_COLORSPACE(cs)) - cs->used_on_current_page = pdc_true; + cs = &p->colorspaces[cfill->cs]; + if (!PDF_SIMPLE_COLORSPACE(cs)) + cs->used_on_current_page = pdc_true; + } } /* pdf_set_color_values */ @@ -504,13 +508,12 @@ void pdf_write_page_colorspaces(PDF *p) { int i, total = 0; - int bias = p->curr_ppt->cs_bias; for (i = 0; i < p->colorspaces_number; i++) if (p->colorspaces[i].used_on_current_page) total++; - if (total > 0 || bias + if (total > 0 ) { pdc_puts(p->out, "/ColorSpace"); @@ -529,7 +532,7 @@ pdf_write_page_colorspaces(PDF *p) /* don't write simple color spaces as resource */ if (!PDF_SIMPLE_COLORSPACE(cs)) { - pdc_printf(p->out, "/C%d", bias + i); + pdc_printf(p->out, "/C%d", i); pdc_objref(p->out, "", cs->obj_id); } } @@ -537,7 +540,6 @@ pdf_write_page_colorspaces(PDF *p) } - if (!bias) pdc_end_dict(p->out); /* color space names */ } } /* pdf_write_page_colorspaces */ @@ -843,9 +845,15 @@ pdf_setcolor_internal(PDF *p, int drawmode, int colortype, pdc_scalar c1, pdc_scalar c2, pdc_scalar c3, pdc_scalar c4, pdf_color *fcolor) { - pdf_color c; + pdf_color c, cstroke; pdf_colorspace cs; + if (PDF_GET_STATE(p) == pdf_state_pattern && + pdf_get_shading_painttype(p) == 2) + { + pdc_error(p->pdc, PDF_E_COLOR_INVALSPEC, 0, 0, 0, 0); + } + /* TODO: synchronize the PDF/X checks below with pdf_check_pdfx_colorspaces */ switch (colortype) @@ -876,6 +884,10 @@ pdf_setcolor_internal(PDF *p, int drawmode, int colortype, pdf_check_color_values(p, cs.type, c1, c2, c3, c4); break; + case color_spotname: + case color_spot: + pdc_error(p->pdc, PDF_E_UNSUPP_SPOTCOLOR, 0, 0, 0, 0); + break; case color_pattern: cs.type = PatternCS; @@ -887,22 +899,55 @@ pdf_setcolor_internal(PDF *p, int drawmode, int colortype, { cs.val.pattern.base = pdc_undef; c.cs = pdf_add_colorspace(p, &cs, pdc_false); + cstroke = c; } - else + else if (p->pattern[c.val.pattern].painttype == 2) { - cs.val.pattern.base = p->curr_ppt->cstate[p->curr_ppt->sl].fill.cs; - c.cs = pdf_add_colorspace(p, &cs, pdc_true); + if (drawmode == pdf_stroke || drawmode == pdf_fillstroke) + { + pdf_color *strokecolor = pdf_get_cstate(p, pdf_stroke); + + if (p->colorspaces[strokecolor->cs].type == PatternCS) + pdc_error(p->pdc, PDF_E_COLOR_INVALPATT, 0, 0, 0, 0); + + cstroke.val.pattern = (int) c1; + cs.val.pattern.base = strokecolor->cs; + cstroke.cs = pdf_add_colorspace(p, &cs, pdc_true); + } + + if (drawmode == pdf_fill || drawmode == pdf_fillstroke) + { + pdf_color *fillcolor = pdf_get_cstate(p, pdf_fill); + + if (p->colorspaces[fillcolor->cs].type == PatternCS) + pdc_error(p->pdc, PDF_E_COLOR_INVALPATT, 0, 0, 0, 0); + + cs.val.pattern.base = fillcolor->cs; + c.cs = pdf_add_colorspace(p, &cs, pdc_true); + } } break; + case color_iccbasedgray: + case color_iccbasedrgb: + case color_iccbasedcmyk: + case color_lab: + pdc_error(p->pdc, PDF_E_UNSUPP_ICCBASEDCOLOR, 0, 0, 0, 0); + break; } if (fcolor == NULL) - pdf_set_color_values(p, &c, (pdf_drawmode) drawmode); + { + if (colortype != color_pattern) + cstroke = c; + pdf_set_color_values(p, &c, &cstroke, (pdf_drawmode) drawmode); + } else + { *fcolor = c; + } } static const pdc_keyconn pdf_fstype_keylist[] = diff --git a/src/pdflib/pdflib/p_color.h b/src/pdflib/pdflib/p_color.h index d8a0fa8..4a1f584 100644 --- a/src/pdflib/pdflib/p_color.h +++ b/src/pdflib/pdflib/p_color.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_color.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_color.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib color definitions * diff --git a/src/pdflib/pdflib/p_defopt.h b/src/pdflib/pdflib/p_defopt.h index 6c4a862..f8174c4 100644 --- a/src/pdflib/pdflib/p_defopt.h +++ b/src/pdflib/pdflib/p_defopt.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_defopt.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_defopt.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib shared option definitions and structures * @@ -29,6 +29,7 @@ #define PDF_RETURN_BOXFULL "_boxfull" #define PDF_RETURN_NEXTPAGE "_nextpage" #define PDF_RETURN_STOP "_stop" +#define PDF_RETURN_ATMARK "_mark%d" typedef enum { @@ -146,7 +147,7 @@ typedef struct } pdf_fit_options; -typedef struct pdf_fittext_s pdf_fittext; +typedef struct pdf_fitres_s pdf_fitres; /* font option definitions */ @@ -155,6 +156,7 @@ typedef struct pdf_fittext_s pdf_fittext; #define PDF_SUBSETTING_FLAG PDC_OPT_UNSUPP #define PDF_AUTOCIDFONT_FLAG PDC_OPT_UNSUPP #define PDF_EMBEDOPENTYPE_FLAG PDC_OPT_UNSUPP +#define PDF_SKIPPOSTTABLE_FLAG PDC_OPT_UNSUPP #define PDF_CHARREF_FLAG PDC_OPT_UNSUPP #define PDF_ESCAPESEQU_FLAG PDC_OPT_UNSUPP #define PDF_GLYPHCHECK_FLAG PDC_OPT_UNSUPP @@ -192,7 +194,7 @@ typedef struct pdf_fittext_s pdf_fittext; 0.0, 0.0, pdf_fontstyle_pdfkeylist}, \ \ /* deprecated */ \ - {"fontwarning", pdc_booleanlist, PDC_OPT_NONE, 1, 1, \ + {"fontwarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, 0.0, NULL}, \ \ {"monospace", pdc_integerlist, PDC_OPT_NONE, 1, 1, \ @@ -227,6 +229,12 @@ typedef struct pdf_fittext_s pdf_fittext; \ {"embedopentype", pdc_booleanlist, PDF_EMBEDOPENTYPE_FLAG, 1, 1, \ 0.0, 0.0, NULL}, \ +\ + {"skipposttable", pdc_booleanlist, PDF_SKIPPOSTTABLE_FLAG, 1, 1, \ + 0.0, 0.0, NULL}, \ +\ + {"dropcorewidths", pdc_booleanlist, PDC_OPT_NONE, 1, 1, \ + 0.0, 0.0, NULL}, \ \ {"keepnative", pdc_booleanlist, PDF_KEEPNATIVE_FLAG, 1, 1, \ 0.0, 0.0, NULL}, \ @@ -255,7 +263,7 @@ typedef struct pdf_fittext_s pdf_fittext; PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, \ \ /* deprecated */ \ - {"glyphwarning", pdc_booleanlist, PDC_OPT_NONE, 1, 1, \ + {"glyphwarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, 0.0, NULL}, \ \ {"fillcolor", pdc_stringlist, PDC_OPT_NONE, 1, 5, \ @@ -317,15 +325,15 @@ typedef struct pdf_fittext_s pdf_fittext; PDC_FLOAT_MIN, PDC_FLOAT_MAX, pdf_underlineposition_keylist}, \ \ /* deprecated */ \ - {"weblink", pdc_stringlist, PDC_OPT_NONE, 1, 1, \ + {"weblink", pdc_stringlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, PDC_INT_MAX, NULL}, \ \ /* deprecated */ \ - {"locallink", pdc_stringlist, PDC_OPT_NONE, 1, 1, \ + {"locallink", pdc_stringlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, PDC_INT_MAX, NULL}, \ \ /* deprecated */ \ - {"pdflink", pdc_stringlist, PDC_OPT_NONE, 1, 1, \ + {"pdflink", pdc_stringlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, PDC_INT_MAX, NULL}, \ \ {"charref", pdc_booleanlist, PDF_CHARREF_FLAG, 1, 1, \ @@ -359,7 +367,7 @@ typedef struct pdf_fittext_s pdf_fittext; 0.0, 0.0, NULL}, \ \ /* deprecated */ \ - {"imagewarning", pdc_booleanlist, PDC_OPT_NONE, 1, 1, \ + {"imagewarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, \ 0.0, 0.0, NULL}, \ \ {"dpi", pdc_scalarlist, PDC_OPT_NONE, 1, 2, \ @@ -459,7 +467,7 @@ void pdf_init_text_options(PDF *p, pdf_text_options *to); void pdf_get_text_options(PDF *p, pdf_text_options *to, pdc_resopt *resopts); pdc_resopt *pdf_parse_fittextline_optlist(PDF *p, pdf_text_options *to, pdf_fit_options *fit, const char *optlist); -int pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, +pdc_bool pdf_fit_textline_internal(PDF *p, pdf_fitres *fitres, pdf_text_options *to, pdf_fit_options *fit, pdc_matrix *matrix); void pdf_calculate_textline_size(PDF *p, pdf_text_options *to, pdf_fit_options *fit, pdc_scalar *width, pdc_scalar *height); @@ -472,13 +480,13 @@ void pdf_draw_leader_text(PDF *p, pdc_scalar xstart, pdc_scalar ybase, pdf_text_options *to); int pdf_get_approximate_uvlist(PDF *p, pdf_font *currfont, - pdc_encodingvector *ev, int usv, pdc_bool replace, pdc_ushort *uvlist, - pdc_ushort *cglist); + pdc_encodingvector *ev, int usv, pdc_bool replace, pdf_fitres *fitres, + pdc_ushort *uvlist, pdc_ushort *cglist); void pdf_get_input_textformat(pdf_font *currfont, pdc_text_format *intextformat, int *convflags); -int pdf_check_textstring(PDF *p, const char *text, int len, int flags, - pdf_text_options *to, pdc_byte **outtext, int *outlen, int *outcharlen, - pdc_bool verbose); +pdc_bool pdf_check_textstring(PDF *p, const char *text, int len, int flags, + pdf_text_options *to, pdf_fitres *fittext, pdc_byte **outtext, + int *outlen, int *outcharlen, pdc_bool verbose); pdc_scalar pdf_calculate_textsize(PDF *p, const pdc_byte *text, int len, int charlen, pdf_text_options *to, int breakchar, pdc_scalar *height, pdc_bool verbose); diff --git a/src/pdflib/pdflib/p_document.c b/src/pdflib/pdflib/p_document.c index 4c00aa3..f9de980 100644 --- a/src/pdflib/pdflib/p_document.c +++ b/src/pdflib/pdflib/p_document.c @@ -10,15 +10,13 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_document.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_document.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib document related routines * */ -#undef MVS_TEST - #define P_DOCUMENT_C /* For checking the beta expiration date */ @@ -33,6 +31,8 @@ +#include "pc_strconst.h" + #if (defined(WIN32) || defined(OS2)) && !defined(WINCE) #include @@ -62,8 +62,8 @@ typedef enum open_bookmarks, open_thumbnails, open_fullscreen, - open_attachments - + open_attachments, + open_layers } pdf_openmode; @@ -74,7 +74,7 @@ static const pdc_keyconn pdf_openmode_keylist[] = {"thumbnails", open_thumbnails}, {"fullscreen", open_fullscreen}, {"attachments", open_attachments}, - + {"layers", open_layers}, {NULL, 0} }; @@ -86,7 +86,7 @@ static const pdc_keyconn pdf_openmode_pdfkeylist[] = {"UseThumbs", open_thumbnails}, {"FullScreen", open_fullscreen}, {"UseAttachments", open_attachments}, - + {"UseOC", open_layers}, {NULL, 0} }; @@ -125,7 +125,7 @@ static const pdc_keyconn pdf_nonfullscreen_keylist[] = {"none", open_none}, {"bookmarks", open_bookmarks}, {"thumbnails", open_thumbnails}, - + {"layers", open_layers}, {NULL, 0} }; @@ -235,7 +235,7 @@ static const pdc_keyconn pdc_permissions_keylist[] = {"pdfx", pdc_keywordlist, PDF_ICC_FLAG, 1, 1, \ 0.0, 0.0, pdf_pdfx_keylist}, \ \ - {"compatibility", pdc_keywordlist, PDC_OPT_IGNOREIF1, 1, 1, \ + {"compatibility", pdc_keywordlist, PDC_OPT_NONE, 1, 1, \ 0.0, 0.0, pdf_compatibility_keylist}, \ \ {"flush", pdc_keywordlist, PDC_OPT_NONE, 1, 1, \ @@ -284,9 +284,11 @@ static const pdc_keyconn pdc_permissions_keylist[] = {"tempdirname", pdc_stringlist, PDF_LINEARIZE_FLAG, 1, 1, \ 4.0, 400.0, NULL}, \ - #if defined(MVS) || defined(MVS_TEST) #define PDF_DOCUMENT_OPTIONS10 \ +\ + {"filemode", pdc_stringlist, PDC_OPT_NONE, 1, 1, \ + 0.0, PDF_MAX_NAMESTRING, NULL}, \ \ {"recordsize", pdc_integerlist, PDF_LINEARIZE_FLAG, 1, 1, \ 0.0, 32768.0, NULL}, \ @@ -351,6 +353,11 @@ struct pdf_document_s +#if defined(MVS) || defined(MVS_TEST) + char *fopenparams; /* additional fopen() parameter string */ + char **tempfilenames; /* 2 temporary file names */ +#endif + pdc_bool moddate; /* modified date will be created */ char lang[PDF_MAX_LANGCODE + 1]; /* default natural language */ char *action; /* document actions */ @@ -394,6 +401,11 @@ pdf_init_get_document(PDF *p) +#if defined(MVS) || defined(MVS_TEST) + doc->fopenparams = NULL; + doc->tempfilenames = NULL; +#endif + doc->moddate = pdc_false; doc->lang[0] = 0; doc->action = NULL; @@ -452,6 +464,20 @@ pdf_cleanup_document_internal(PDF *p) +#if defined(MVS) || defined(MVS_TEST) + if (doc->fopenparams) + { + pdc_free(p->pdc, doc->fopenparams); + doc->fopenparams = NULL; + } + + if (doc->tempfilenames) + { + pdc_cleanup_optstringlist(p->pdc, doc->tempfilenames, 2); + doc->tempfilenames = NULL; + } +#endif + if (doc->searchindexname) { @@ -607,6 +633,8 @@ pdf_parse_and_write_viewerpreferences(PDF *p, const char *optlist, if (pdc_get_optvalues("nonfullscreenpagemode", resopts, &inum, NULL) && inum != (int) open_none) { + if (inum == (int) open_layers) + pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0); writevpdict = pdc_true; if (output) pdc_printf(p->out, "/NonFullScreenPageMode/%s\n", pdc_get_keyword(inum, pdf_openmode_pdfkeylist)); @@ -687,7 +715,8 @@ pdf_parse_and_write_viewerpreferences(PDF *p, const char *optlist, pdc_printf(p->out, "/PrintPageRange"); pdc_begin_array(p->out); for (i = 0; i < nv; i++) - pdc_printf(p->out, "%d ", prs[i]); + /* because of bug #1623: -1 */ + pdc_printf(p->out, "%d ", prs[i] - 1); pdc_end_array(p->out); } } @@ -718,7 +747,8 @@ static const pdc_defopt pdf_search_options[] = }; static void -pdf_parse_search_optlist(PDF *p, const char *optlist) +pdf_parse_search_optlist(PDF *p, const char *optlist, + pdc_encoding htenc, int htcp) { pdf_document *doc = p->document; pdc_resopt *resopts = NULL; @@ -727,9 +757,9 @@ pdf_parse_search_optlist(PDF *p, const char *optlist) resopts = pdc_parse_optionlist(p->pdc, optlist, pdf_search_options, NULL, pdc_true); - if (pdc_get_optvalues("filename", resopts, NULL, NULL)) - doc->searchindexname = - (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); + if (pdf_get_opt_textlist(p, "filename", resopts, htenc, htcp, + pdc_true, NULL, &doc->searchindexname, NULL)) + pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); if (pdc_get_optvalues("indextype", resopts, NULL, NULL)) doc->searchindextype = @@ -759,6 +789,11 @@ pdf_write_search_indexes(PDF *p) pdc_puts(p->out, "/Type/Filespec"); pdc_puts(p->out, "/F"); pdf_put_pdffilename(p, doc->searchindexname); + if (p->compatibility >= PDC_1_7) + { + pdc_printf(p->out, "/UF"); + pdf_put_pdfunifilename(p, doc->searchindexname); + } pdc_end_dict(p->out); /* Index */ pdc_end_dict(p->out); /* Indexes */ pdc_end_array(p->out); @@ -853,9 +888,9 @@ pdf_parse_attachments_optlist(PDF *p, char **optlists, int ns, resopts = pdc_parse_optionlist(p->pdc, optlists[i], pdf_attachments_options, &cdata, pdc_true); - if (pdc_get_optvalues("filename", resopts, NULL, NULL)) - fat->filename = - (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); + if (pdf_get_opt_textlist(p, "filename", resopts, htenc, htcp, + pdc_true, NULL, &fat->filename, NULL)) + pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); if (pdf_get_opt_textlist(p, "description", resopts, htenc, htcp, pdc_true, NULL, &fat->description, NULL)) @@ -881,6 +916,7 @@ pdf_write_attachments(PDF *p) static const char fn[] = "pdf_write_attachments"; pdf_document *doc = p->document; pdc_id attachment_id, obj_id; + const char *basename; char *name; int i; @@ -894,10 +930,19 @@ pdf_write_attachments(PDF *p) attachment_id = pdc_begin_obj(p->out, PDC_NEW_ID); pdc_begin_dict(p->out); /* FS dict */ + /* see bug #1439 */ + basename = pdc_file_strip_dirs(fat->filename); + pdc_puts(p->out, "/Type/Filespec\n"); pdc_printf(p->out, "/F"); - pdf_put_pdffilename(p, fat->filename); + pdf_put_pdffilename(p, basename); pdc_puts(p->out, "\n"); + if (p->compatibility >= PDC_1_7) + { + pdc_printf(p->out, "/UF"); + pdf_put_pdfunifilename(p, basename); + pdc_puts(p->out, "\n"); + } if (fat->description != NULL) { @@ -921,7 +966,7 @@ pdf_write_attachments(PDF *p) /* insert name in tree */ if (fat->name == NULL) - name = pdc_strdup_ext(p->pdc, fat->filename, 0, fn); + name = pdc_strdup_ext(p->pdc, basename, 0, fn); else name = pdc_strdup_ext(p->pdc, fat->name, 0, fn); pdf_insert_name(p, name, names_embeddedfiles, attachment_id); @@ -1066,6 +1111,10 @@ pdf_get_document_common_options(PDF *p, pdc_resopt *resopts, int fcode) if (pdc_get_optvalues("openmode", resopts, &inum, NULL)) doc->openmode = (pdf_openmode) inum; + + if (doc->openmode == open_layers) + pdc_error(p->pdc, PDF_E_UNSUPP_LAYER, 0, 0, 0, 0); + if (doc->openmode == open_attachments && p->compatibility < PDC_1_6) pdc_error(p->pdc, PDC_E_OPT_VERSION, "openmode=attachments", pdc_get_pdfversion(p->pdc, p->compatibility), 0, 0); @@ -1101,7 +1150,7 @@ pdf_get_document_common_options(PDF *p, pdc_resopt *resopts, int fcode) } if (pdc_get_optvalues("search", resopts, NULL, &strlist)) - pdf_parse_search_optlist(p, strlist[0]); + pdf_parse_search_optlist(p, strlist[0], htenc, htcp); pdc_get_optvalues("moddate", resopts, &doc->moddate, NULL); @@ -1187,6 +1236,14 @@ pdf_begin_document_internal(PDF *p, const char *optlist, pdc_bool callback) +#if defined(MVS) || defined(MVS_TEST) + if (pdc_get_optvalues("filemode", resopts, NULL, NULL)) + { + doc->fopenparams = + (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); + } +#endif + n_groups = pdc_get_optvalues("groups", resopts, NULL, &groups); } @@ -1210,23 +1267,6 @@ pdf_begin_document_internal(PDF *p, const char *optlist, pdc_bool callback) pdf_get_document_common_options(p, resopts, PDF_FC_BEGIN_DOCUMENT); - /* deprecated */ - p->bookmark_dest = pdf_init_destination(p); - - pdf_init_images(p); - pdf_init_xobjects(p); - pdf_init_fonts(p); - pdf_init_outlines(p); - pdf_init_annot_params(p); - pdf_init_colorspaces(p); - pdf_init_pattern(p); - pdf_init_shadings(p); - pdf_init_extgstates(p); - - - - - /* create document digest */ pdc_init_digest(p->out); @@ -1268,23 +1308,59 @@ pdf_begin_document_internal(PDF *p, const char *optlist, pdc_bool callback) oc.filename = ""; +#if defined(MVS) || defined(MVS_TEST) + oc.fopenparams = doc->fopenparams; +#endif - if (!pdc_init_output((void *) p, p->out, doc->compatibility, &oc)) + + PDC_TRY(p->pdc) { - if (oc.filename && *oc.filename) + if (!pdc_init_output((void *) p, p->out, doc->compatibility, &oc)) { - pdc_set_fopen_errmsg(p->pdc, - pdc_get_fopen_errnum(p->pdc, PDC_E_IO_WROPEN), "PDF ", - pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, oc.filename)); + if (oc.filename && *oc.filename) + { + pdc_set_fopen_errmsg(p->pdc, + pdc_get_fopen_errnum(p->pdc, PDC_E_IO_WROPEN), "PDF ", + pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, + oc.filename)); + if (verbose) + { + pdf_cleanup_document_internal(p); + PDC_RETHROW(p->pdc); + } + } - if (verbose) - pdc_error(p->pdc, -1, 0, 0, 0, 0); + pdf_cleanup_document_internal(p); + PDC_EXIT_TRY(p->pdc); + return -1; } - + } + PDC_CATCH(p->pdc) + { pdf_cleanup_document_internal(p); + if (verbose) + PDC_RETHROW(p->pdc); + return -1; } + /* deprecated */ + p->bookmark_dest = pdf_init_destination(p); + + pdf_init_images(p); + pdf_init_xobjects(p); + pdf_init_fonts(p); + pdf_init_outlines(p); + pdf_init_annot_params(p); + pdf_init_colorspaces(p); + pdf_init_pattern(p); + pdf_init_shadings(p); + pdf_init_extgstates(p); + + + + + /* Write the constant /ProcSet array once at the beginning */ p->procset_id = pdc_begin_obj(p->out, PDC_NEW_ID); pdc_puts(p->out, "[/PDF/ImageB/ImageC/ImageI/Text]\n"); @@ -1323,8 +1399,8 @@ pdf__begin_document(PDF *p, const char *filename, int len, const char *optlist) * The Intel version of the Metrowerks compiler doesn't have setmode(). */ #if !defined(__MWERKS__) && (defined(WIN32) || defined(OS2)) -#if defined WINCE - _setmode(fileno(fp), _O_BINARY); +#if !defined(__BORLANDC__) && !defined(OS2) + _setmode(_fileno(fp), _O_BINARY); #else setmode(fileno(fp), O_BINARY); #endif @@ -1466,58 +1542,121 @@ pdf_get_id_from_nametree(PDF *p, pdf_nametree_type type, const char *name) return PDC_BAD_ID; } +#define PDF_TREE_LEAF_SIZE 32 + +static char * +pdf_get_numbered_name(PDF *p, pdf_nametree_type type, int ia, int *in, int nn) +{ + int i, j = ia, n = 0; + + for (i = ia; i < p->names_number; i++) + { + if (p->names[i].type == type) + { + n++; + if (n == nn) + { + if (in != NULL) + *in = i; + + return p->names[i].name; + } + j = i; + } + } + + return (in != NULL) ? NULL : p->names[j].name; +} + static pdc_id pdf_write_names(PDF *p, pdf_nametree_type type) { + static const char fn[] = "pdf_write_names"; pdc_id ret = PDC_BAD_ID; - int i, ibeg = -1, iend = 0; + int i, nnames = 0; for (i = 0; i < p->names_number; i++) { if (p->names[i].type == type) { - if (ibeg == -1) - ibeg = i; - iend = i; + nnames++; } } - if (ibeg > -1) + if (nnames) { - ret = pdc_begin_obj(p->out, PDC_NEW_ID); /* Names object */ + char *name; + int nleafs, nnodes, ik, il, ia, nn; + pdc_id *idlist; - pdc_begin_dict(p->out); /* Node dict */ + nnodes = nnames / PDF_TREE_LEAF_SIZE; + if (!nnodes) + nleafs = nnames; + else + nleafs = PDF_TREE_LEAF_SIZE; + if (nnames > nnodes * nleafs) + nnodes++; - /* - * Because we have only the 1 tree - the root tree - * the /Limits entry is not allowed (see chapter 3.8.5). - * - pdc_puts(p->out, "/Limits"); + idlist = (pdc_id *) pdc_malloc(p->pdc, + (size_t) (nnodes * sizeof(pdc_id)), fn); + + for (i = 0; i < nnodes; i++) + idlist[i] = pdc_alloc_id(p->out); + + ret = pdc_begin_obj(p->out, PDC_NEW_ID); /* Names object */ + pdc_begin_dict(p->out); + + pdc_puts(p->out, "/Kids"); pdc_begin_array(p->out); - pdf_put_hypertext(p, p->names[ibeg].name); - pdf_put_hypertext(p, p->names[iend].name); + for (i = 0; i < nnodes; i++) + pdc_objref_c(p->out, idlist[i]); pdc_end_array(p->out); - */ - pdc_puts(p->out, "/Names"); - pdc_begin_array(p->out); + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* Names object */ - for (i = ibeg; i <= iend; i++) + ia = 0; + for (ik = 0; ik < nnodes; ik++) { - if (p->names[i].type == type) + pdc_begin_obj(p->out, idlist[ik]); + pdc_begin_dict(p->out); + + pdc_puts(p->out, "/Limits"); + pdc_begin_array(p->out); + + name = pdf_get_numbered_name(p, type, ia, NULL, 1); + pdc_put_pdfstring(p->out, name, pdc_strlen(name)); + + nn = (ik == nnodes - 1) ? p->names_number : nleafs; + name = pdf_get_numbered_name(p, type, ia, NULL, nn); + pdc_put_pdfstring(p->out, name, pdc_strlen(name)); + + pdc_end_array(p->out); + + pdc_puts(p->out, "/Names"); + pdc_begin_array(p->out); + + for (il = 0; il < nn; il++) { - pdf_put_hypertext(p, p->names[i].name); - pdc_objref(p->out, "", p->names[i].obj_id); + name = pdf_get_numbered_name(p, type, ia, &ia, 1); + if (name == NULL) + break; + + pdc_put_pdfstring(p->out, name, pdc_strlen(name)); + pdc_objref(p->out, "", p->names[ia].obj_id); + ia++; } - } - pdc_end_array(p->out); + pdc_end_array(p->out); - pdc_end_dict(p->out); /* Node dict */ + pdc_end_dict(p->out); + pdc_end_obj(p->out); + } - pdc_end_obj(p->out); /* Names object */ + pdc_free(p->pdc, idlist); } + return ret; } @@ -1527,7 +1666,7 @@ name_compare( const void* a, const void* b) pdf_name *p1 = (pdf_name *) a; pdf_name *p2 = (pdf_name *) b; - return strcmp(p1->name, p2->name); + return pdc_wstrcmp(p1->name, p2->name); } /* ---------------------------- write document -------------------------- */ @@ -1557,18 +1696,30 @@ pdf_write_pages_and_catalog(PDF *p, pdc_id orig_root_id) /* name tree dictionaries */ if (p->names_number) { + char *name; + int i, outlen, inlen; + + for (i = 0; i < p->names_number; i++) + { + inlen = strlen(p->names[i].name); + name = pdf_convert_pdfstring(p, p->names[i].name, inlen, + PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES, &outlen); + + if (name != p->names[i].name) + pdc_free(p->pdc, p->names[i].name); + + p->names[i].name = name; + } qsort(p->names, (size_t) p->names_number, sizeof(pdf_name), name_compare); - names_dests_id = pdf_write_names(p, names_dests); names_javascript_id = pdf_write_names(p, names_javascript); names_ap_id = pdf_write_names(p, names_ap); names_embeddedfiles_id = pdf_write_names(p, names_embeddedfiles); } - (void) forpdfa; @@ -1718,6 +1869,8 @@ pdf_write_document(PDF *p) void pdf_cleanup_document(PDF *p) { + pdf_cleanup_pages(p); + if (PDF_GET_STATE(p) != pdf_state_object) { /* Don't call pdc_cleanup_output() here because we may still need @@ -1727,7 +1880,7 @@ pdf_cleanup_document(PDF *p) pdf_delete_actions(p); pdf_cleanup_destination(p, p->bookmark_dest); /* deprecated */ - pdf_cleanup_pages(p); + p->bookmark_dest = NULL; pdf_cleanup_document_internal(p); pdf_cleanup_info(p); pdf_cleanup_fonts(p); @@ -1937,3 +2090,7 @@ pdf_set_viewerpreference(PDF *p, const char *viewerpreference) + + + + diff --git a/src/pdflib/pdflib/p_draw.c b/src/pdflib/pdflib/p_draw.c index dc9271e..f1fc806 100644 --- a/src/pdflib/pdflib/p_draw.c +++ b/src/pdflib/pdflib/p_draw.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_draw.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_draw.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib drawing routines * diff --git a/src/pdflib/pdflib/p_encoding.c b/src/pdflib/pdflib/p_encoding.c index af24792..162fd8d 100644 --- a/src/pdflib/pdflib/p_encoding.c +++ b/src/pdflib/pdflib/p_encoding.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_encoding.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_encoding.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib encoding handling routines * @@ -70,8 +70,7 @@ pdf__encoding_set_char(PDF *p, const char *encoding, int slot, reg_glyphname = pdc_unicode2glyphname(p->pdc, (pdc_ushort) uv); if (reg_glyphname) { - if (strcmp(reg_glyphname, glyphname) && - p->debug[(int) 'F'] == pdc_true) + if (strcmp(reg_glyphname, glyphname)) { pdc_warning(p->pdc, PDF_E_ENC_BADGLYPH, glyphname, @@ -87,8 +86,7 @@ pdf__encoding_set_char(PDF *p, const char *encoding, int slot, if (retval > -1) { reg_uv = (pdc_ushort) retval; - if (reg_uv && reg_uv != (pdc_ushort) uv && - p->debug[(int) 'F'] == pdc_true) + if (reg_uv && reg_uv != (pdc_ushort) uv) { pdc_error(p->pdc, PDF_E_ENC_BADUNICODE, pdc_errprintf(p->pdc, "%04X", uv), glyphname, @@ -155,6 +153,14 @@ pdf_get_hypertextencoding_param(PDF *p, int *codepage) if (codepage) *codepage = p->hypertextcodepage; + pdc_logg_cond(p->pdc, 3, trc_encoding, + "\t\thypertextformat=%d\n" + "\t\thypertextencoding=%s\n" + "\t\thypertextcodepage=%d\n", + p->hypertextformat, + pdc_get_user_encoding(p->pdc, p->hypertextencoding), + p->hypertextcodepage); + return p->hypertextencoding; } diff --git a/src/pdflib/pdflib/p_fields.c b/src/pdflib/pdflib/p_fields.c index 4900b3b..9b7b4b9 100644 --- a/src/pdflib/pdflib/p_fields.c +++ b/src/pdflib/pdflib/p_fields.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_fields.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_fields.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib form fields handling routines * diff --git a/src/pdflib/pdflib/p_filter.c b/src/pdflib/pdflib/p_filter.c index d5a11a6..4121d02 100644 --- a/src/pdflib/pdflib/p_filter.c +++ b/src/pdflib/pdflib/p_filter.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_filter.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_filter.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Compressed and uncompressed stream output * diff --git a/src/pdflib/pdflib/p_font.c b/src/pdflib/pdflib/p_font.c index 5dfce77..4aec8a6 100644 --- a/src/pdflib/pdflib/p_font.c +++ b/src/pdflib/pdflib/p_font.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_font.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_font.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib font handling routines * @@ -132,6 +132,10 @@ pdf_init_font(PDF *p, pdf_font *font, pdf_font_options *fo) font->expectglyphs = pdc_false; font->iscidfont = pdc_false; + font->widths = NULL; + font->numwidths = 0; + font->konlydef = pdc_false; + } void @@ -182,6 +186,12 @@ pdf_cleanup_font(PDF *p, pdf_font *font) font->t3font = NULL; } + if (font->widths != NULL) + { + pdc_free(p->pdc, font->widths); + font->widths = NULL; + } + } void @@ -425,8 +435,9 @@ pdf_get_fontname_core(pdf_font *font, const char *fontname, pdc_bool checktimes) static pdc_bool pdf_get_metrics_core(PDF *p, pdf_font *font, const char *fontname, - pdc_encoding enc, pdc_bool checktimes) + const char *outfilename, pdc_encoding enc, pdc_bool checktimes) { + static const char fn[] = "pdf_get_metrics_core"; const char *fname = NULL; const fnt_font_metric *ftm; @@ -435,10 +446,16 @@ pdf_get_metrics_core(PDF *p, pdf_font *font, const char *fontname, { fontname = fname; font->opt.fontstyle = fnt_Normal; + + if (font->apiname != NULL) + { + pdc_free(p->pdc, font->apiname); + font->apiname = pdc_strdup_ext(p->pdc, fontname, 0, fn); + } } ftm = fnt_get_core_metric(fontname); - if (ftm != NULL) + if (ftm != NULL && (!font->opt.embedding || outfilename != NULL)) { pdc_logg_cond(p->pdc, 1, trc_font, "\tLoading metrics data for core font \"%s\":\n", fontname); @@ -813,6 +830,7 @@ pdf_init_font_options(PDF *p, pdf_font_options *fo) fo->xheight = 0; fo->linegap = 0; fo->auxiliary = pdc_false; + fo->dropcorewidths = pdc_false; } @@ -908,10 +926,12 @@ pdf_get_font_options(PDF *p, pdf_font_options *fo, pdc_resopt *resopts) if (pdc_get_optvalues("linegap", resopts, &fo->linegap, NULL)) fo->mask |= (1L << fo_linegap); + + pdc_get_optvalues("dropcorewidths", resopts, &fo->dropcorewidths, NULL); } int -pdf__load_font(PDF *p, const char *fontname, int inlen, +pdf__load_font(PDF *p, const char *fontname, int len, const char *encoding, const char *optlist) { int slot; @@ -920,14 +940,11 @@ pdf__load_font(PDF *p, const char *fontname, int inlen, if (encoding == NULL || *encoding == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "encoding", 0, 0, 0); - if (fontname == NULL) - pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); - /* initialize */ pdf_init_font_options(p, &fo); /* Converting fontname */ - fo.fontname = (char *) pdf_convert_name(p, fontname, inlen, + fo.fontname = (char *) pdf_convert_name(p, fontname, len, PDC_CONV_WITHBOM); if (fo.fontname == NULL || *fo.fontname == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); @@ -997,6 +1014,7 @@ pdf_check_font_embedding(PDF *p, pdf_font *font, const char *fontname) int pdf_load_font_internal(PDF *p, pdf_font_options *fo) { + pdc_bool logg1 = pdc_logg_is_enabled(p->pdc, 1, trc_font); pdc_bool logg2 = pdc_logg_is_enabled(p->pdc, 2, trc_font); const char *fontname; const char *encoding; @@ -1014,6 +1032,17 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) pdc_bool retval = pdc_false; int slot = -1, i; + /* register and skip at sign '@' in font name */ + if (fo->fontname[0] == PDF_VERTICAL_SIGN || + (pdc_is_utf8_bytecode(fo->fontname) && + fo->fontname[3] == PDF_VERTICAL_SIGN)) + { + + i = (fo->fontname[0] == PDF_VERTICAL_SIGN) ? 1 : 4; + len = strlen(fo->fontname) + 1 - i; + memmove(&fo->fontname[i - 1], &fo->fontname[i], len); + } + /* host or UTF-8 encoded font name without BOM */ fontname_p = pdc_utf8_to_hostbytes(p->pdc, pdc_false, fo->fontname); if (fontname_p == NULL) @@ -1023,10 +1052,14 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) else { fontname = pdc_utf8strprint(p->pdc, fontname_p); - pdc_free(p->pdc, fontname_p); + pdc_free_tmp(p->pdc, fontname_p); } fontname_p = NULL; + if (logg1) + pdc_logg(p->pdc, "\tCanonical font name: \"%s\"\n", + fontname); + /* font encoding */ encoding = fo->encoding; encoding_aux = encoding; @@ -1047,14 +1080,22 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) /* UTF-8 font name with BOM */ font->ft.utf8name = pdc_strdup(p->pdc, fo->fontname); - pdc_logg_cond(p->pdc, 1, trc_font, "\tFont UTF-8 name: \"%s\"\n", - font->ft.utf8name); + if (logg1) + pdc_logg(p->pdc, "\tFont UTF-8 name: \"%s\"\n", + font->ft.utf8name); /* specified encoding name */ font->encapiname = pdc_strdup(p->pdc, encoding); /* search for a registered encoding */ enc = pdc_find_encoding(p->pdc, encoding); + + if (enc == pdc_unicode || enc == pdc_glyphid) + { + pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_UNICODE, 0, 0, 0, 0); + goto PDF_PREMATURE_EXIT; + } + if (enc == pdc_invalidenc || enc == pdc_unicode) { /* search for a predefined CMap and registered fonts */ @@ -1112,8 +1153,8 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) * is found, make a copy in a new slot and attach the requested encoding. */ - pdc_logg_cond(p->pdc, 1, trc_font, - "\tFont will be searched in the PDFlib font cache\n"); + if (logg1) + pdc_logg(p->pdc, "\tFont will be searched in the PDFlib font cache\n"); for (slot = 0; slot < p->fonts_number; slot++) { if (p->fonts[slot].obj_id == PDC_BAD_ID && @@ -1233,8 +1274,8 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) } slot = -1; - pdc_logg_cond(p->pdc, 1, trc_font, - "\tFont not found in the PDFlib font cache\n"); + if (logg1) + pdc_logg(p->pdc, "\tFont not found in the PDFlib font cache\n"); /* embedding check */ if (!pdf_check_font_embedding(p, font, fontname)) @@ -1269,18 +1310,11 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) } mmparam[2] = '\0'; /* strip the parameter from the master name */ } - - /* Font for vertical writing mode */ fontname_p = mastername; - if (mastername[0] == '@') - { - font->ft.vertical = pdc_true; - fontname_p = &mastername[1]; - } /* protocol */ - pdc_logg_cond(p->pdc, 1, trc_font, - "\tPDFlib font name: \"%s\"\n", fontname_p); + if (logg1) + pdc_logg(p->pdc, "\tPDFlib font name: \"%s\"\n", fontname_p); /* Font file search hierarchy * - Check "FontOutline" resource entry and check TrueType font @@ -1293,6 +1327,14 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) retval = pdc_false; while (1) { + if (font->opt.auxiliary) + { + /* only in-core fonts are possible */ + retval = pdf_get_metrics_core(p, font, fontname_p, "", enc, + pdc_false); + break; + } + #ifdef PDF_TRUETYPE_SUPPORTED /* Check specified TrueType file */ filename = pdc_find_resource(p->pdc, "FontOutline", fontname_p); @@ -1350,22 +1392,26 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) - /* Check available in-core metrics */ - retval = pdf_get_metrics_core(p, font, fontname_p, enc, pdc_false); + /* Check available in-core metrics - will be skipped + * in the case of embedding and missing outline file + * to check the possibility of an host font in the next step. + */ + retval = pdf_get_metrics_core(p, font, fontname_p, outfilename, enc, + pdc_false); if (retval != pdc_undef) break; retval = pdc_false; /* Check available in-core metrics */ - retval = pdf_get_metrics_core(p, font, fontname_p, enc, pdc_true); + retval = pdf_get_metrics_core(p, font, fontname_p, "", enc, pdc_true); if (retval != pdc_undef) break; retval = pdc_false; /* Searching for a metric file */ - pdc_logg_cond(p->pdc, 1, trc_font, - "\tSearching for font metrics data file:\n"); + if (logg1) + pdc_logg(p->pdc, "\tSearching for font metrics data file:\n"); filename = testfilename; for (i = 0; i < 100; i++) @@ -1420,9 +1466,10 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) { retval = pdc_false; - pdc_logg_cond(p->pdc, 1, trc_font, - "\tMetric data file for font \"%s\" not available\n", - fontname_p); + if (logg1) + pdc_logg(p->pdc, + "\tMetric data file for font \"%s\" not available\n", + fontname_p); pdc_set_errmsg(p->pdc, PDF_E_FONT_NOMETRICS, 0, 0, 0, 0); } @@ -1470,8 +1517,9 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) else { /* Searching font outline file */ - pdc_logg_cond(p->pdc, 1, trc_font, - "\tSearching for font outline data file:\n"); + if (logg1) + pdc_logg(p->pdc, + "\tSearching for font outline data file:\n"); outfilename = testfilename; for (i = 0; i < 100; i++) @@ -1506,25 +1554,33 @@ pdf_load_font_internal(PDF *p, pdf_font_options *fo) if (retval == pdc_undef) { retval = pdc_false; - pdc_set_errmsg(p->pdc, PDF_E_FONT_NOOUTLINE, 0, 0, 0, 0); + if (font->ft.m.type == fnt_Type1 || + font->ft.m.type == fnt_MMType1) + pdc_set_errmsg(p->pdc, PDF_E_FONT_NOOUTLINE_PS, + 0, 0, 0, 0); + else + pdc_set_errmsg(p->pdc, PDF_E_FONT_NOOUTLINE_TT, + 0, 0, 0, 0); } } if (retval == pdc_false) { - pdc_logg_cond(p->pdc, 1, trc_font, - "\tOutline data file for font \"%s\" not found\n", - fontname_p); + if (logg1) + pdc_logg(p->pdc, + "\tOutline data file for font \"%s\" not found\n", + fontname_p); } else { if (!font->ft.img) font->filename = font->ft.filename; - pdc_logg_cond(p->pdc, 1, trc_font, - "\tFont outline data file \"%s\" available\n", - font->filename ? - font->filename : font->ft.imgname); + if (logg1) + pdc_logg(p->pdc, + "\tFont outline data file \"%s\" available\n", + font->filename ? + font->filename : font->ft.imgname); } } } @@ -1644,6 +1700,38 @@ pdf_transform_fontwidths(PDF *p, pdf_font *font, pdc_encodingvector *evto, memcpy(font->ft.code2gid, code2gid, 256 * sizeof(pdc_ushort)); } +void +pdf_prepare_fontwidths(PDF *p, pdf_font *font, int nusedgids) +{ + + (void) p; + (void) nusedgids; + + if (font->towinansi != pdc_invalidenc || font->widths != NULL || + (font->iscidfont && (font->ft.isstdfont || font->opt.monospace))) + { + return; + } + + /* exchange widths pointer */ + if (!font->iscidfont && font->ft.enc != pdc_unicode) + { + font->widths = font->ft.m.widths; + font->numwidths = font->ft.m.numwidths; + font->ft.m.widths = NULL; + font->ft.m.numwidths = 0; + return; + } + + /* already defined or no basic data */ + if (font->ft.m.widths == NULL && font->ft.m.ciw == NULL + ) + { + return; + } + +} + static void @@ -1746,6 +1834,7 @@ pdf_put_font(PDF *p, pdf_font *font) /* save font struct members */ pdc_encodingvector *ev = NULL; pdc_encoding font_encoding = font->ft.enc; + pdc_encoding font_towinansi = font->towinansi; int font_numcodes = font->ft.numcodes; int font_codesize = font->codesize; @@ -1889,8 +1978,12 @@ pdf_put_font(PDF *p, pdf_font *font) enc = font->towinansi; font->ft.enc = enc; + font->towinansi = pdc_invalidenc; } + /* preparation for font widths array */ + pdf_prepare_fontwidths(p, font, nusedgids); + /* /FontDescriptor, /FirstChar, /LastChar, /Widths */ switch (fonttype) { @@ -1912,8 +2005,11 @@ pdf_put_font(PDF *p, pdf_font *font) { fontdescriptor_id = pdc_alloc_id(p->out); pdc_objref(p->out, "/FontDescriptor", fontdescriptor_id); - } + /* bug #1036 */ + if (font->ft.isstdfont == pdc_true && font->opt.dropcorewidths) + break; + } /* determine missing width. * Only for embedded fonts because of a bug in Acrobat, @@ -1922,19 +2018,19 @@ pdf_put_font(PDF *p, pdf_font *font) if (font->opt.embedding) { if (fonttype != fnt_Type3) - defwidth = font->ft.m.widths[0]; + defwidth = font->widths[0]; { for (i = 1; i < 255; i++) { - if (font->ft.m.widths[i] != defwidth) + if (font->widths[i] != defwidth) break; } if (i > 1) firstchar = i; for (i = 255; i > 0; i--) { - if (i == firstchar || font->ft.m.widths[i] != defwidth) + if (i == firstchar || font->widths[i] != defwidth) break; } lastchar = i; @@ -1952,7 +2048,7 @@ pdf_put_font(PDF *p, pdf_font *font) for (i = firstchar; i <= lastchar; i++) { pdc_printf(p->out, "%d", - (int) (font->ft.m.widths[i] / a + .5)); + (int) (font->widths[i] / a + .5)); if (i < 255) pdc_printf(p->out, "%s", ((i + 1) % 16) ? " " : "\n"); } @@ -2376,6 +2472,7 @@ pdf_put_font(PDF *p, pdf_font *font) /* restore font struct members */ font->ft.enc = font_encoding; + font->towinansi = font_towinansi; font->ft.numcodes = font_numcodes; font->codesize = font_codesize; @@ -2451,7 +2548,6 @@ void pdf_write_page_fonts(PDF *p) { int i, total = 0; - int bias = p->curr_ppt->fn_bias; /* This doesn't really belong here, but all modules which write * font resources also need this, so we include it here. @@ -2466,7 +2562,7 @@ pdf_write_page_fonts(PDF *p) if (p->fonts[i].used_on_current_page == pdc_true) total++; - if (total > 0 || bias) + if (total > 0) { pdc_puts(p->out, "/Font"); pdc_begin_dict(p->out); /* font resource dict */ @@ -2478,12 +2574,11 @@ pdf_write_page_fonts(PDF *p) { if (p->fonts[i].used_on_current_page == pdc_true) { p->fonts[i].used_on_current_page = pdc_false; /* reset */ - pdc_printf(p->out, "/F%d", bias + i); + pdc_printf(p->out, "/F%d", i); pdc_objref(p->out, "", p->fonts[i].obj_id); } } - if (!bias) pdc_end_dict(p->out); /* font resource dict */ } } @@ -2508,6 +2603,3 @@ pdf_mark_page_font(PDF *p, int ft) { p->fonts[ft].used_on_current_page = pdc_true; } - - - diff --git a/src/pdflib/pdflib/p_font.h b/src/pdflib/pdflib/p_font.h index 3dc4d91..3da2df4 100644 --- a/src/pdflib/pdflib/p_font.h +++ b/src/pdflib/pdflib/p_font.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_font.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_font.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Header file for the PDFlib font subsystem * @@ -30,6 +30,9 @@ /* minimal number of glyphs for appropriate encoding */ #define PDF_MIN_GLYPHS 5 +/* sign for vertical writing mode on Windows */ +#define PDF_VERTICAL_SIGN '@' + typedef enum { font_ascender = (1<<0), @@ -62,6 +65,7 @@ struct pdf_font_options_s int xheight; int linegap; pdc_bool auxiliary; + pdc_bool dropcorewidths; }; /* Type3 font structures */ @@ -123,7 +127,7 @@ struct pdf_font_s /* pdflib encoding and CMap properties */ char *encapiname; /* encoding name specified in API call */ - char *outcmapname; /* output CMap namel */ + char *outcmapname; /* output CMap name */ int codepage; /* OEM multi byte code-page number */ pdc_encoding towinansi; /* convert to 'towinansi' enc. for output */ pdc_bool hasnomac; /* TT font has no macroman cmap */ @@ -152,6 +156,10 @@ struct pdf_font_s pdc_bool expectglyphs; /* TT: glyph id text strings are expected */ pdc_bool iscidfont; /* is CID font */ + int *widths; /* temporary glyph widths: code/gid -> width */ + int numwidths; /* number of entries in widths */ + pdc_bool konlydef; /* only default widths */ + }; /* p_truetype.c */ @@ -202,6 +210,7 @@ pdc_encodingvector *pdf_create_font_encoding(PDF *p, pdc_encoding enc, pdf_font *font, const char *fontname, pdc_bool kreg); void pdf_transform_fontwidths(PDF *p, pdf_font *font, pdc_encodingvector *evto, pdc_encodingvector *evfrom); +void pdf_prepare_fontwidths(PDF *p, pdf_font *font, int nusedgids); /* p_type1.c */ pdc_bool pdf_t1open_fontfile(PDF *p, pdf_font *font, const char *fontname, diff --git a/src/pdflib/pdflib/p_generr.h b/src/pdflib/pdflib/p_generr.h index 166e0f7..f11d9c0 100644 --- a/src/pdflib/pdflib/p_generr.h +++ b/src/pdflib/pdflib/p_generr.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_generr.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_generr.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib error messages * @@ -51,6 +51,9 @@ gen(0, 2012, UNSUPP_UNICODE, gen(0, 2014, UNSUPP_SPOTCOLOR, "Spot colors not supported in PDFlib Lite") +gen(0, 2015, UNSUPP_ICCBASEDCOLOR, + "ICC based or Lab colors not supported in PDFlib Lite") + gen(0, 2016, UNSUPP_PDI, "PDF import (PDI) not supported in PDFlib Lite") gen(0, 2017, UNSUPP_PDI_CONFIG, @@ -99,7 +102,7 @@ gen(0, 2098, BETA_EXPIRED, /* -------------------------------------------------------------------- */ -/* Document, page, scoping and resource (21xx) */ +/* Document, page, scoping, resource and matchbox (21xx) */ /* -------------------------------------------------------------------- */ gen(1, 2100, DOC_SCOPE, "Function must not be called in '$1' scope") @@ -157,7 +160,7 @@ gen(1, 2150, DOC_NEED_LABELOPT, "Option 'labels' requires suboption '$1' if used with this function") gen(1, 2152, PAGE_TRANS_COMPAT, - "Page transition '$1' requires PDF version 1.5 or higher") + "Page transition '$1' requires PDF 1.5") gen(1, 2154, PAGE_ILLROTATE, "Option 'rotate' has illegal value $1") @@ -192,6 +195,12 @@ gen(0, 2176, DOC_GETBUF_LIN, gen(1, 2178, PAGE_ILLREF, "A link annotation refers to non-existing page '$1'") +gen(0, 2180, DOC_NOLINOPT_ENCATT, + "Optimization/linearization not supported for encrypted file attachments") + +gen(1, 2190, MBOX_NOTFOUND, + "Matchbox '$1' not found") + /* -------------------------------------------------------------------- */ /* Graphics and Text (22xx) */ @@ -210,6 +219,11 @@ gen(0, 2212, SHADING13, "Smooth shadings are not supported in PDF 1.3") gen(1, 2220, TEMPLATE_SELF, "Can't place template handle $1 within its own definition") +gen(1, 2222, TEXT_ALIGNCHARNOTFOUND, + "Character U+$1 for option 'alignchar' not found in font or encoding") + +gen(1, 2223, TEXT_BADTEXTFORMAT, "Bad textformat '$1' (must be 'bytes')") + /* UNUSED gen(1, 2230, TEXT_UNICODENOTSHOW, "Can't show character with Unicode value U+$1") @@ -220,7 +234,7 @@ gen(1, 2233, TEXT_BUILTINNOTSHOW, "Can't show 16-bit character $1 for builtin encoding") */ -gen(1, 2234, TEXT_TOOLONG, "Text too long (max. $1)") +gen(2, 2234, TEXT_TOOLONG, "Text with $1 bytes is too long (max. $2)") gen(2, 2235, TEXT_SIZENOMATCH, "Size ($1) of glyphwidths list doesn't match size ($2 characters) of text") @@ -261,6 +275,11 @@ gen(2, 2309, COLOR_REDEFINE_SPOTNAME, "Option '$1': spot color '$2' has already an alternative color") +gen(1, 2350, COLOR_INVALPATT, + "Pattern with painttype 2 can not be colorized with another pattern") + +gen(0, 2352, COLOR_INVALSPEC, + "Color specification not allowed while defining a pattern with painttype 2") /* -------------------------------------------------------------------- */ /* Image (24xx) */ @@ -268,6 +287,8 @@ gen(2, 2309, COLOR_REDEFINE_SPOTNAME, gen(2, 2400, IMAGE_CORRUPT, "Corrupt $1 image file '$2'") +gen(4, 2401, IMAGE_TOO_LARGE, "$1 image '$2' too large ($3 x $4)") + gen(3, 2402, IMAGE_NOPAGE, "Requested page $1 in $2 image '$3' not found") gen(2, 2404, IMAGE_BADDEPTH, @@ -378,8 +399,12 @@ gen(1, 2482, TIFF_UNSUPP_JPEG_TILED, gen(2, 2483, TIFF_UNSUPP_COLORSPACE, "Color space (photometric) $1 in TIFF image '$2' not supported") -gen(1, 2484, TIFF_UNSUPP_JPEG_SEPARATE, - "Couldn't open TIFF image '$1' (JPEG with separate image planes)") +gen(1, 2484, TIFF_UNSUPP_SEPARATE, + "Couldn't open TIFF image '$1' (separate image planes not supported)") + +gen(1, 2485, TIFF_TILE_UNSUPP, + "Couldn't open TIFF image '$1' " + "(separate image planes with tiles not supported)") gen(2, 2486, TIFF_UNSUPP_SEP_NONCMYK, "Couldn't open TIFF image '$1' (unsupported inkset tag $2)") @@ -409,12 +434,14 @@ gen(1, 2496, JPX_RAWDATAUNSUPP, gen(1, 2498, JPX_COMPOUNDUNSUPP, "Compound JPEG2000 (JPM) image file '$1' not supported") +gen(1, 2499, TIFF_BPC_UNSUPP, +"TIFF image '$1' contains bpc that not equal to 1,2, 4, 8, 16, not supported") /* -------------------------------------------------------------------- */ /* Font (25xx) */ /* -------------------------------------------------------------------- */ -gen(2, 2500, FONT_CORRUPT, "Corrupt $1 font file '$2'") +gen(2, 2500, FONT_CORRUPT, "Corrupt $1 font file $2") gen(2, 2501, FONT_PREFIX, "Font '$1' with encoding '$2': ") @@ -446,9 +473,18 @@ gen(0, 2509, FONT_FORCECVTUNI, gen(0, 2514, FONT_EMBEDMM, "Multiple Master font cannot be embedded") -gen(0, 2516, FONT_NOMETRICS, "Metrics data not found") +gen(0, 2516, FONT_NOMETRICS, + "Font file (AFM, PFM, TTF, OTF etc.) or host font not found") +gen(0, 2517, FONT_NOOUTLINE_PS, + "Font cannot be embedded (PFA or PFB font file not found)") + +/* Unused gen(0, 2518, FONT_NOOUTLINE, "File with outline data not found") +*/ + +gen(0, 2519, FONT_NOOUTLINE_TT, + "Font cannot be embedded (TTF or OTF font file not found)") /* Unused gen(0, 2520, FONT_NOGLYPHID, "Font doesn't contain any glyph IDs") @@ -510,6 +546,9 @@ gen(2, 2554, T1_AFMBADKEY, "Unknown key '$1' in AFM file '$2'") gen(1, 2558, T1_NOFONT, "'$1' is not a PostScript Type1 font file") +gen(1, 2559, T1_RESOURCENOTLOADED, + "Couldn't load PostScript font resource file (system error code $1)") + gen(2, 2560, FONT_CODENOTFOUND1, "Glyph with character code $1 not found in font '$2'") @@ -611,6 +650,10 @@ gen(1, 2830, FF_NOEMBEDFONT, gen(1, 2832, FF_SUBSETTFONT, "Specified font '$1' not allowed for fields (must not be subset)") +gen(2, 2833, FF_NOPDFDOCFONT, + "Specified encoding '$1' of font '$2' not recommended for fields " + "(please use encoding 'pdfdoc')") + gen(1, 2834, FF_CAPTMISSING, "No caption or icon specified for field '$1'") gen(0, 2836, FF_DIFFSTRLISTS, @@ -666,6 +709,12 @@ gen(1, 2886, ANN_OPTALRDEF, gen(1, 2888, ANN_ILLCUSTOMKEY, "Option 'custom' uses illegal key '$1' (already defined in PDF)") +gen(0, 2890, ANN_ILLTEMPLATE, + "Option 'movieposter' has bad template handle " + "(only images with RGB or Gray color spaces supported)") + +gen(1, 2892, ANN_ACTIONNOTALLOWED, + "Option 'action' not allowed for annotation type '$1'") /* -------------------------------------------------------------------- */ /* Internal (29xx) */ @@ -689,7 +738,7 @@ gen(1, 2912, INT_SSTACK_UNDER, "State stack underflow in function '$1'") gen(3, 2914, INT_WRAPPER, "Error in PDFlib $1 wrapper function $2 ($3)") gen(0, 2990, OT_UNSUPP_SID2CID, - "Accented characters not supported; contact support@pdflib.com") +"Accented characters not supported; use autocidfont=false in PDF_load_font()") diff --git a/src/pdflib/pdflib/p_gif.c b/src/pdflib/pdflib/p_gif.c index 59d80f5..12993bf 100644 --- a/src/pdflib/pdflib/p_gif.c +++ b/src/pdflib/pdflib/p_gif.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_gif.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_gif.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * GIF processing for PDFlib * @@ -51,14 +51,13 @@ pdf_process_GIF_data( PDF *p, int imageslot) { - pdf_image *image = &p->images[imageslot]; + (void) imageslot; pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "GIF", 0, 0, 0); return -1; } -/* CDPDF - added missing function */ void pdf_cleanup_gif(PDF *p, pdf_image *image) { @@ -463,7 +462,7 @@ GetDataBlock(PDF *p, pdf_image *image, unsigned char *lbuf) if (!PDC_OK_FREAD(fp, &count, 1)) return -1; /* Error in getting DataBlock size */ - ZeroDataBlock = (count == 0); + ZeroDataBlock = (count == (unsigned char) 0); if ((count != (unsigned char) 0) && (!PDC_OK_FREAD(fp, lbuf, count))) { diff --git a/src/pdflib/pdflib/p_gstate.c b/src/pdflib/pdflib/p_gstate.c index 2b62542..892a9d2 100644 --- a/src/pdflib/pdflib/p_gstate.c +++ b/src/pdflib/pdflib/p_gstate.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_gstate.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_gstate.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib routines dealing with the graphics states * @@ -23,15 +23,31 @@ void pdf_concat_raw(PDF *p, pdc_matrix *m) { - if (pdc_is_identity_matrix(m)) - return; + if (!pdc_is_identity_matrix(m)) + { + char sa[32], sb[32], sc[32], sd[32]; - pdf_end_text(p); + pdc_sprintf(p->pdc, pdc_true, sa, "%f", m->a); + pdc_sprintf(p->pdc, pdc_true, sb, "%f", m->b); + pdc_sprintf(p->pdc, pdc_true, sc, "%f", m->c); + pdc_sprintf(p->pdc, pdc_true, sd, "%f", m->d); + + if ((!strcmp(sa, "0") || !strcmp(sd, "0")) && + (!strcmp(sb, "0") || !strcmp(sc, "0"))) + { + pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, + pdc_errprintf(p->pdc, "%f %f %f %f %f %f", + m->a, m->b, m->c, m->d, m->e, m->f), + 0, 0, 0); + } + + pdf_end_text(p); - pdc_printf(p->out, "%f %f %f %f %f %f cm\n", - m->a, m->b, m->c, m->d, m->e, m->f); + pdc_printf(p->out, "%s %s %s %s %f %f cm\n", + sa, sb, sc, sd, m->e, m->f); - pdc_multiply_matrix(m, &p->curr_ppt->gstate[p->curr_ppt->sl].ctm); + pdc_multiply_matrix(m, &p->curr_ppt->gstate[p->curr_ppt->sl].ctm); + } } void @@ -189,7 +205,6 @@ pdf__concat(PDF *p, pdc_scalar a, pdc_scalar b, pdc_scalar c, pdc_scalar d, pdc_scalar e, pdc_scalar f) { pdc_matrix m; - pdc_scalar det = a * d - b * c; pdc_check_number(p->pdc, "a", a); pdc_check_number(p->pdc, "b", b); @@ -198,11 +213,6 @@ pdf__concat(PDF *p, pdc_scalar a, pdc_scalar b, pdc_scalar c, pdc_scalar d, pdc_check_number(p->pdc, "e", e); pdc_check_number(p->pdc, "f", f); - if (fabs(det) < PDF_SMALLREAL) - pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, - pdc_errprintf(p->pdc, "%f %f %f %f %f %f", a, b, c, d, e, f), - 0, 0, 0); - m.a = a; m.b = b; m.c = c; @@ -217,13 +227,6 @@ void pdf_setmatrix_e(PDF *p, pdc_matrix *n) { pdc_matrix m; - pdc_scalar det = n->a * n->d - n->b * n->c; - - if (fabs(det) < PDF_SMALLREAL) - pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, - pdc_errprintf(p->pdc, "%f %f %f %f %f %f", - n->a, n->b, n->c, n->d, n->e, n->f), - 0, 0, 0); pdc_invert_matrix(p->pdc, &m, &p->curr_ppt->gstate[p->curr_ppt->sl].ctm); pdc_multiply_matrix(n, &m); diff --git a/src/pdflib/pdflib/p_hkscmyk.h b/src/pdflib/pdflib/p_hkscmyk.h index 924ad64..b1e6c21 100644 --- a/src/pdflib/pdflib/p_hkscmyk.h +++ b/src/pdflib/pdflib/p_hkscmyk.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_hkscmyk.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_hkscmyk.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib HKS spot CMYK color table * diff --git a/src/pdflib/pdflib/p_hkslab.h b/src/pdflib/pdflib/p_hkslab.h index 68f13bb..6ad0c3b 100644 --- a/src/pdflib/pdflib/p_hkslab.h +++ b/src/pdflib/pdflib/p_hkslab.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_hkslab.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_hkslab.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib HKS spot Lab color table * diff --git a/src/pdflib/pdflib/p_hyper.c b/src/pdflib/pdflib/p_hyper.c index 644e311..a72d0ec 100644 --- a/src/pdflib/pdflib/p_hyper.c +++ b/src/pdflib/pdflib/p_hyper.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_hyper.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_hyper.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib routines for hypertext stuff: * named destination, bookmarks, document info @@ -544,7 +544,8 @@ pdf__add_nameddest( pdf_dest *dest; int inum; - if (!name) + len = pdc_check_text_length(p->pdc, &name, len, PDF_MAXSTRINGSIZE); + if (!len) pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "name", 0, 0, 0); resopts = pdc_parse_optionlist(p->pdc, optlist, @@ -955,6 +956,10 @@ pdf__create_bookmark(PDF *p, const char *text, int len, const char *optlist) int ns, inum, outlen, retval = 0; int jndex = -2; + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXSTRINGSIZE); + if (!len) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "text", 0, 0, 0); + /* Initialize */ pdf_init_outline(p, &self); hypertextformat = p->hypertextformat; @@ -1196,12 +1201,17 @@ pdf_cleanup_outlines(PDF *p) int pdf__add_bookmark(PDF *p, const char *text, int len, int parent, int open) { + static const char *fn = "pdf__add_bookmark"; pdf_outline self; pdf_dest *dest = (pdf_dest *) p->bookmark_dest; char *hypertext = NULL; int acthdl; int retval = 0; + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXSTRINGSIZE); + if (!len) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "text", 0, 0, 0); + pdf_init_outline(p, &self); if (parent != 0) @@ -1212,16 +1222,21 @@ pdf__add_bookmark(PDF *p, const char *text, int len, int parent, int open) /* creating a Launch action - defined via bookmarkdest */ if (dest->filename) { - char actoptlist[2048]; + char *actoptlist; - sprintf(actoptlist, "filename {%s} ", dest->filename); + actoptlist = (char *) + pdc_malloc(p->pdc, strlen(dest->filename) + 80, fn); + pdc_sprintf(p->pdc, pdc_false, actoptlist, "filename {%s} ", + dest->filename); acthdl = pdf__create_action(p, "Launch", actoptlist); if (acthdl != -1) { if (p->pdc->hastobepos) acthdl++; - sprintf(actoptlist, "activate %d", acthdl); + pdc_sprintf(p->pdc, pdc_false, actoptlist, "activate %d", acthdl); self.action = pdc_strdup(p->pdc, actoptlist); } + + pdc_free(p->pdc, actoptlist); } else { @@ -1311,21 +1326,38 @@ pdf__set_info(PDF *p, const char *key, const char *value, int len) static const char fn[] = "pdf__set_info"; char *key_buf, *val_buf; pdf_info *oldentry, *newentry; + const char **kp; + static const char *forbidden_keys[] = + { + "Producer", + "CreationDate", + "ModDate", + "GTS_PDFXVersion", + "GTS_PDFXConformance", + "ISO_PDFEVersion" + }; if (key == NULL || !*key) pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); - if (!strcmp(key, "Producer") || - !strcmp(key, "CreationDate") || - !strcmp(key, "ModDate")) - pdc_error(p->pdc, PDC_E_ILLARG_STRING, "key", key, 0, 0); + len = pdc_check_text_length(p->pdc, &value, len, PDF_MAXSTRINGSIZE); + + for (kp = forbidden_keys; + kp != sizeof(forbidden_keys) / sizeof(char *) + forbidden_keys; + kp += 1) + { + if (!strcmp(*kp, key)) + { + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "key", key, 0, 0); + } + } /* converting key */ key_buf = pdf_convert_name(p, key, 0, 0); /* convert text string */ val_buf = pdf_convert_hypertext_depr(p, value, len); - if (!val_buf) + if (val_buf == NULL) pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "value", 0, 0, 0); /* special handling required for "Trapped" */ @@ -1365,8 +1397,9 @@ pdf__set_info(PDF *p, const char *key, const char *value, int len) pdc_id pdf_write_info(PDF *p, pdc_bool moddate) { + pdc_bool logg3 = pdc_logg_is_enabled(p->pdc, 3, trc_xmp); char time_str[PDC_TIME_SBUF_SIZE]; - char producer[PDF_MAX_PARAMSTRING]; + char producer[PDC_GEN_BUFSIZE]; pdf_info *info; pdc_id info_id; @@ -1374,6 +1407,8 @@ pdf_write_info(PDF *p, pdc_bool moddate) const char *product = "PDFlib Lite"; + (void) logg3; + if (!p->pdc->smokerun) pdc_logg_cond(p->pdc, 1, trc_api, @@ -1427,10 +1462,10 @@ pdf_write_info(PDF *p, pdc_bool moddate) */ if (p->pdc->binding) - sprintf(producer, "%s %s (%s/%s)", product, + pdc_sprintf(p->pdc, pdc_false, producer, "%s %s (%s/%s)", product, PDFLIB_VERSIONSTRING, p->pdc->binding, PDF_PLATFORM); else - sprintf(producer, "%s %s (%s)", product, + pdc_sprintf(p->pdc, pdc_false, producer, "%s %s (%s)", product, PDFLIB_VERSIONSTRING, PDF_PLATFORM); pdc_puts(p->out, "/Producer "); @@ -1447,3 +1482,4 @@ pdf_write_info(PDF *p, pdc_bool moddate) } + diff --git a/src/pdflib/pdflib/p_icc.c b/src/pdflib/pdflib/p_icc.c index 072ea55..250c2b2 100644 --- a/src/pdflib/pdflib/p_icc.c +++ b/src/pdflib/pdflib/p_icc.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_icc.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_icc.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib ICC handling routines * diff --git a/src/pdflib/pdflib/p_icc.h b/src/pdflib/pdflib/p_icc.h index 73fedfa..7a2f192 100644 --- a/src/pdflib/pdflib/p_icc.h +++ b/src/pdflib/pdflib/p_icc.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_icc.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_icc.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib ICC typedefs, structures, and enums * diff --git a/src/pdflib/pdflib/p_icc9809.h b/src/pdflib/pdflib/p_icc9809.h index 3ceb0f7..e7eb077 100644 --- a/src/pdflib/pdflib/p_icc9809.h +++ b/src/pdflib/pdflib/p_icc9809.h @@ -1,4 +1,4 @@ -/* $Id: p_icc9809.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_icc9809.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Header file of ICC (name see note above) for ICClib and PDFlib * diff --git a/src/pdflib/pdflib/p_icclib.c b/src/pdflib/pdflib/p_icclib.c index 02275da..e62a80f 100644 --- a/src/pdflib/pdflib/p_icclib.c +++ b/src/pdflib/pdflib/p_icclib.c @@ -1,14 +1,14 @@ -/* $Id: p_icclib.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_icclib.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * ICClib routines for PDFlib, slightly modified from the original ICClib. * (see below). * * $Log: p_icclib.c,v $ - * Revision 1.1 2008/10/17 06:11:49 scuri - * First commit - moving from LuaForge to SourceForge + * Revision 1.2 2009/10/20 18:14:16 scuri + * *** empty log message *** * - * Revision 1.3 2007/11/06 15:48:55 scuri - * PDF Lite library updated to version "7.0.2". + * Revision 1.18.8.4 2007/11/22 17:54:38 kurt + * bug #1538 (Relax date check for embedded ICC profile) fixed * * Revision 1.18.8.3 2007/05/23 21:15:00 york * fixed #1230: "Performance problems in mulithreaded env with tolower/toupper". diff --git a/src/pdflib/pdflib/p_icclib.h b/src/pdflib/pdflib/p_icclib.h index b300419..ac933ff 100644 --- a/src/pdflib/pdflib/p_icclib.h +++ b/src/pdflib/pdflib/p_icclib.h @@ -1,13 +1,10 @@ -/* $Id: p_icclib.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_icclib.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * ICClib Header file icc.h for PDFlib * * $Log: p_icclib.h,v $ - * Revision 1.1 2008/10/17 06:11:49 scuri - * First commit - moving from LuaForge to SourceForge - * - * Revision 1.3 2007/11/06 15:48:55 scuri - * PDF Lite library updated to version "7.0.2". + * Revision 1.2 2009/10/20 18:14:16 scuri + * *** empty log message *** * * Revision 1.12.8.1 2007/03/28 12:47:10 kurt * bug #1180 (Function prefixes missing for zlib assembler and ICC code) fixed diff --git a/src/pdflib/pdflib/p_image.c b/src/pdflib/pdflib/p_image.c index fe95b1c..8e5cd6e 100644 --- a/src/pdflib/pdflib/p_image.c +++ b/src/pdflib/pdflib/p_image.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_image.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_image.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib image routines * @@ -112,6 +112,8 @@ pdf_grow_images(PDF *p) for (im = p->images_capacity; im < 2 * p->images_capacity; im++) pdf_init_image_struct(p, &(p->images[im])); + for (im = 0; im < p->images_capacity; im++) + p->images[im].src.private_data = &(p->images[im]); p->images_capacity *= 2; } @@ -400,7 +402,10 @@ pdf_put_inline_image(PDF *p, int im) if ((int) image->width != 1728) /* CCITT default width */ pdc_printf(p->out, "/Columns %d", (int) image->width); - /* /Rows is not required */ + /* /Rows is optional, but it helps in certain cases with damaged + * CCITT compressed image data + */ + pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); } pdc_puts(p->out, ">>]"); /* DecodeParms dict and array */ } @@ -618,9 +623,10 @@ pdf_put_image(PDF *p, int im, pdc_bool firststrip, pdc_bool checkcontentstream) if ((int) image->width != 1728) /* CCITT default width */ pdc_printf(p->out, "/Columns %d", (int) image->width); - /* + /* /Rows is optional, but it helps in certain cases with damaged + * CCITT compressed image data + */ pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); - */ if (image->K != 0) pdc_printf(p->out, "/K %d", image->K); @@ -650,6 +656,9 @@ pdf_put_image(PDF *p, int im, pdc_bool firststrip, pdc_bool checkcontentstream) /* We must avoid pdc_begin/end_pdfstream() here in order to * generate a really empty stream. + * Note: this doesn't work with AES encryption, but we don't + * bother to fix it since file references are no longer + * supported anyway. */ pdc_puts(p->out, "stream\n"); /* dummy image stream */ pdc_puts(p->out, "endstream\n"); @@ -711,7 +720,10 @@ pdf_put_image(PDF *p, int im, pdc_bool firststrip, pdc_bool checkcontentstream) if ((int) image->width != 1728) /* CCITT default width */ pdc_printf(p->out, "/Columns %d", (int) image->width); - /* /Rows is not required */ + /* /Rows is optional, but it helps in certain cases with damaged + * CCITT compressed image data + */ + pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); } pdc_puts(p->out, ">>\n"); /* DecodeParms dict */ @@ -775,6 +787,9 @@ pdf__fit_image(PDF *p, int im, pdc_scalar x, pdc_scalar y, const char *optlist) if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p) && image->imagemask == pdc_false) legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template; + else if (PDF_GET_STATE(p) == pdf_state_pattern && + pdf_get_shading_painttype(p) == 2 && image->imagemask == pdc_false) + legal_states = pdf_state_page | pdf_state_glyph | pdf_state_template; else legal_states = pdf_state_content; PDF_CHECK_STATE(p, legal_states); @@ -937,15 +952,15 @@ pdf_fit_xobject_internal(PDF *p, pdf_xobject_options *xo, pdf_fit_options *fit, pdf_xobject_options xo_save; pdc_rectangle matchrect; pdf_fit_options fit_save; - pdc_matrix m, mm, sm, ctm_save; + pdc_matrix m, mm, sm, ctm_clip, ctm_save; pdc_vector tmpscale, elemscale, fitscale, purescale; pdc_vector elemsize, mirror, shift, relpos; pdc_vector polyline[5]; - pdc_box fitbox, clipbox, elembox; + pdc_box fitbox, clipbox, elembox, redbox; pdc_scalar x, y, ss; pdc_scalar rowsize = 1, lastratio = 1; pdc_scalar dpi_x, dpi_y, tx = 0, ty = 0, boxwidth, boxheight; - pdc_bool hasfitbox, kclip = pdc_false, kcliptiff = pdc_false; + pdc_bool kclip = pdc_false, kcliptiff = pdc_false; int indangle, indmirror; int is, ip, islast; int imageno; @@ -967,7 +982,6 @@ pdf_fit_xobject_internal(PDF *p, pdf_xobject_options *xo, pdf_fit_options *fit, /* box size */ boxwidth = fit->boxsize[0]; boxheight = fit->boxsize[1]; - hasfitbox = boxwidth > PDC_FLOAT_PREC && boxheight > PDC_FLOAT_PREC; /* element size */ elemsize.x = fabs(image->width); @@ -1237,15 +1251,18 @@ pdf_fit_xobject_internal(PDF *p, pdf_xobject_options *xo, pdf_fit_options *fit, /* clipping */ if (fit->fitmethod == pdc_clip || fit->fitmethod == pdc_slice) { - pdc_scalar cw = boxwidth; - pdc_scalar ch = boxheight; - - if (cw < PDC_FLOAT_PREC) - cw = PDF_ACRO_MAXPAGE; - if (ch < PDC_FLOAT_PREC) - ch = PDF_ACRO_MAXPAGE; - pdf__rect(p, 0, 0, cw, ch); + if (boxwidth < PDC_FLOAT_PREC) + boxwidth = PDF_ACRO_MAXPAGE; + if (boxheight < PDC_FLOAT_PREC) + boxheight = PDF_ACRO_MAXPAGE; + pdf__rect(p, 0, 0, boxwidth, boxheight); pdf__clip(p); + + ctm_clip = p->curr_ppt->gstate[p->curr_ppt->sl].ctm; + redbox.ll.x = 0; + redbox.ll.y = 0; + redbox.ur.x = boxwidth; + redbox.ur.y = p->ydirection * boxheight; } } @@ -1309,6 +1326,21 @@ pdf_fit_xobject_internal(PDF *p, pdf_xobject_options *xo, pdf_fit_options *fit, matchrect.lly = 0; matchrect.urx = boxwidth; matchrect.ury = p->ydirection * boxheight; + + if (fit->fitmethod == pdc_clip || fit->fitmethod == pdc_slice) + { + pdc_rectangle cliprect; + pdc_matrix ctm_inv; + + pdc_invert_matrix(p->pdc, &ctm_inv, + &p->curr_ppt->gstate[p->curr_ppt->sl].ctm); + pdc_multiply_matrix(&ctm_clip, &ctm_inv); + pdc_box2polyline(&ctm_inv, &redbox, polyline); + pdc_polyline2rect(polyline, 4, &cliprect); + + pdc_rect_intersect(&matchrect, &matchrect, &cliprect); + } + pdf_set_mbox_rectangle(p, fit->matchbox, &matchrect, 0); pdf_draw_mbox_rectangle(p, fit->matchbox, mbox_area | mbox_border); @@ -1429,7 +1461,12 @@ pdf_fit_xobject_internal(PDF *p, pdf_xobject_options *xo, pdf_fit_options *fit, } } if (image->mask != pdc_undef) + { p->xobjects[p->images[image->mask].no].flags |= xobj_flag_write; + + if (p->images[image->mask].bpc > 1) + pdf_set_autotgroup(p, pdc_true); + } } } @@ -1484,6 +1521,20 @@ pdf_get_image_resolution(PDF *p, int im, pdc_scalar *dpi_x, pdc_scalar *dpi_y) } } +int +pdf_get_image_colorspace(PDF *p, int im) +{ + pdf_image *image; + + pdf_check_handle(p, im, pdc_imagehandle); + image = &p->images[im]; + + if (image->colorspace != pdc_undef) + return (int) p->colorspaces[image->colorspace].type; + + return (int) NoColor; +} + const char * pdf_get_image_filename(PDF *p, pdf_image *image) @@ -1567,14 +1618,14 @@ static const pdc_defopt pdf_open_image_options[] = 0.0, 0.0, NULL}, {"clippingpathname", pdc_stringlist, PDF_CLIPPATH_FLAG, 1, 1, - 1.0, PDC_INT_MAX, NULL}, + 1.0, 255.0, NULL}, {"ignoremask", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, {"ignoreorientation", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, /* deprecated */ - {"imagewarning", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + {"imagewarning", pdc_booleanlist, PDC_OPT_PDFLIB_7, 1, 1, 0.0, 0.0, NULL}, {"inline", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, @@ -1652,7 +1703,14 @@ pdf__load_image( imgtype = (pdf_image_type) k; type = pdc_get_keyword(imgtype, pdf_image_keylist); - verbose = pdf_get_errorpolicy(p, NULL, verbose); + /* parsing option list */ + pdf_set_clientdata(p, &data); + resopts = pdc_parse_optionlist(p->pdc, optlist, pdf_open_image_options, + &data, pdc_true); + + keyword = "imagewarning"; + pdc_get_optvalues(keyword, resopts, &verbose, NULL); + verbose = pdf_get_errorpolicy(p, resopts, verbose); /* filename must be already converted to UTF-8 */ pdc_logg_cond(p->pdc, 1, trc_image, "\tImage file: \"%s\"\n", filename); @@ -1785,15 +1843,6 @@ pdf__load_image( /* parsing optlist */ if (optlist && strlen(optlist)) { - pdf_set_clientdata(p, &data); - resopts = pdc_parse_optionlist(p->pdc, optlist, pdf_open_image_options, - &data, pdc_true); - /* save and check options */ - keyword = "imagewarning"; - pdc_get_optvalues(keyword, resopts, &image->verbose, NULL); - image->verbose = pdf_get_errorpolicy(p, resopts, image->verbose); - verbose = image->verbose; - keyword = "reftype"; if (pdc_get_optvalues(keyword, resopts, &inum, NULL)) { @@ -2171,7 +2220,7 @@ pdf__load_image( image->fp = NULL; /* logging protocol */ - if (pdc_logg_is_enabled(p->pdc, 1, trc_image)) + if (image->in_use && pdc_logg_is_enabled(p->pdc, 1, trc_image)) { pdc_scalar width, height, dpi_x, dpi_y; diff --git a/src/pdflib/pdflib/p_image.h b/src/pdflib/pdflib/p_image.h index 2f67649..f5423c8 100644 --- a/src/pdflib/pdflib/p_image.h +++ b/src/pdflib/pdflib/p_image.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_image.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_image.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Header file for the PDFlib image subsystem * @@ -155,7 +155,7 @@ typedef struct pdf_jpeg_info_t { pdf_jpeg_segment *seglist; /* list of segments to be copy */ int capacity; /* currently allocated size */ int number; /* next available segment number */ - pdc_uint32 jpegifoffset; /* offset to JPEG data for TIFF OJPEG */ /* CDPDF - replaced toff_t by pdc_uint32 */ + pdc_uint32 jpegifoffset; /* offset to JPEG data for TIFF OJPEG */ pdc_byte id[JPEG_MAX_COMPS]; /* component ids */ pdc_byte hsamp[JPEG_MAX_COMPS]; /* horizontal sampling factor */ pdc_byte vsamp[JPEG_MAX_COMPS]; /* vertical sampling factor */ @@ -252,10 +252,11 @@ struct pdf_image_s { pdf_ref_type reference; /* kind of image data reference */ pdc_bool topdown_save; /* saved topdown flag */ char *iconname; /* icon name for template images */ + pdf_transgroup tgroup; /* transparency group definition */ /**************************************************************************/ pdc_bool transparent; /* image is transparent */ - pdc_byte transval[4]; /* transparent color values */ + pdc_ushort transval[4]; /* transparent color values */ pdf_predictor predictor; /* predictor for lzw and flate */ pdc_scalar dpi_x; /* horiz. resolution in dots per inch */ @@ -341,6 +342,9 @@ int pdf_process_TIFF_data(PDF *p, int imageslot); pdc_bool pdf_is_TIFF_file(PDF *p, pdc_file *fp, pdf_tiff_info *tiff, pdc_bool check); +void pdf_proc_TIFF_alpha(PDF *p, int imageslot, pdc_byte *smaskData, + unsigned int smaskLen); + /* p_image.c */ pdc_id pdf_get_xobject(PDF *p, int im); void pdf_init_xobjects(PDF *p); diff --git a/src/pdflib/pdflib/p_intern.h b/src/pdflib/pdflib/p_intern.h index 80f92d9..2123b9e 100644 --- a/src/pdflib/pdflib/p_intern.h +++ b/src/pdflib/pdflib/p_intern.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_intern.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_intern.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib internal definitions * @@ -109,14 +109,21 @@ enum }; #endif -#define pdf_state_content \ +#define pdf_state_content \ (pdf_state) (pdf_state_page | pdf_state_pattern | \ pdf_state_template | pdf_state_glyph) -#define pdf_state_all \ - (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page | \ - pdf_state_pattern | pdf_state_template | pdf_state_path | \ - pdf_state_font | pdf_state_glyph) +#define pdf_state_firsttest \ + (pdf_state) (pdf_state_document | pdf_state_content | \ + pdf_state_path | pdf_state_font | \ + pdf_state_glyphmetrics) + +#define pdf_state_documentall \ + (pdf_state) (pdf_state_document | pdf_state_content | \ + pdf_state_path | pdf_state_font | \ + pdf_state_glyphmetrics | pdf_state_glyphignore) + +#define pdf_state_all (pdf_state) (pdf_state_object | pdf_state_documentall) #define PDF_STATE_STACK_SIZE 4 @@ -198,6 +205,14 @@ typedef struct pdf_widget_s pdf_widget; typedef struct pdf_xobject_s pdf_xobject; +/* -------------------- transparency group -------------------- */ +typedef struct +{ + pdf_colortype colorspace; /* color space */ + pdc_bool isolated; /* isolated flag I */ + pdc_bool knockout; /* knockout flag K */ +} pdf_transgroup; + /* -------------------- special graphics state -------------------- */ typedef struct { pdc_matrix ctm; /* current transformation matrix */ @@ -230,16 +245,6 @@ typedef struct pdc_vtr * mboxes; /* matchbox chain */ - /* in update mode, the resource numbers generally don't start - ** with 0, but with a bias value derived from the original - ** page's resources. - */ - int cs_bias; /* colorspaces */ - int eg_bias; /* extended gstates */ - int fn_bias; /* fonts */ - int pt_bias; /* patterns */ - int sh_bias; /* shadings */ - int xo_bias; /* xobjects */ } pdf_ppt; /* Force graphics or color operator output, avoiding the optimization @@ -736,6 +741,7 @@ void pdf_cleanup_image(PDF *p, int im); void pdf_get_image_size(PDF *p, int im, pdc_scalar *width, pdc_scalar *height); void pdf_get_image_resolution(PDF *p, int im, pdc_scalar *dpi_x, pdc_scalar *dpi_y); +int pdf_get_image_colorspace(PDF *p, int im); @@ -810,7 +816,7 @@ int pdf_search_page_fwd(PDF *p, int start_page, pdc_id id); int pdf_search_page_bwd(PDF *p, int start_page, pdc_id id); int pdf_xlat_pageno(PDF *p, int pageno, const char *groupname); -double pdf_get_pageheight(PDF *p); +pdc_scalar pdf_get_pageheight(PDF *p); const pdc_rectangle *pdf_get_pagebox(PDF *p, pdf_pagebox box); void pdf_set_pagebox_llx(PDF *p, pdf_pagebox box, pdc_scalar llx); void pdf_set_pagebox_lly(PDF *p, pdf_pagebox box, pdc_scalar lly); @@ -818,11 +824,14 @@ void pdf_set_pagebox_urx(PDF *p, pdf_pagebox box, pdc_scalar urx); void pdf_set_pagebox_ury(PDF *p, pdf_pagebox box, pdc_scalar ury); void pdf_set_pagebox(PDF *p, pdf_pagebox box, pdc_scalar llx, pdc_scalar lly, pdc_scalar urx, pdc_scalar ury); +void pdf_set_transgroup(PDF *p, const char *optlist, pdf_transgroup *tgroup); +void pdf_write_transgroup(PDF *p, pdf_transgroup *tgroup); pdc_vtr *pdf_get_annots_list(PDF *p); void pdf_set_annots_list(PDF *p, pdc_vtr *annots); pdc_id pdf_get_thumb_id(PDF *p); void pdf_set_thumb_id(PDF *p, pdc_id id); +void pdf_set_autotgroup(PDF *p, pdc_bool autotgroup); void pdf_begin_contents_section(PDF *p); void pdf_end_contents_section(PDF *p); @@ -979,12 +988,16 @@ char *pdf_convert_hypertext_depr(PDF *p, const char *text, int len); char *pdf_convert_hypertext(PDF *p, const char *text, int len, pdc_text_format hypertextformat, pdc_encoding hypertextencoding, int codepage, int *outlen, pdc_bool oututf8, pdc_bool verbose); +char *pdf_convert_pdfstring(PDF *p, const char *text, int inlen, int convflags, + int *outlen); void pdf_put_hypertext(PDF *p, const char *text); char *pdf_convert_name(PDF *p, const char *name, int len, int flags); const char *pdf_convert_filename(PDF *p, const char *filename, int len, const char *paramname, int flags); -void pdf_add_resource(PDF *p, const char *category, const char *resname); +void pdf_add_pdflib_resource(PDF *p, const char *category, const char *resname); void pdf_put_pdffilename(PDF *p, const char *text); +void pdf_put_pdfunifilename(PDF *p, const char *text); +int pdf_check_opt_handle(void *opaque, int handle, pdc_opttype type); void pdf_check_handle(PDF *p, int value, pdc_opttype type); void pdf_set_clientdata(PDF *p, pdc_clientdata *clientdata); void pdf_init_stringlists(PDF *p); @@ -995,6 +1008,8 @@ const char *pdf_get_utilstring(PDF *p, int i); int pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, pdc_encoding enc, int codepage, pdc_bool ishypertext, const char *fieldname, char **text, char ***textlist); +char *pdf_get_opt_filename(PDF *p, const char *keyword, pdc_resopt *resopts, + pdc_encoding enc, int codepage); char *pdf_get_opt_utf8name(PDF *p, const char *keyword, pdc_resopt *resopts); pdc_bool pdf_get_errorpolicy(PDF *p, pdc_resopt *resopts, pdc_bool verbose); @@ -1025,3 +1040,4 @@ pdc_id pdf_get_gstate_id(PDF *p, int gstate); + diff --git a/src/pdflib/pdflib/p_jpeg.c b/src/pdflib/pdflib/p_jpeg.c index 467f282..fb7cd18 100644 --- a/src/pdflib/pdflib/p_jpeg.c +++ b/src/pdflib/pdflib/p_jpeg.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_jpeg.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_jpeg.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * JPEG processing for PDFlib * @@ -36,14 +36,13 @@ pdf_process_JPEG_data( PDF *p, int imageslot) { - pdf_image *image = &p->images[imageslot]; + (void) imageslot; pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "JPEG", 0, 0, 0); return -1; } -/* CDPDF - added missing function */ void pdf_cleanup_jpeg(PDF *p, pdf_image *image) { diff --git a/src/pdflib/pdflib/p_jpx.c b/src/pdflib/pdflib/p_jpx.c index 73e364c..412339c 100644 --- a/src/pdflib/pdflib/p_jpx.c +++ b/src/pdflib/pdflib/p_jpx.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_jpx.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_jpx.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * JPEG2000 processing for PDFlib * diff --git a/src/pdflib/pdflib/p_kerning.c b/src/pdflib/pdflib/p_kerning.c index bc711ba..035d273 100644 --- a/src/pdflib/pdflib/p_kerning.c +++ b/src/pdflib/pdflib/p_kerning.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_kerning.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_kerning.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib kerning routines * diff --git a/src/pdflib/pdflib/p_keyconn.h b/src/pdflib/pdflib/p_keyconn.h index a56d783..86e13ce 100644 --- a/src/pdflib/pdflib/p_keyconn.h +++ b/src/pdflib/pdflib/p_keyconn.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_keyconn.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_keyconn.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib shared keys connection lists * @@ -25,17 +25,17 @@ typedef enum { - pdf_state_object = (1<<0), /* outside any document */ - pdf_state_document = (1<<1), /* document */ - pdf_state_page = (1<<2), /* page description in a document */ - pdf_state_pattern = (1<<3), /* pattern in a document */ - pdf_state_template = (1<<4), /* template in a document */ - pdf_state_path = (1<<5), /* path in a page description */ - pdf_state_font = (1<<6), /* font definition */ - pdf_state_glyph = (1<<7), /* glyph description in a Type3 font */ - pdf_state_glyphmetric = (1<<8), /* glyph metric in a Type3 font */ - pdf_state_glyphignore = (1<<9), /* glyph will be ignored without error */ - pdf_state_error = (1<<10) /* in error cleanup */ + pdf_state_object = (1<<0), /* outside any document */ + pdf_state_document = (1<<1), /* document */ + pdf_state_page = (1<<2), /* page description in a document */ + pdf_state_pattern = (1<<3), /* pattern in a document */ + pdf_state_template = (1<<4), /* template in a document */ + pdf_state_path = (1<<5), /* path in a page description */ + pdf_state_font = (1<<6), /* font definition */ + pdf_state_glyph = (1<<7), /* glyph description in a Type3 font */ + pdf_state_glyphmetrics = (1<<8), /* glyph metrics in a Type3 font */ + pdf_state_glyphignore = (1<<9), /* glyph ignored without error */ + pdf_state_error = (1<<10) /* in error cleanup */ } pdf_state; @@ -50,7 +50,7 @@ pdf_errpol; typedef enum { names_undef = 0, - names_3dannots, /* internal for named 3D annotations */ + names_annots, /* internal for named 3D or Movie annotations */ names_dests, names_javascript, names_ap, @@ -167,6 +167,7 @@ typedef enum fo_subsetting, fo_unicodemap, fo_embedopentype, + fo_skipposttable, fo_vertical, fo_keepnative, fo_replacementchar, @@ -421,6 +422,19 @@ static const pdc_keyconn pdf_mbox_keylist[] = #endif /* P_MBOX_C */ +#if defined(P_PAGE_C) || defined(P_TEMPLATE_C) + +static const pdc_keyconn pdf_tgroup_cs_pdfkeylist[] = +{ + {"DeviceGray", color_gray}, + {"DeviceRGB", color_rgb}, + {"DeviceCMYK", color_cmyk}, + {NULL, 0} +}; + +#endif /* P_PAGE_C || P_TEMPLATE_C */ + + #if defined(P_DOCUMENT_C) || defined(P_PARAMS_C) static const pdc_keyconn pdf_compatibility_keylist[] = @@ -492,7 +506,7 @@ static const pdc_keyconn pdf_renderingintent_pdfkeylist[] = #endif /* P_IMAGE_C || P_PARAMS_C || P_XGSTATE_C */ -#if defined(P_MBOX_C) || defined(P_XGSTATE_C) +#if defined(P_MBOX_C) || defined(P_TABLE_C) || defined(P_XGSTATE_C) static const pdc_keyconn pdf_linecap_keylist[] = { @@ -510,7 +524,19 @@ static const pdc_keyconn pdf_linejoin_keylist[] = {NULL, 0} }; -#endif /* P_MBOX_C || P_XGSTATE_C */ +#endif /* P_MBOX_C || P_TABLE_C || P_XGSTATE_C */ + + +#if defined(P_PARAMS_C) || defined(P_TEXTFLOW_C) + +static const pdc_keyconn pdf_fillrule_keylist[] = +{ + {"winding", pdf_fill_winding }, + {"evenodd", pdf_fill_evenodd }, + {NULL, 0} +}; + +#endif /* P_PARAMS_C || P_TEXTFLOW_C */ #if defined(P_DOCUMENT_C) || defined(P_PARAMS_C) || defined(P_PDI_C) @@ -622,7 +648,7 @@ static const pdc_keyconn pdf_glyphcheck_keylist[] = #endif /* P_BLOCK_C || P_PARAMS_C || P_TEXT_C || P_TEXTFLOW_C */ -#if defined(P_BLOCK_C) || defined(P_FIELDS_C) || \ +#if defined(P_ANNOTS_C) || defined(P_BLOCK_C) || defined(P_FIELDS_C) || \ defined(P_IMAGE_C) || defined(P_TEXT_C) static const pdc_keyconn pdf_position_keylist[] = @@ -635,7 +661,7 @@ static const pdc_keyconn pdf_position_keylist[] = {NULL, 0} }; -#endif /* P_BLOCK_C || P_FIELDS_C || P_IMAGE_C || P_TEXT_C */ +#endif /* P_ANNOTS_C || P_BLOCK_C || P_FIELDS_C || P_IMAGE_C || P_TEXT_C */ #if defined(P_BLOCK_C) || defined(P_FIELDS_C) || \ diff --git a/src/pdflib/pdflib/p_layer.c b/src/pdflib/pdflib/p_layer.c index 1600a5b..7fb7321 100644 --- a/src/pdflib/pdflib/p_layer.c +++ b/src/pdflib/pdflib/p_layer.c @@ -9,7 +9,7 @@ | available, please check http://www.pdflib.com. | *---------------------------------------------------------------------------*/ -/* $Id: p_layer.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_layer.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib optional content routines * @@ -34,3 +34,5 @@ + + diff --git a/src/pdflib/pdflib/p_layer.h b/src/pdflib/pdflib/p_layer.h index 74d51eb..41f350b 100644 --- a/src/pdflib/pdflib/p_layer.h +++ b/src/pdflib/pdflib/p_layer.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_layer.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_layer.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib marked content header * diff --git a/src/pdflib/pdflib/p_mbox.c b/src/pdflib/pdflib/p_mbox.c index db6ffff..0c7497e 100644 --- a/src/pdflib/pdflib/p_mbox.c +++ b/src/pdflib/pdflib/p_mbox.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_mbox.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_mbox.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib matchbox related routines * @@ -452,9 +452,9 @@ pdf_set_mbox_rectangle(PDF *p, pdf_mbox *mbox, pdc_rectangle *rect, int flags) if (!(flags & mbox_statbottom)) { if (mbox->percentbottom) - mbox->rect.lly += mbox->offsetbottom * height; + mbox->rect.lly += p->ydirection * mbox->offsetbottom * height; else - mbox->rect.lly += mbox->offsetbottom; + mbox->rect.lly += p->ydirection * mbox->offsetbottom; } if (!(flags & mbox_statright)) @@ -468,9 +468,9 @@ pdf_set_mbox_rectangle(PDF *p, pdf_mbox *mbox, pdc_rectangle *rect, int flags) if (!(flags & mbox_stattop)) { if (mbox->percenttop) - mbox->rect.ury += mbox->offsettop * height; + mbox->rect.ury += p->ydirection * mbox->offsettop * height; else - mbox->rect.ury += mbox->offsettop; + mbox->rect.ury += p->ydirection * mbox->offsettop; } } @@ -620,7 +620,7 @@ pdf_get_usematchbox(PDF *p, const char *option, const char *optval, &strlist); if (ns) { - boxname = pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, strlist[0]); + boxname = pdc_strdup_tmp(p->pdc, strlist[0]); /* number of rectangles */ pdf_get_mbox(p, NULL, boxname, 0, &nrect); @@ -674,16 +674,18 @@ static const pdc_keyconn pdf_info_keylist[] = { {"count", 0}, {"exists", 1}, - {"width", 2}, - {"height", 3}, - {"x1", 4}, - {"y1", 5}, - {"x2", 6}, - {"y2", 7}, - {"x3", 8}, - {"y3", 9}, - {"x4", 10}, - {"y4", 11}, + {"name", 2}, + + {"width", 3}, + {"height", 4}, + {"x1", 5}, + {"y1", 6}, + {"x2", 7}, + {"y2", 8}, + {"x3", 9}, + {"y3", 10}, + {"x4", 11}, + {"y4", 12}, {NULL, 0} }; @@ -692,7 +694,6 @@ pdf__info_matchbox(PDF *p, const char *boxname, int len, int num, const char *keyword) { pdf_mbox *mbox; - char *cname; double mbinfo = 0; int infokey, count; @@ -703,20 +704,21 @@ pdf__info_matchbox(PDF *p, const char *boxname, int len, int num, pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "keyword", 0, 0, 0); /* Converting boxname */ - cname = pdf_convert_name(p, boxname, len, 0); - if (cname == NULL || *cname == '\0') + boxname = pdf_convert_name(p, boxname, len, PDC_CONV_TMPALLOC); + if (boxname == NULL || *boxname == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "boxname", 0, 0, 0); - boxname = pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, cname); - pdc_free(p->pdc, cname); infokey = pdc_get_keycode_ci(keyword, pdf_info_keylist); if (infokey == PDC_KEY_NOTFOUND) pdc_error(p->pdc, PDC_E_ILLARG_STRING, "keyword", keyword, 0, 0); + if (!strcmp(boxname, "*")) + boxname = NULL; + /* count */ if (!infokey) { - pdf_get_mbox(p, NULL, boxname, num, &count); + pdf_get_mbox(p, NULL, boxname, -1, &count); mbinfo = (double) count; } else @@ -735,51 +737,63 @@ pdf__info_matchbox(PDF *p, const char *boxname, int len, int num, switch (infokey) { + /* exists */ case 1: mbinfo = 1; break; + /* name */ case 2: - mbinfo = pdc_get_vector_length(&polyline[0], &polyline[1]); + mbinfo = (double) + pdf_insert_utilstring(p, mbox->name, pdc_true); break; + /* geometrical keys */ case 3: - mbinfo = pdc_get_vector_length(&polyline[0], &polyline[3]); + mbinfo = pdc_get_vector_length(&polyline[0], &polyline[1]); break; case 4: - mbinfo = polyline[0].x; + mbinfo = pdc_get_vector_length(&polyline[0], &polyline[3]); break; case 5: - mbinfo = polyline[0].y; + mbinfo = polyline[0].x; break; case 6: - mbinfo = polyline[1].x; + mbinfo = polyline[0].y; break; case 7: - mbinfo = polyline[1].y; + mbinfo = polyline[1].x; break; case 8: - mbinfo = polyline[2].x; + mbinfo = polyline[1].y; break; case 9: - mbinfo = polyline[2].y; + mbinfo = polyline[2].x; break; case 10: - mbinfo = polyline[3].x; + mbinfo = polyline[2].y; break; case 11: + mbinfo = polyline[3].x; + break; + + case 12: mbinfo = polyline[3].y; break; } } + else if (infokey == 2) + { + mbinfo = -1; + } } return mbinfo; diff --git a/src/pdflib/pdflib/p_object.c b/src/pdflib/pdflib/p_object.c index 8ff285c..2c2d28b 100644 --- a/src/pdflib/pdflib/p_object.c +++ b/src/pdflib/pdflib/p_object.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_object.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_object.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib PDF object functions * @@ -25,17 +25,17 @@ static const pdc_keyconn pdf_scope_keylist[] = { - {"object", pdf_state_object}, - {"document", pdf_state_document}, - {"page", pdf_state_page}, - {"pattern", pdf_state_pattern}, - {"template", pdf_state_template}, - {"path", pdf_state_path}, - {"font", pdf_state_font}, - {"glyph", pdf_state_glyph}, - {"glyphmetric", pdf_state_glyphmetric}, - {"glyphignore", pdf_state_glyphignore}, - {"error", pdf_state_error}, + {"object", pdf_state_object}, + {"document", pdf_state_document}, + {"page", pdf_state_page}, + {"pattern", pdf_state_pattern}, + {"template", pdf_state_template}, + {"path", pdf_state_path}, + {"font", pdf_state_font}, + {"glyph", pdf_state_glyph}, + {"glyphmetrics", pdf_state_glyphmetrics}, + {"glyphignore", pdf_state_glyphignore}, + {"error", pdf_state_error}, {NULL, 0} }; @@ -243,7 +243,10 @@ pdf__delete(PDF *p) if (p->out) + { pdc_free(p->pdc, p->out); + p->out = NULL; + } /* we never reach this point if (p->pdc == NULL). */ diff --git a/src/pdflib/pdflib/p_opi.c b/src/pdflib/pdflib/p_opi.c index 94cb435..2d2a308 100644 --- a/src/pdflib/pdflib/p_opi.c +++ b/src/pdflib/pdflib/p_opi.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_opi.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_opi.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib OPI routines * diff --git a/src/pdflib/pdflib/p_page.c b/src/pdflib/pdflib/p_page.c index c03aaf3..02be317 100644 --- a/src/pdflib/pdflib/p_page.c +++ b/src/pdflib/pdflib/p_page.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_page.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_page.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib page related routines * @@ -67,21 +67,6 @@ static const pdc_keyconn pdf_taborder_pdfkeylist[] = {NULL, 0} }; -static const pdc_keyconn pdf_colorspace_pdfkeylist[] = -{ - {"DeviceGray", color_gray}, - {"DeviceRGB", color_rgb}, - {"DeviceCMYK", color_cmyk}, - {NULL, 0} -}; - -typedef struct -{ - pdf_colortype colorspace; /* color space */ - pdc_bool isolated; /* isolated flag I */ - pdc_bool knockout; /* knockout flag K */ -} pg_transgroup; - typedef struct { pdf_labelstyle style; /* page label style */ @@ -160,7 +145,8 @@ typedef struct pdc_scalar userunit; /* page user unit */ char * action; /* "action" option string */ - pg_transgroup tgroup; /* transparency group definition */ + pdf_transgroup tgroup; /* transparency group definition */ + pdc_bool autotgroup; /* create transp. group automatically */ pdc_id * act_idlist; /* action object ids */ @@ -218,31 +204,28 @@ static const pdc_rectangle pdf_null_rect = /*********************** initialization & cleanup ***********************/ static void -pdf_init_ppt(PDF *p, pdc_bool new_ppt) +pdf_init_ppt(PDF *p) { pdf_ppt *ppt = p->curr_ppt; - if (new_ppt) - { - ppt->cstate = 0; - ppt->tstate = 0; + ppt->cstate = (pdf_cstate *) 0; + ppt->tstate = (pdf_tstate *) 0; - ppt->mboxes = (pdc_vtr *) 0; + ppt->mboxes = (pdc_vtr *) 0; - ppt->cs_bias = 0; - ppt->eg_bias = 0; - ppt->fn_bias = 0; - ppt->pt_bias = 0; - ppt->sh_bias = 0; - ppt->xo_bias = 0; - } +} /* pdf_init_ppt */ + +static void +pdf_init_ppt_states(PDF *p) +{ + pdf_ppt *ppt = p->curr_ppt; ppt->sl = 0; pdf_init_tstate(p); pdf_init_gstate(p); pdf_init_cstate(p); -} /* pdf_init_ppt */ +} /* pdf_init_ppt_states */ static void pdf_reset_ppt(pdf_ppt *ppt) @@ -305,6 +288,7 @@ pdf_init_page_obj(page_obj *po) po->tgroup.colorspace = color_none; po->tgroup.isolated = pdc_false; po->tgroup.knockout = pdc_false; + po->autotgroup = pdc_false; po->annots_id = PDC_BAD_ID; po->contents_id = PDC_BAD_ID; @@ -363,6 +347,9 @@ pdf_init_pages(PDF *p, const char **groups, int n_groups) dp->pages = (page_obj *) 0; dp->pnodes = (pdc_id *) 0; + p->curr_ppt = &dp->default_ppt; + pdf_init_ppt(p); + dp->pages_capacity = PAGES_CHUNKSIZE; dp->pages = (page_obj *) pdc_malloc(p->pdc, sizeof (page_obj) * dp->pages_capacity, fn); @@ -383,13 +370,6 @@ pdf_init_pages(PDF *p, const char **groups, int n_groups) dp->current_pnode = 0; dp->current_pnode_kids = 0; - /* clients may set char/word spacing and horizontal scaling outside pages - ** for PDF_stringwidth() calculations, and they may set a color for use - ** in PDF_makespotcolor(). that's what default_ppt is good for. - */ - p->curr_ppt = &dp->default_ppt; - pdf_init_ppt(p, pdc_true); - for (i = 0; i < n_groups - 1; ++i) for (k = i + 1; k < n_groups; ++k) if (strcmp(groups[i], groups[k]) == 0) @@ -410,6 +390,13 @@ pdf_init_pages(PDF *p, const char **groups, int n_groups) dp->groups[i].label.prefix = (char *) 0; dp->groups[i].label.start = 0; } + + /* clients may set char/word spacing and horizontal scaling outside pages + ** for PDF_stringwidth() calculations, and they may set a color for use + ** in PDF_makespotcolor(). that's what default_ppt is good for. + */ + pdf_init_ppt_states(p); + } /* pdf_init_pages */ @@ -806,22 +793,20 @@ pdf_write_pagelabels(PDF *p) static const pdc_defopt pdf_transgroup_options[] = { {"CS", pdc_keywordlist, PDC_OPT_NONE, 1, 1, - 1.0, PDC_INT_MAX, pdf_colorspace_pdfkeylist}, + 1.0, PDC_INT_MAX, pdf_tgroup_cs_pdfkeylist}, {"I", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, - {"K", pdc_booleanlist, PDC_OPT_NONE, 1, 1, \ - 0.0, 0.0, NULL}, \ + {"K", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, NULL}, PDC_OPT_TERMINATE }; -static void -pdf_set_transgroup(PDF *p, const char *optlist, int pageno) +void +pdf_set_transgroup(PDF *p, const char *optlist, pdf_transgroup *tgroup) { - pdf_pages * dp = p->doc_pages; - page_obj * po = &dp->pages[pageno]; pdc_resopt *resopts = NULL; int inum; @@ -829,29 +814,28 @@ pdf_set_transgroup(PDF *p, const char *optlist, int pageno) NULL, pdc_true); if (pdc_get_optvalues("CS", resopts, &inum, NULL)) - po->tgroup.colorspace = (pdf_colortype) inum; + tgroup->colorspace = (pdf_colortype) inum; - pdc_get_optvalues("I", resopts, &po->tgroup.isolated, NULL); - pdc_get_optvalues("K", resopts, &po->tgroup.knockout, NULL); + pdc_get_optvalues("I", resopts, &tgroup->isolated, NULL); + pdc_get_optvalues("K", resopts, &tgroup->knockout, NULL); } -static void -write_transgroup(PDF *p, int pageno) +void +pdf_write_transgroup(PDF *p, pdf_transgroup *tgroup) { - pdf_pages * dp = p->doc_pages; - page_obj *po = &dp->pages[pageno]; - pdc_puts(p->out, "/Group"); pdc_begin_dict(p->out); - pdc_printf(p->out, "/S/Transparency/CS/%s", - pdc_get_keyword(po->tgroup.colorspace, - pdf_colorspace_pdfkeylist)); - if (po->tgroup.isolated) - pdc_printf(p->out, "/I true"); + pdc_puts(p->out, "/S/Transparency/CS/"); + + pdc_printf(p->out, "%s", pdc_get_keyword(tgroup->colorspace, + pdf_tgroup_cs_pdfkeylist)); - if (po->tgroup.knockout) - pdc_printf(p->out, "/K true"); + if (tgroup->isolated) + pdc_puts(p->out, "/I true"); + + if (tgroup->knockout) + pdc_puts(p->out, "/K true"); pdc_end_dict(p->out); } @@ -949,7 +933,7 @@ pdf_search_page_bwd(PDF *p, int start_page, pdc_id id) } /* pdf_search_page_bwd */ -double +pdc_scalar pdf_get_pageheight(PDF *p) { pdf_pages * dp = p->doc_pages; @@ -1099,12 +1083,21 @@ pdf_get_thumb_id(PDF *p) void pdf_set_thumb_id(PDF *p, pdc_id id) { - pdf_pages * dp = p->doc_pages; - page_obj * po = &dp->pages[dp->current_page]; + pdf_pages * dp = p->doc_pages; + page_obj * po = &dp->pages[dp->current_page]; po->thumb_id = id; } /* pdf_set_thumb_id */ +void +pdf_set_autotgroup(PDF *p, pdc_bool autotgroup) +{ + pdf_pages * dp = p->doc_pages; + page_obj * po = &dp->pages[dp->current_page]; + + po->autotgroup = autotgroup; +} /* pdf_set_thumb_id */ + /************************* contents sections ***************************/ @@ -1323,7 +1316,7 @@ pdf_write_pages_tree(PDF *p) pdc_printf(p->out, "/Tabs/%s\n", pdc_get_keyword(po->taborder, pdf_taborder_pdfkeylist)); - if (po->userunit > 1.0) + if (po->userunit != 1.0) pdc_printf(p->out, "/UserUnit %f\n", po->userunit); if (po->rotate > 0) @@ -1345,8 +1338,11 @@ pdf_write_pages_tree(PDF *p) pdc_end_dict(p->out); } + if (po->tgroup.colorspace == color_none && po->autotgroup) + po->tgroup.colorspace = color_rgb; + if (po->tgroup.colorspace != color_none) - write_transgroup(p, i); + pdf_write_transgroup(p, &po->tgroup); pdf_write_box(p, po->boxes[pdf_artbox], "ArtBox"); pdf_write_box(p, po->boxes[pdf_bleedbox], "BleedBox"); @@ -1532,7 +1528,7 @@ static const pdc_keyconn pdf_userunit_keylist[] = {"transition", pdc_keywordlist, PDC_OPT_NONE, 1, 1, \ 0.0, 0.0, pdf_transition_keylist}, \ \ - {"transparencygroup", pdc_stringlist, PDC_OPT_NONE, 1, 1, \ + {"transparencygroup", pdc_stringlist, PDC_OPT_PDC_1_4, 1, 1, \ 1.0, PDF_MAX_NAMESTRING, NULL}, \ \ {"taborder", pdc_keywordlist, PDC_OPT_PDC_1_5, 1, 1, \ @@ -1643,8 +1639,8 @@ get_page_options3(PDF *p, pdc_resopt *resopts, pdc_bool end_page) pdc_get_optvalues("taborder", resopts, &po->taborder, NULL); pdc_get_optvalues("duration", resopts, &po->duration, NULL); pdc_get_optvalues("userunit", resopts, &po->userunit, NULL); - if (po->userunit < 1.0) - po->userunit = 72.0 / (PDC_INCH2METER * fabs(po->userunit)); + if (po->userunit < 0.0) + po->userunit = 72.0 / (PDC_INCH2METER * -po->userunit); if (pdc_get_optvalues("label", resopts, NULL, NULL)) { @@ -1654,7 +1650,7 @@ get_page_options3(PDF *p, pdc_resopt *resopts, pdc_bool end_page) } if (pdc_get_optvalues("transparencygroup", resopts, NULL, &slist)) - pdf_set_transgroup(p, slist[0], pageno); + pdf_set_transgroup(p, slist[0], &po->tgroup); /* the "width" and "height" options must be processed BEFORE the ** "mediabox" option, since the latter dominates over the formers. @@ -1711,6 +1707,8 @@ get_page_options3(PDF *p, pdc_resopt *resopts, pdc_bool end_page) } /* get_page_options3 */ +#if 0 +#endif static const pdc_defopt pdf_begin_page_ext_options[] = { @@ -1807,6 +1805,7 @@ pdf__begin_page_ext( pg = dp->curr_pg = (pdf_page *) pdc_malloc(p->pdc, sizeof (pdf_page), fn); p->curr_ppt = &pg->ppt; + pdf_init_ppt(p); pg->contents_ids = (pdc_id *) 0; pg->annots = (pdc_vtr *) 0; @@ -1845,7 +1844,7 @@ pdf__begin_page_ext( /* initialize the current ppt descriptor. p->ydirection ** must be set before pdf_init_ppt()! */ - pdf_init_ppt(p, pdc_true); + pdf_init_ppt_states(p); pg->next_content = 0; @@ -1866,6 +1865,8 @@ pdf__begin_page_ext( /* set color differing from PDF default */ pdf_set_default_color(p, pdc_false); +#if 0 +#endif if (!p->pdc->smokerun) @@ -1903,6 +1904,7 @@ pdf_pg_suspend(PDF *p) { pdf_page *pg = dp->curr_pg; + pdf_end_contents_section(p); /* restore global parms. @@ -1925,7 +1927,7 @@ pdf_pg_suspend(PDF *p) p->curr_ppt = &dp->default_ppt; } - pdf_init_ppt(p, pdc_false); + pdf_init_ppt_states(p); } /* pdf_pg_suspend */ @@ -2131,6 +2133,8 @@ pdf__end_page_ext(PDF *p, const char *optlist) /* TODO (york): avoid memory leak in error case. */ pg = dp->curr_pg; +#if 0 +#endif pdf_end_contents_section(p); @@ -2210,7 +2214,7 @@ pdf__end_page_ext(PDF *p, const char *optlist) /* restore the default ppt for out-of-page usage. */ p->curr_ppt = &dp->default_ppt; - pdf_init_ppt(p, pdc_false); + pdf_init_ppt_states(p); PDF_SET_STATE(p, pdf_state_document); pdf_delete_page(p, pg); dp->curr_pg = (pdf_page *) 0; @@ -2259,3 +2263,4 @@ pdf_set_transition(PDF *p, const char *transition) p->doc_pages->transition = i; } + diff --git a/src/pdflib/pdflib/p_page.h b/src/pdflib/pdflib/p_page.h index 3f496e4..acfd861 100644 --- a/src/pdflib/pdflib/p_page.h +++ b/src/pdflib/pdflib/p_page.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_page.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_page.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Header file for the PDFlib page system * diff --git a/src/pdflib/pdflib/p_pantlab.h b/src/pdflib/pdflib/p_pantlab.h index 79c35cc..67ad728 100644 --- a/src/pdflib/pdflib/p_pantlab.h +++ b/src/pdflib/pdflib/p_pantlab.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_pantlab.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_pantlab.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib PANTONE spot LAB color table derived from * PANTONE MATCHING SYSTEM diff --git a/src/pdflib/pdflib/p_params.c b/src/pdflib/pdflib/p_params.c index e55a8b1..efe2c87 100644 --- a/src/pdflib/pdflib/p_params.c +++ b/src/pdflib/pdflib/p_params.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_params.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_params.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib parameter handling * @@ -25,12 +25,8 @@ #include "p_page.h" #include "p_tagged.h" -static const pdc_keyconn pdf_fillrule_keylist[] = -{ - {"winding", pdf_fill_winding }, - {"evenodd", pdf_fill_evenodd }, - {NULL, 0} -}; +#include "pc_scope.h" +#include "pc_file.h" /* * PDF_get_parameter() and PDF_set_parameter() deal with strings, @@ -42,6 +38,7 @@ typedef struct char * name; /* parameter name */ pdc_bool mod_zero; /* PDF_get_() modifier argument must be 0 */ pdc_bool check_scope; /* check following scope for PDF_get_...() */ + int deprecated; /* deprecated and unsupported level */ int scope; /* bit mask of legal states */ } @@ -53,7 +50,7 @@ static pdf_parm_descr parms[] = #include "p_params.h" #undef pdf_gen_parm_descr - { "", 0, 0, 0 } + { "", 0, 0, 0, 0 } }; enum @@ -78,9 +75,26 @@ pdf_get_index(PDF *p, const char *key, pdc_bool setpar) if (pdc_stricmp(key, parms[i].name) == 0) { if ((setpar || parms[i].check_scope) && - (p->state_stack[p->state_sp] & parms[i].scope) == 0) - pdc_error(p->pdc, PDF_E_DOC_SCOPE_SET, key, - pdf_current_scope(p), 0, 0); + (p->state_stack[p->state_sp] & parms[i].scope) == 0 && + (p->state_stack[p->state_sp] & pdf_state_glyphignore) == 0) + { + pdc_error(p->pdc, + setpar ? PDF_E_DOC_SCOPE_SET : PDF_E_DOC_SCOPE_GET, + key, pdf_current_scope(p), 0, 0); + } + + if (parms[i].deprecated > 0) + { + pdc_logg_cond(p->pdc, 2, trc_api, + "[Parameter \"%s\" is deprecated since PDFlib %d]\n", + key, parms[i].deprecated); + } + else if (parms[i].deprecated < 0) + { + pdc_logg_cond(p->pdc, 2, trc_api, + "[Parameter \"%s\" is unsupported]\n", key); + } + return i; } } @@ -110,7 +124,7 @@ pdf__set_parameter(PDF *p, const char *key, const char *value) { pdc_pagebox usebox = pdc_pbox_none; pdc_text_format textformat = pdc_auto; - char optlist[512]; + char optlist[PDC_GEN_BUFSIZE]; pdf_ppt *ppt; int i, k; @@ -131,9 +145,7 @@ pdf__set_parameter(PDF *p, const char *key, const char *value) if (k == PDC_KEY_NOTFOUND) pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); usebox = (pdc_pagebox) k; - strcpy(optlist, key); - strcat(optlist, " "); - strcat(optlist, value); + pdc_sprintf(p->pdc, pdc_false, optlist, "%s %s", key, value); break; case PDF_PARAMETER_TEXTFORMAT: @@ -156,7 +168,7 @@ pdf__set_parameter(PDF *p, const char *key, const char *value) case PDF_PARAMETER_ICCPROFILE: case PDF_PARAMETER_STANDARDOUTPUTINTENT: { - pdf_add_resource(p, key, value); + pdf_add_pdflib_resource(p, key, value); break; } @@ -393,8 +405,7 @@ pdf__set_parameter(PDF *p, const char *key, const char *value) } case PDF_PARAMETER_TRACEFILE: - strcpy(optlist, "filename "); - strcat(optlist, value); + pdc_sprintf(p->pdc, pdc_false, optlist, "filename %s", value); pdc_set_logg_options(p->pdc, optlist); break; @@ -567,6 +578,15 @@ pdf__set_value(PDF *p, const char *key, double value) switch (i) { +#if defined(WIN32) && !defined(__BORLANDC__) + case PDF_PARAMETER_MAXFILEHANDLES: + ivalue = pdc_set_maxfilehandles(p->pdc, ivalue); + if (ivalue == -1) + pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, + pdc_errprintf(p->pdc, "%f", value), key, 0, 0); + break; +#endif + case PDF_PARAMETER_COMPRESS: if (ivalue < 0 || ivalue > 9) pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, @@ -827,6 +847,12 @@ pdf__get_value(PDF *p, const char *key, double mod) switch (i) { +#if defined(WIN32) && !defined(__BORLANDC__) + case PDF_PARAMETER_MAXFILEHANDLES: + result = (double) pdc_get_maxfilehandles(); + break; +#endif + case PDF_PARAMETER_COMPRESS: result = (double) pdc_get_compresslevel(p->out); break; @@ -1126,6 +1152,10 @@ pdf__get_parameter(PDF *p, const char *key, double mod) result = "lite"; break; + case PDF_PARAMETER_PRODUCT: + result = "PDFlib Lite"; + break; + case PDF_PARAMETER_ERRORPOLICY: result = pdc_get_keyword(p->errorpolicy, pdf_errpol_keylist); break; diff --git a/src/pdflib/pdflib/p_params.h b/src/pdflib/pdflib/p_params.h index 12bbf6d..3fdcd75 100644 --- a/src/pdflib/pdflib/p_params.h +++ b/src/pdflib/pdflib/p_params.h @@ -10,40 +10,39 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_params.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_params.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib parameter table * */ #if pdf_gen_parm_enum -#define pdf_gen1(code, name, zero, check, scope) PDF_PARAMETER_##code, +#define pdf_gen1(code, name, zero, check, depr, scope) PDF_PARAMETER_##code, #elif pdf_gen_parm_descr -#define pdf_gen1(code, name, zero, check, scope) \ - { name, zero, check, scope }, +#define pdf_gen1(code, name, zero, check, depr, scope) \ + { name, zero, check, depr, scope }, #else #error invalid inclusion of generator file #endif /* - * Deprecated and unsupported parameters: - * dep7 Deprecated since PDFlib 7 - * dep6 Deprecated since PDFlib 6 - * dep5 Deprecated since PDFlib 5 - * unsupp Unsupported (internal use, dysfunctional, or other) + * Deprecated and unsupported parameters (see variable depr = i): + * i = 0: Neither deprecated nor unsupported + * i > 0: Deprecated since PDFlib i + * i =-1: Unsupported (internal use, dysfunctional, or other) */ /* List of unsupported control characters for the "debug" parameter: 2 disable the search for the Windows color directory via mscms.dll e extract embedded ICC profiles from image files - F throw an exception in PDF_load_font (dep7); - g throw an exception in PDF_fit_textline and PDF_show (dep7) + F throw an exception in PDF_load_font (depr = 7); + g throw an exception in PDF_fit_textline and PDF_show (depr = 7) h disable host font processing - i throw an exception in PDF_load_image (dep7) - I throw an exception in PDF_load_iccprofile (dep7); - o throw an exception in PDF_begin_document (dep7) - p throw an exception in PDF_open_pdi (dep7) + i throw an exception in PDF_load_image (depr = 7) + I throw an exception in PDF_load_iccprofile (depr = 7); + o throw an exception in PDF_begin_document (depr = 7) + p throw an exception in PDF_open_pdi (depr = 7) On by default: e F I */ @@ -55,44 +54,46 @@ * ---------------------------------------------------------------------- */ -pdf_gen1(OPENWARNING, "openwarning", 1, 1, pdf_state_all) /* dep6 */ -pdf_gen1(COMPRESS, "compress", 1, 1, +pdf_gen1(OPENWARNING, "openwarning", 1, 1, 6, pdf_state_all) +pdf_gen1(COMPRESS, "compress", 1, 1, 0, pdf_state_page | pdf_state_document) -pdf_gen1(FLUSH, "flush", 1, 1, pdf_state_all) /* dep6 */ -pdf_gen1(RESOURCEFILE, "resourcefile", 1, 1, pdf_state_all) -pdf_gen1(COMPATIBILITY, "compatibility",1, 0, pdf_state_object) /* dep6 */ -pdf_gen1(PDFX, "pdfx", 1, 0, pdf_state_object) /* dep6 */ -pdf_gen1(SEARCHPATH, "SearchPath", 0, 1, pdf_state_all) -pdf_gen1(ASCIIFILE, "asciifile", 1, 1, pdf_state_all) -pdf_gen1(WARNING, "warning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(ERRORPOLICY, "errorpolicy", 1, 1, pdf_state_all) -pdf_gen1(NODEMOSTAMP, "nodemostamp", 1, 0, pdf_state_object) -pdf_gen1(LICENSE, "license", 1, 0, pdf_state_object) -pdf_gen1(LICENCE, "licence", 1, 0, pdf_state_object) /* unsupp */ -pdf_gen1(LICENSEFILE, "licensefile", 1, 0, pdf_state_object) -pdf_gen1(LICENCEFILE, "licencefile", 1, 0, pdf_state_object) /* unsupp */ -pdf_gen1(TRACE, "trace", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(TRACEFILE, "tracefile", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(TRACEMSG, "tracemsg", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(LOGGING, "logging", 1, 1, pdf_state_all) -pdf_gen1(LOGMSG, "logmsg", 1, 1, pdf_state_all) -pdf_gen1(CHARREF, "charref", 1, 1, pdf_state_all) -pdf_gen1(ESCAPESEQUENCE,"escapesequence",1,1, pdf_state_all) -pdf_gen1(HONORLANG, "honorlang", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(STRING, "string", 0, 1, pdf_state_all) -pdf_gen1(SCOPE, "scope", 1, 1, pdf_state_all) - -pdf_gen1(SERIAL, "serial", 1, 0, pdf_state_object) /* unsupp */ -pdf_gen1(FLOATDIGITS, "floatdigits", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(BINDING, "binding", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(OBJORIENT, "objorient", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(HASTOBEPOS, "hastobepos", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(UNICAPLANG, "unicaplang", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(DEBUG, "debug", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(NODEBUG, "nodebug", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(PTFRUN, "ptfrun", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(SMOKERUN, "smokerun", 1, 1, pdf_state_all) /* unsupp */ -pdf_gen1(CONFIGURATION, "configuration",1, 1, pdf_state_all) /* unsupp */ +pdf_gen1(FLUSH, "flush", 1, 1, 6, pdf_state_all) +pdf_gen1(RESOURCEFILE, "resourcefile", 1, 1, 0, pdf_state_all) +pdf_gen1(COMPATIBILITY, "compatibility",1, 0, 6, pdf_state_object) +pdf_gen1(PDFX, "pdfx", 1, 0, 6, pdf_state_object) +pdf_gen1(SEARCHPATH, "SearchPath", 0, 1, 0, pdf_state_all) +pdf_gen1(ASCIIFILE, "asciifile", 1, 1, 0, pdf_state_all) +pdf_gen1(WARNING, "warning", 1, 1, 7, pdf_state_all) +pdf_gen1(ERRORPOLICY, "errorpolicy", 1, 1, 0, pdf_state_all) +pdf_gen1(NODEMOSTAMP, "nodemostamp", 1, 0, 0, pdf_state_object) +pdf_gen1(LICENSE, "license", 1, 0, 0, pdf_state_object) +pdf_gen1(LICENCE, "licence", 1, 0,-1, pdf_state_object) +pdf_gen1(LICENSEFILE, "licensefile", 1, 0, 0, pdf_state_object) +pdf_gen1(LICENCEFILE, "licencefile", 1, 0,-1, pdf_state_object) +pdf_gen1(TRACE, "trace", 1, 1, 7, pdf_state_all) +pdf_gen1(TRACEFILE, "tracefile", 1, 1, 7, pdf_state_all) +pdf_gen1(TRACEMSG, "tracemsg", 1, 1, 7, pdf_state_all) +pdf_gen1(LOGGING, "logging", 1, 1, 0, pdf_state_all) +pdf_gen1(LOGMSG, "logmsg", 1, 1, 0, pdf_state_all) +pdf_gen1(CHARREF, "charref", 1, 1, 0, pdf_state_all) +pdf_gen1(ESCAPESEQUENCE,"escapesequence",1,1, 0, pdf_state_all) +pdf_gen1(HONORLANG, "honorlang", 1, 1,-1, pdf_state_all) +pdf_gen1(STRING, "string", 0, 1, 0, pdf_state_all) +pdf_gen1(SCOPE, "scope", 1, 1, 0, pdf_state_all) + +pdf_gen1(SERIAL, "serial", 1, 0,-1, pdf_state_object) +pdf_gen1(FLOATDIGITS, "floatdigits", 1, 1,-1, pdf_state_all) +pdf_gen1(BINDING, "binding", 1, 1,-1, pdf_state_all) +pdf_gen1(OBJORIENT, "objorient", 1, 1,-1, pdf_state_all) +pdf_gen1(HASTOBEPOS, "hastobepos", 1, 1,-1, pdf_state_all) +pdf_gen1(UNICAPLANG, "unicaplang", 1, 1,-1, pdf_state_all) +pdf_gen1(DEBUG, "debug", 1, 1,-1, pdf_state_all) +pdf_gen1(NODEBUG, "nodebug", 1, 1,-1, pdf_state_all) +pdf_gen1(PTFRUN, "ptfrun", 1, 1,-1, pdf_state_all) +pdf_gen1(SMOKERUN, "smokerun", 1, 1,-1, pdf_state_all) +pdf_gen1(CONFIGURATION, "configuration",1, 1,-1, pdf_state_all) +pdf_gen1(PRODUCT, "product", 1, 1,-1, pdf_state_all) +pdf_gen1(MAXFILEHANDLES,"maxfilehandles",1, 1,-1, pdf_state_object) /* @@ -101,10 +102,10 @@ pdf_gen1(CONFIGURATION, "configuration",1, 1, pdf_state_all) /* unsupp */ * ---------------------------------------------------------------------- */ -pdf_gen1(MAJOR, "major", 1, 1, pdf_state_all) -pdf_gen1(MINOR, "minor", 1, 1, pdf_state_all) -pdf_gen1(REVISION, "revision", 1, 1, pdf_state_all) -pdf_gen1(VERSION, "version", 1, 1, pdf_state_all) +pdf_gen1(MAJOR, "major", 1, 1, 0, pdf_state_all) +pdf_gen1(MINOR, "minor", 1, 1, 0, pdf_state_all) +pdf_gen1(REVISION, "revision", 1, 1, 0, pdf_state_all) +pdf_gen1(VERSION, "version", 1, 1, 0, pdf_state_all) /* @@ -115,24 +116,24 @@ pdf_gen1(VERSION, "version", 1, 1, pdf_state_all) /* all of the following group are dep6 */ -pdf_gen1(PAGEWIDTH, "pagewidth", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(PAGEHEIGHT, "pageheight", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(CROPBOX_LLX, "CropBox/llx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(CROPBOX_LLY, "CropBox/lly", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(CROPBOX_URX, "CropBox/urx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(CROPBOX_URY, "CropBox/ury", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(BLEEDBOX_LLX, "BleedBox/llx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(BLEEDBOX_LLY, "BleedBox/lly", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(BLEEDBOX_URX, "BleedBox/urx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(BLEEDBOX_URY, "BleedBox/ury", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(TRIMBOX_LLX, "TrimBox/llx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(TRIMBOX_LLY, "TrimBox/lly", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(TRIMBOX_URX, "TrimBox/urx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(TRIMBOX_URY, "TrimBox/ury", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(ARTBOX_LLX, "ArtBox/llx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(ARTBOX_LLY, "ArtBox/lly", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(ARTBOX_URX, "ArtBox/urx", 1, 1, pdf_state_page | pdf_state_path) -pdf_gen1(ARTBOX_URY, "ArtBox/ury", 1, 1, pdf_state_page | pdf_state_path) +pdf_gen1(PAGEWIDTH, "pagewidth", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(PAGEHEIGHT, "pageheight", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_LLX, "CropBox/llx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_LLY, "CropBox/lly", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_URX, "CropBox/urx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_URY, "CropBox/ury", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_LLX, "BleedBox/llx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_LLY, "BleedBox/lly", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_URX, "BleedBox/urx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_URY, "BleedBox/ury", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_LLX, "TrimBox/llx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_LLY, "TrimBox/lly", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_URX, "TrimBox/urx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_URY, "TrimBox/ury", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_LLX, "ArtBox/llx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_LLY, "ArtBox/lly", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_URX, "ArtBox/urx", 1, 1, 0, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_URY, "ArtBox/ury", 1, 1, 0, pdf_state_page | pdf_state_path) /* @@ -141,34 +142,34 @@ pdf_gen1(ARTBOX_URY, "ArtBox/ury", 1, 1, pdf_state_page | pdf_state_path) * ---------------------------------------------------------------------- */ -pdf_gen1(FONTAFM, "FontAFM", 0, 1, pdf_state_all) -pdf_gen1(FONTPFM, "FontPFM", 0, 1, pdf_state_all) -pdf_gen1(FONTOUTLINE, "FontOutline", 0, 1, pdf_state_all) -pdf_gen1(HOSTFONT, "HostFont", 0, 1, pdf_state_all) -pdf_gen1(ENCODING, "Encoding", 0, 1, pdf_state_all) -pdf_gen1(FONTWARNING, "fontwarning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(FONT, "font", 1, 1, pdf_state_content) -pdf_gen1(FONTSIZE, "fontsize", 1, 1, pdf_state_content) - -pdf_gen1(SUBSETLIMIT, "subsetlimit", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(SUBSETMINSIZE, "subsetminsize",1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(AUTOSUBSETTING,"autosubsetting",1,1, pdf_state_all) /* dep7 */ -pdf_gen1(AUTOCIDFONT, "autocidfont", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(UNICODEMAP, "unicodemap", 1, 1, pdf_state_all) /* dep7 */ - -pdf_gen1(FONTNAME, "fontname", 1, 1, pdf_state_content) /* dep7 */ -pdf_gen1(FONTSTYLE, "fontstyle", 1, 1, pdf_state_content) /* dep7 */ -pdf_gen1(FONTENCODING, "fontencoding", 1, 1, pdf_state_content) /* dep7 */ -pdf_gen1(MONOSPACE, "monospace", 1, 1, pdf_state_content) /* dep7 */ -pdf_gen1(FONTMAXCODE, "fontmaxcode", 0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(ASCENDER, "ascender", 0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(DESCENDER, "descender", 0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(CAPHEIGHT, "capheight", 0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(XHEIGHT, "xheight", 0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(ASCENDERFAKED, "ascenderfaked",0, 1, pdf_state_all) /* dep7 */ -pdf_gen1(DESCENDERFAKED,"descenderfaked",0,1, pdf_state_all) /* dep7 */ -pdf_gen1(CAPHEIGHTFAKED,"capheightfaked",0,1, pdf_state_all) /* dep7 */ -pdf_gen1(XHEIGHTFAKED, "xheightfaked", 0,1, pdf_state_all) /* dep7 */ +pdf_gen1(FONTAFM, "FontAFM", 0, 1, 0, pdf_state_all) +pdf_gen1(FONTPFM, "FontPFM", 0, 1, 0, pdf_state_all) +pdf_gen1(FONTOUTLINE, "FontOutline", 0, 1, 0, pdf_state_all) +pdf_gen1(HOSTFONT, "HostFont", 0, 1, 0, pdf_state_all) +pdf_gen1(ENCODING, "Encoding", 0, 1, 0, pdf_state_all) +pdf_gen1(FONTWARNING, "fontwarning", 1, 1, 7, pdf_state_all) +pdf_gen1(FONT, "font", 1, 1, 0, pdf_state_content) +pdf_gen1(FONTSIZE, "fontsize", 1, 1, 0, pdf_state_content) + +pdf_gen1(SUBSETLIMIT, "subsetlimit", 1, 1, 7, pdf_state_all) +pdf_gen1(SUBSETMINSIZE, "subsetminsize",1, 1, 7, pdf_state_all) +pdf_gen1(AUTOSUBSETTING,"autosubsetting",1,1, 7, pdf_state_all) +pdf_gen1(AUTOCIDFONT, "autocidfont", 1, 1, 7, pdf_state_all) +pdf_gen1(UNICODEMAP, "unicodemap", 1, 1, 7, pdf_state_all) + +pdf_gen1(FONTNAME, "fontname", 1, 1, 7, pdf_state_content) +pdf_gen1(FONTSTYLE, "fontstyle", 1, 1, 7, pdf_state_content) +pdf_gen1(FONTENCODING, "fontencoding", 1, 1, 7, pdf_state_content) +pdf_gen1(MONOSPACE, "monospace", 1, 1, 7, pdf_state_content) +pdf_gen1(FONTMAXCODE, "fontmaxcode", 0, 1, 7, pdf_state_all) +pdf_gen1(ASCENDER, "ascender", 0, 1, 7, pdf_state_all) +pdf_gen1(DESCENDER, "descender", 0, 1, 7, pdf_state_all) +pdf_gen1(CAPHEIGHT, "capheight", 0, 1, 7, pdf_state_all) +pdf_gen1(XHEIGHT, "xheight", 0, 1, 7, pdf_state_all) +pdf_gen1(ASCENDERFAKED, "ascenderfaked",0, 1, 7, pdf_state_all) +pdf_gen1(DESCENDERFAKED,"descenderfaked",0,1, 7, pdf_state_all) +pdf_gen1(CAPHEIGHTFAKED,"capheightfaked",0,1, 7, pdf_state_all) +pdf_gen1(XHEIGHTFAKED, "xheightfaked", 0,1, 7, pdf_state_all) /* @@ -177,32 +178,32 @@ pdf_gen1(XHEIGHTFAKED, "xheightfaked", 0,1, pdf_state_all) /* dep7 */ * ---------------------------------------------------------------------- */ -pdf_gen1(TEXTX, "textx", 1, 1, pdf_state_content) -pdf_gen1(TEXTY, "texty", 1, 1, pdf_state_content) -pdf_gen1(LEADING, "leading", 1, 1, pdf_state_content) -pdf_gen1(TEXTRISE, "textrise", 1, 1, pdf_state_content) -pdf_gen1(HORIZSCALING, "horizscaling", 1, 1, +pdf_gen1(TEXTX, "textx", 1, 1, 0, pdf_state_content) +pdf_gen1(TEXTY, "texty", 1, 1, 0, pdf_state_content) +pdf_gen1(LEADING, "leading", 1, 1, 0, pdf_state_content) +pdf_gen1(TEXTRISE, "textrise", 1, 1, 0, pdf_state_content) +pdf_gen1(HORIZSCALING, "horizscaling", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(TEXTRENDERING, "textrendering",1, 1, pdf_state_content) -pdf_gen1(CHARSPACING, "charspacing", 1, 1, +pdf_gen1(TEXTRENDERING, "textrendering",1, 1, 0, pdf_state_content) +pdf_gen1(CHARSPACING, "charspacing", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(WORDSPACING, "wordspacing", 1, 1, +pdf_gen1(WORDSPACING, "wordspacing", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(ITALICANGLE, "italicangle", 1, 1, +pdf_gen1(ITALICANGLE, "italicangle", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(FAKEBOLD, "fakebold", 1, 1, +pdf_gen1(FAKEBOLD, "fakebold", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(UNDERLINEWIDTH,"underlinewidth", 1, 1, +pdf_gen1(UNDERLINEWIDTH,"underlinewidth", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(UNDERLINEPOSITION,"underlineposition", 1, 1, +pdf_gen1(UNDERLINEPOSITION,"underlineposition", 1, 1, 0, pdf_state_content | pdf_state_document) -pdf_gen1(UNDERLINE, "underline", 1, 1, pdf_state_content) -pdf_gen1(OVERLINE, "overline", 1, 1, pdf_state_content) -pdf_gen1(STRIKEOUT, "strikeout", 1, 1, pdf_state_content) -pdf_gen1(KERNING, "kerning", 1, 1, pdf_state_all) -pdf_gen1(TEXTFORMAT, "textformat", 1, 1, pdf_state_all) -pdf_gen1(GLYPHWARNING, "glyphwarning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(GLYPHCHECK, "glyphcheck", 1, 1, pdf_state_all) +pdf_gen1(UNDERLINE, "underline", 1, 1, 0, pdf_state_content) +pdf_gen1(OVERLINE, "overline", 1, 1, 0, pdf_state_content) +pdf_gen1(STRIKEOUT, "strikeout", 1, 1, 0, pdf_state_content) +pdf_gen1(KERNING, "kerning", 1, 1, 0, pdf_state_all) +pdf_gen1(TEXTFORMAT, "textformat", 1, 1, 0, pdf_state_all) +pdf_gen1(GLYPHWARNING, "glyphwarning", 1, 1, 7, pdf_state_all) +pdf_gen1(GLYPHCHECK, "glyphcheck", 1, 1, 0, pdf_state_all) /* @@ -211,18 +212,18 @@ pdf_gen1(GLYPHCHECK, "glyphcheck", 1, 1, pdf_state_all) * ---------------------------------------------------------------------- */ -pdf_gen1(CURRENTX, "currentx", 1, 1, +pdf_gen1(CURRENTX, "currentx", 1, 1, 0, pdf_state_content | pdf_state_path) -pdf_gen1(CURRENTY, "currenty", 1, 1, +pdf_gen1(CURRENTY, "currenty", 1, 1, 0, pdf_state_content | pdf_state_path) -pdf_gen1(FILLRULE, "fillrule", 1, 1, pdf_state_content) -pdf_gen1(TOPDOWN, "topdown", 1, 0, pdf_state_document) -pdf_gen1(CTM_A, "ctm_a", 1, 1, pdf_state_content) -pdf_gen1(CTM_B, "ctm_b", 1, 1, pdf_state_content) -pdf_gen1(CTM_C, "ctm_c", 1, 1, pdf_state_content) -pdf_gen1(CTM_D, "ctm_d", 1, 1, pdf_state_content) -pdf_gen1(CTM_E, "ctm_e", 1, 1, pdf_state_content) -pdf_gen1(CTM_F, "ctm_f", 1, 1, pdf_state_content) +pdf_gen1(FILLRULE, "fillrule", 1, 1, 0, pdf_state_content) +pdf_gen1(TOPDOWN, "topdown", 1, 0, 0, pdf_state_document) +pdf_gen1(CTM_A, "ctm_a", 1, 1, 0, pdf_state_content) +pdf_gen1(CTM_B, "ctm_b", 1, 1, 0, pdf_state_content) +pdf_gen1(CTM_C, "ctm_c", 1, 1, 0, pdf_state_content) +pdf_gen1(CTM_D, "ctm_d", 1, 1, 0, pdf_state_content) +pdf_gen1(CTM_E, "ctm_e", 1, 1, 0, pdf_state_content) +pdf_gen1(CTM_F, "ctm_f", 1, 1, 0, pdf_state_content) /* @@ -231,32 +232,33 @@ pdf_gen1(CTM_F, "ctm_f", 1, 1, pdf_state_content) * ---------------------------------------------------------------------- */ -pdf_gen1(SETCOLOR_ICCPROFILEGRAY, "setcolor:iccprofilegray", 1, 1, +pdf_gen1(SETCOLOR_ICCPROFILEGRAY, "setcolor:iccprofilegray", 1, 1, 0, pdf_state_document | pdf_state_content) -pdf_gen1(SETCOLOR_ICCPROFILERGB, "setcolor:iccprofilergb", 1, 1, +pdf_gen1(SETCOLOR_ICCPROFILERGB, "setcolor:iccprofilergb", 1, 1, 0, pdf_state_document | pdf_state_content) -pdf_gen1(SETCOLOR_ICCPROFILECMYK, "setcolor:iccprofilecmyk", 1, 1, +pdf_gen1(SETCOLOR_ICCPROFILECMYK, "setcolor:iccprofilecmyk", 1, 1, 0, pdf_state_document | pdf_state_content) -pdf_gen1(IMAGE_ICCPROFILE,"image:iccprofile", 0, 1, +pdf_gen1(IMAGE_ICCPROFILE,"image:iccprofile", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(ICCWARNING, "iccwarning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(HONORICCPROFILE, "honoriccprofile", 1, 1, pdf_state_all) -pdf_gen1(ICCCOMPONENTS, "icccomponents", 0, 1, pdf_state_all) -pdf_gen1(ICCPROFILE, "ICCProfile", 0, 1, pdf_state_all) -pdf_gen1(STANDARDOUTPUTINTENT, "StandardOutputIntent", 0, 1, pdf_state_all) -pdf_gen1(RENDERINGINTENT, "renderingintent", 1, 1, pdf_state_all) +pdf_gen1(ICCWARNING, "iccwarning", 1, 1, 7, + pdf_state_all) +pdf_gen1(HONORICCPROFILE, "honoriccprofile", 1, 1, 0, pdf_state_all) +pdf_gen1(ICCCOMPONENTS, "icccomponents", 0, 1, 0, pdf_state_all) +pdf_gen1(ICCPROFILE, "ICCProfile", 0, 1, 0, pdf_state_all) +pdf_gen1(STANDARDOUTPUTINTENT, "StandardOutputIntent", 0, 1, 0, pdf_state_all) +pdf_gen1(RENDERINGINTENT, "renderingintent", 1, 1, 0, pdf_state_all) /* 3 x dep6 */ -pdf_gen1(DEFAULTRGB, "defaultrgb", 1, 1, +pdf_gen1(DEFAULTRGB, "defaultrgb", 1, 1, 0, pdf_state_content | pdf_state_path) -pdf_gen1(DEFAULTGRAY, "defaultgray", 1, 1, +pdf_gen1(DEFAULTGRAY, "defaultgray", 1, 1, 0, pdf_state_content | pdf_state_path) -pdf_gen1(DEFAULTCMYK, "defaultcmyk", 1, 1, +pdf_gen1(DEFAULTCMYK, "defaultcmyk", 1, 1, 0, pdf_state_content | pdf_state_path) -pdf_gen1(PRESERVEOLDPANTONENAMES, "preserveoldpantonenames", 1, 1, +pdf_gen1(PRESERVEOLDPANTONENAMES, "preserveoldpantonenames", 1, 1, 0, pdf_state_all) -pdf_gen1(SPOTCOLORLOOKUP, "spotcolorlookup", 1, 1, +pdf_gen1(SPOTCOLORLOOKUP, "spotcolorlookup", 1, 1, 0, pdf_state_all) /* @@ -265,19 +267,19 @@ pdf_gen1(SPOTCOLORLOOKUP, "spotcolorlookup", 1, 1, * ---------------------------------------------------------------------- */ -pdf_gen1(IMAGEWARNING, "imagewarning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(IMAGEWIDTH, "imagewidth", 0, 1, +pdf_gen1(IMAGEWARNING, "imagewarning", 1, 1, 7, pdf_state_all) +pdf_gen1(IMAGEWIDTH, "imagewidth", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(IMAGEHEIGHT, "imageheight", 0, 1, +pdf_gen1(IMAGEHEIGHT, "imageheight", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(RESX, "resx", 0, 1, +pdf_gen1(RESX, "resx", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(RESY, "resy", 0, 1, +pdf_gen1(RESY, "resy", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(ORIENTATION, "orientation", 0, 1, +pdf_gen1(ORIENTATION, "orientation", 0, 1, 0, pdf_state_path | pdf_state_content | pdf_state_document) -pdf_gen1(INHERITGSTATE, "inheritgstate",1, 1, pdf_state_all) /* dep6 */ +pdf_gen1(INHERITGSTATE, "inheritgstate",1, 1, 6, pdf_state_all) /* @@ -286,10 +288,10 @@ pdf_gen1(INHERITGSTATE, "inheritgstate",1, 1, pdf_state_all) /* dep6 */ * ---------------------------------------------------------------------- */ -pdf_gen1(PDI, "pdi", 1, 1, pdf_state_all) -pdf_gen1(PDIWARNING, "pdiwarning", 1, 1, pdf_state_all) /* dep7 */ -pdf_gen1(PDIUSEBOX, "pdiusebox", 1, 1, pdf_state_all) /* dep6 */ -pdf_gen1(PDISTRICT, "pdistrict", 1, 1, pdf_state_all) /* unsupp */ +pdf_gen1(PDI, "pdi", 1, 1, 0, pdf_state_all) +pdf_gen1(PDIWARNING, "pdiwarning", 1, 1, 7, pdf_state_all) +pdf_gen1(PDIUSEBOX, "pdiusebox", 1, 1, 6, pdf_state_all) +pdf_gen1(PDISTRICT, "pdistrict", 1, 1,-1, pdf_state_all) /* @@ -298,55 +300,55 @@ pdf_gen1(PDISTRICT, "pdistrict", 1, 1, pdf_state_all) /* unsupp */ * ---------------------------------------------------------------------- */ -pdf_gen1(HYPERTEXTFORMAT, "hypertextformat", 1, 1, pdf_state_all) -pdf_gen1(HYPERTEXTENCODING, "hypertextencoding", 1, 1, pdf_state_all) -pdf_gen1(USERCOORDINATES, "usercoordinates", 1, 1, pdf_state_all) -pdf_gen1(USEHYPERTEXTENCODING, "usehypertextencoding", 1, 1, pdf_state_all) - /* unsupp */ - -pdf_gen1(HIDETOOLBAR, "hidetoolbar", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(HIDEMENUBAR, "hidemenubar", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(HIDEWINDOWUI, "hidewindowui", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(FITWINDOW, "fitwindow", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(CENTERWINDOW, "centerwindow", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(DISPLAYDOCTITLE, "displaydoctitle", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(NONFULLSCREENPAGEMODE, "nonfullscreenpagemode", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(DIRECTION, "direction", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ - -pdf_gen1(VIEWAREA, "viewarea", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(VIEWCLIP, "viewclip", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(PRINTAREA, "printarea", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(PRINTCLIP, "printclip", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ - -pdf_gen1(OPENACTION, "openaction", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(OPENMODE, "openmode", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(BOOKMARKDEST, "bookmarkdest", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ -pdf_gen1(TRANSITION, "transition", 1, 1, pdf_state_all) /* dep6 */ -pdf_gen1(DURATION, "duration", 1, 1, pdf_state_all) /* dep6 */ -pdf_gen1(BASE, "base", 1, 1, - pdf_state_content | pdf_state_document) /* dep6 */ - -pdf_gen1(LAUNCHLINK_PARAMETERS, "launchlink:parameters", 1, 1, - pdf_state_all) /* dep6 */ -pdf_gen1(LAUNCHLINK_OPERATION, "launchlink:operation", 1, 1, - pdf_state_all) /* dep6 */ -pdf_gen1(LAUNCHLINK_DEFAULTDIR, "launchlink:defaultdir", 1, 1, - pdf_state_all) /* dep6 */ +pdf_gen1(HYPERTEXTFORMAT, "hypertextformat", 1, 1, 0, pdf_state_all) +pdf_gen1(HYPERTEXTENCODING, "hypertextencoding", 1, 1, 0, pdf_state_all) +pdf_gen1(USERCOORDINATES, "usercoordinates", 1, 1, 0, pdf_state_all) +pdf_gen1(USEHYPERTEXTENCODING, "usehypertextencoding", 1, 1, 0, + pdf_state_all) + +pdf_gen1(HIDETOOLBAR, "hidetoolbar", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(HIDEMENUBAR, "hidemenubar", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(HIDEWINDOWUI, "hidewindowui", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(FITWINDOW, "fitwindow", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(CENTERWINDOW, "centerwindow", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(DISPLAYDOCTITLE, "displaydoctitle", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(NONFULLSCREENPAGEMODE, "nonfullscreenpagemode", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(DIRECTION, "direction", 1, 1, 6, + pdf_state_content | pdf_state_document) + +pdf_gen1(VIEWAREA, "viewarea", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(VIEWCLIP, "viewclip", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(PRINTAREA, "printarea", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(PRINTCLIP, "printclip", 1, 1, 6, + pdf_state_content | pdf_state_document) + +pdf_gen1(OPENACTION, "openaction", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(OPENMODE, "openmode", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(BOOKMARKDEST, "bookmarkdest", 1, 1, 6, + pdf_state_content | pdf_state_document) +pdf_gen1(TRANSITION, "transition", 1, 1, 6, pdf_state_all) +pdf_gen1(DURATION, "duration", 1, 1, 6, pdf_state_all) +pdf_gen1(BASE, "base", 1, 1, 6, + pdf_state_content | pdf_state_document) + +pdf_gen1(LAUNCHLINK_PARAMETERS, "launchlink:parameters", 1, 1, 6, + pdf_state_all) +pdf_gen1(LAUNCHLINK_OPERATION, "launchlink:operation", 1, 1, 6, + pdf_state_all) +pdf_gen1(LAUNCHLINK_DEFAULTDIR, "launchlink:defaultdir", 1, 1, 6, + pdf_state_all) /* @@ -355,9 +357,9 @@ pdf_gen1(LAUNCHLINK_DEFAULTDIR, "launchlink:defaultdir", 1, 1, * ---------------------------------------------------------------------- */ -pdf_gen1(USERPASSWORD, "userpassword", 1, 1, pdf_state_object) /* dep6 */ -pdf_gen1(MASTERPASSWORD,"masterpassword",1,1, pdf_state_object) /* dep6 */ -pdf_gen1(PERMISSIONS, "permissions", 1, 1, pdf_state_object) /* dep6 */ +pdf_gen1(USERPASSWORD, "userpassword", 1, 1, 6, pdf_state_object) +pdf_gen1(MASTERPASSWORD,"masterpassword",1,1, 6, pdf_state_object) +pdf_gen1(PERMISSIONS, "permissions", 1, 1, 6, pdf_state_object) /* @@ -366,7 +368,7 @@ pdf_gen1(PERMISSIONS, "permissions", 1, 1, pdf_state_object) /* dep6 */ * ---------------------------------------------------------------------- */ -pdf_gen1(AUTOSPACE, "autospace", 1, 1, pdf_state_all) +pdf_gen1(AUTOSPACE, "autospace", 1, 1, 0, pdf_state_all) #undef pdf_gen1 diff --git a/src/pdflib/pdflib/p_pattern.c b/src/pdflib/pdflib/p_pattern.c index 73306f7..dd458b6 100644 --- a/src/pdflib/pdflib/p_pattern.c +++ b/src/pdflib/pdflib/p_pattern.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_pattern.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_pattern.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib pattern routines * @@ -59,13 +59,12 @@ void pdf_write_page_pattern(PDF *p) { int i, total = 0; - int bias = p->curr_ppt->pt_bias; for (i = 0; i < p->pattern_number; i++) if (p->pattern[i].used_on_current_page) total++; - if (total > 0 || bias) + if (total > 0) { pdc_puts(p->out, "/Pattern"); pdc_begin_dict(p->out); @@ -78,12 +77,11 @@ pdf_write_page_pattern(PDF *p) if (p->pattern[i].used_on_current_page) { p->pattern[i].used_on_current_page = pdc_false; /* reset */ - pdc_printf(p->out, "/P%d", bias + i); + pdc_printf(p->out, "/P%d", i); pdc_objref(p->out, "", p->pattern[i].obj_id); } } - if (!bias) pdc_end_dict(p->out); } } diff --git a/src/pdflib/pdflib/p_pdi.c b/src/pdflib/pdflib/p_pdi.c index a138987..79ece1b 100644 --- a/src/pdflib/pdflib/p_pdi.c +++ b/src/pdflib/pdflib/p_pdi.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_pdi.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_pdi.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDF import routines (require the PDI library) * @@ -26,3 +26,4 @@ + diff --git a/src/pdflib/pdflib/p_pfm.c b/src/pdflib/pdflib/p_pfm.c index cab291b..b1989a4 100644 --- a/src/pdflib/pdflib/p_pfm.c +++ b/src/pdflib/pdflib/p_pfm.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_pfm.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_pfm.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib routines for fast reading of PFM font metrics files * @@ -115,32 +115,32 @@ pdf_check_pfm_encoding(PDF *p, pdf_font *font, pdc_encoding enc) const char *encname = pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, pdf_get_encoding_name(p, enc, font)); - const char *newencname = NULL; - pdc_encoding newenc = pdc_invalidenc; + const char *intencname = NULL; + pdc_encoding intenc = pdc_invalidenc; pdc_bool issymbfont = pdc_undef; pdc_logg_cond(p->pdc, 2, trc_font, "\tFont internal charset (dfCharSet): %d\n", font->ft.enc); /* Font encoding */ - newencname = pdc_get_keyword(font->ft.enc, pdf_charset_keylist); - if (newencname == NULL) + intencname = pdc_get_keyword(font->ft.enc, pdf_charset_keylist); + if (intencname == NULL) { pdc_set_errmsg(p->pdc, PDF_E_T1_BADCHARSET, pdc_errprintf(p->pdc, "%d", font->ft.enc), 0, 0, 0); return pdc_false; } - if (strlen(newencname)) + if (strlen(intencname)) { int codepage = 0; pdc_logg_cond(p->pdc, 2, trc_font, - "\tFont internal encoding \"%s\" found\n", newencname); + "\tFont internal encoding \"%s\" found\n", intencname); - newenc = pdc_find_encoding(p->pdc, newencname); - if (newenc == pdc_invalidenc) - newenc = pdc_insert_encoding(p->pdc, newencname, &codepage, + intenc = pdc_find_encoding(p->pdc, intencname); + if (intenc == pdc_invalidenc) + intenc = pdc_insert_encoding(p->pdc, intencname, &codepage, pdc_true); font->ft.issymbfont = pdc_false; @@ -150,7 +150,7 @@ pdf_check_pfm_encoding(PDF *p, pdf_font *font, pdc_encoding enc) pdc_logg_cond(p->pdc, 2, trc_font, "\tSymbol font\n"); font->ft.issymbfont = pdc_true; - newenc = pdc_builtin; + intenc = pdc_builtin; /* auto */ if (!strcmp(font->encapiname, "auto")) @@ -169,21 +169,25 @@ pdf_check_pfm_encoding(PDF *p, pdf_font *font, pdc_encoding enc) { font->unibyte = pdc_true; issymbfont = pdc_false; - enc = newenc; + enc = intenc; } /* encoding is subset of 8-bit encoding */ - if (enc >= pdc_winansi && newenc >= pdc_winansi) + if (enc >= pdc_winansi && intenc >= pdc_winansi) { if (pdc_is_encoding_subset(p->pdc, pdc_get_encoding_vector(p->pdc, enc), - pdc_get_encoding_vector(p->pdc, newenc))) + pdc_get_encoding_vector(p->pdc, intenc))) { - if (enc != pdc_winansi && newenc == pdc_winansi && + if (enc != pdc_winansi && intenc == pdc_winansi && strcmp(encname, "iso8859-1")) - font->towinansi = pdc_invalidenc; - + { + font->towinansi = intenc; + } + else + { + enc = intenc; + } issymbfont = pdc_false; - enc = newenc; } } @@ -198,9 +202,9 @@ pdf_check_pfm_encoding(PDF *p, pdf_font *font, pdc_encoding enc) if (issymbfont && !font->ft.issymbfont) { pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, - pdf_get_encoding_name(p, newenc, NULL), + pdf_get_encoding_name(p, intenc, NULL), 0, 0, 0); - font->ft.enc = newenc; + font->ft.enc = intenc; } if (!issymbfont && font->ft.issymbfont) { diff --git a/src/pdflib/pdflib/p_photoshp.c b/src/pdflib/pdflib/p_photoshp.c index 354f547..825929b 100644 --- a/src/pdflib/pdflib/p_photoshp.c +++ b/src/pdflib/pdflib/p_photoshp.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_photoshp.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_photoshp.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib Photoshop image resource data routines * diff --git a/src/pdflib/pdflib/p_png.c b/src/pdflib/pdflib/p_png.c index 42359a3..5882f2a 100644 --- a/src/pdflib/pdflib/p_png.c +++ b/src/pdflib/pdflib/p_png.c @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* | PDFlib - A library for generating PDF on the fly | +---------------------------------------------------------------------------+ - | Copyright (c) 1997-2006 Thomas Merz and PDFlib GmbH. All rights reserved. | + | Copyright (c) 1997-2009 Thomas Merz and PDFlib GmbH. All rights reserved. | +---------------------------------------------------------------------------+ | | | This software is subject to the PDFlib license. It is NOT in the | @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_png.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_png.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PNG processing for PDFlib * @@ -24,173 +24,22 @@ #define PDF_ALIGN16 #endif -/* SPNG - Simple PNG -** -** The items below, prefixed with spng_, or SPNG_, establish a replacement -** for LIBPNG that works very fast, but processes simple PNG images only: -** - bit_depth <= 8 (no 16-bit) -** - interlace_type 0 (no interlacing) -** - color_type 0, 2, or 3 (no alpha-channel); color type 3 requires -** libpng for palette processing -*/ -#define SPNG_SIGNATURE "\211\120\116\107\015\012\032\012" - -#define SPNG_CHUNK_IHDR 0x49484452 -#define SPNG_CHUNK_PLTE 0x504C5445 -#define SPNG_CHUNK_tRNS 0x74524E53 -#define SPNG_CHUNK_IDAT 0x49444154 -#define SPNG_CHUNK_IEND 0x49454E44 - -/* spng_init() return codes -*/ -#define SPNG_ERR_OK 0 /* no error */ -#define SPNG_ERR_NOPNG 1 /* bad PNG signature */ -#define SPNG_ERR_FMT 2 /* bad PNG file format */ - -typedef struct -{ - /* from IHDR: - */ - int width; - int height; - pdc_byte bit_depth; - pdc_byte color_type; - pdc_byte compr_type; - pdc_byte filter_type; - pdc_byte interlace_type; -} spng_info; - -static int -spng_getint(pdc_file *fp) -{ - unsigned char buf[4]; - - if (!PDC_OK_FREAD(fp, buf, 4)) - return -1; - - return (int) pdc_get_be_long(buf); -} /* spng_getint */ - -static int -spng_init(PDF *p, pdf_image *image, spng_info *spi) -{ - pdc_file *fp = image->fp; - char buf[8]; - - (void) p; - - /* check signature - */ - if (!PDC_OK_FREAD(fp, buf, 8) || - strncmp(buf, SPNG_SIGNATURE, 8) != 0) - return SPNG_ERR_NOPNG; - - /* read IHDR - */ - if (spng_getint(fp) != 13 || - spng_getint(fp) != SPNG_CHUNK_IHDR) - return SPNG_ERR_FMT; - - spi->width = spng_getint(fp); - spi->height = spng_getint(fp); - - if (!PDC_OK_FREAD(fp, buf, 5)) - return SPNG_ERR_FMT; - - spi->bit_depth = (pdc_byte) buf[0]; - spi->color_type = (pdc_byte) buf[1]; - spi->compr_type = (pdc_byte) buf[2]; - spi->filter_type = (pdc_byte) buf[3]; - spi->interlace_type = (pdc_byte) buf[4]; - - (void) spng_getint(fp); /* CRC */ - - /* decide whether this image is "simple". - */ #ifdef HAVE_LIBPNG - if (spi->bit_depth > 8 || spi->color_type > 3 || spi->interlace_type != 0) -#else - if (spi->bit_depth > 8 || spi->color_type > 2 || spi->interlace_type != 0) -#endif /* !HAVE_LIBPNG */ - { - image->use_raw = pdc_false; - return SPNG_ERR_OK; - } - else - image->use_raw = pdc_true; - - /* read (or skip) all chunks up to the first IDAT. - */ - for (/* */ ; /* */ ; /* */) - { - int len = spng_getint(fp); - int type = spng_getint(fp); - - switch (type) - { - case SPNG_CHUNK_IDAT: /* prepare data xfer */ - image->info.png.nbytes = (size_t) len; - return SPNG_ERR_OK; - - case -1: - return SPNG_ERR_FMT; - - /* if we decide to live without LIBPNG, - ** we should handle these cases, too. - */ - case SPNG_CHUNK_tRNS: /* transparency chunk */ - case SPNG_CHUNK_PLTE: /* read in palette */ - - default: - pdc_fseek(fp, len + 4, SEEK_CUR); - /* skip data & CRC */ - break; - } /* switch */ - } - - return SPNG_ERR_OK; -} /* spng_init */ - -#define PDF_PNG_BUFFERSIZE 8192 static void pdf_data_source_PNG_init(PDF *p, PDF_data_source *src) { - static const char fn[] = "pdf_data_source_PNG_init"; - pdf_image *image = (pdf_image *) src->private_data; + pdf_image *image = (pdf_image *) src->private_data; -#ifdef HAVE_LIBPNG - if (image->use_raw) - { -#endif - src->buffer_length = PDF_PNG_BUFFERSIZE; - src->buffer_start = (pdc_byte *) - pdc_malloc(p->pdc, src->buffer_length, fn); - src->bytes_available = 0; - src->next_byte = src->buffer_start; + (void) p; -#ifdef HAVE_LIBPNG - } - else - { - image->info.png.cur_line = 0; - src->buffer_length = image->info.png.rowbytes; - } -#endif + image->info.png.cur_line = 0; + src->buffer_length = image->info.png.rowbytes; } #undef min #define min(a, b) (((a) < (b)) ? (a) : (b)) -static void -spng_error(PDF *p, PDF_data_source *src) -{ - pdf_image *image = (pdf_image *) src->private_data; - - pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "PNG", - pdf_get_image_filename(p, image), 0, 0); -} /* spng_error */ - static pdc_bool pdf_data_source_PNG_fill(PDF *p, PDF_data_source *src) { @@ -198,69 +47,18 @@ pdf_data_source_PNG_fill(PDF *p, PDF_data_source *src) PDC_TRY(p->pdc) { -#ifdef HAVE_LIBPNG - if (image->use_raw) - { -#endif - pdc_file * fp = image->fp; - size_t buf_avail = src->buffer_length; - pdc_byte *scan = src->buffer_start; - - src->bytes_available = 0; - - if (image->info.png.nbytes == 0) - { - PDC_EXIT_TRY(p->pdc); - return pdc_false; - } - - do - { - size_t nbytes = min(image->info.png.nbytes, buf_avail); - - if (!PDC_OK_FREAD(fp, scan, nbytes)) - spng_error(p, src); - - src->bytes_available += nbytes; - scan += nbytes; - buf_avail -= nbytes; - - if ((image->info.png.nbytes -= nbytes) == 0) - { - /* proceed to next IDAT chunk - */ - (void) spng_getint(fp); /* CRC */ - image->info.png.nbytes = - (size_t) spng_getint(fp); /* length */ - - if (spng_getint(fp) != SPNG_CHUNK_IDAT) - { - image->info.png.nbytes = 0; - PDC_EXIT_TRY(p->pdc); - return pdc_true; - } - } - } - while (buf_avail); - -#ifdef HAVE_LIBPNG - } - else - { - if (image->info.png.cur_line == image->height) - { - PDC_EXIT_TRY(p->pdc); - return pdc_false; - } + if (image->info.png.cur_line == image->height) + { + PDC_EXIT_TRY(p->pdc); + return pdc_false; + } - src->next_byte = image->info.png.raster + - image->info.png.cur_line * image->info.png.rowbytes; + src->next_byte = image->info.png.raster + + image->info.png.cur_line * image->info.png.rowbytes; - src->bytes_available = src->buffer_length; + src->bytes_available = src->buffer_length; - image->info.png.cur_line++; - } -#endif /* HAVE_LIBPNG */ + image->info.png.cur_line++; } PDC_CATCH(p->pdc) { @@ -273,20 +71,24 @@ pdf_data_source_PNG_fill(PDF *p, PDF_data_source *src) static void pdf_data_source_PNG_terminate(PDF *p, PDF_data_source *src) { - pdf_image *image = (pdf_image *) src->private_data; + (void) p; + (void) src; +} -#ifdef HAVE_LIBPNG - if (image->use_raw) +static void +pdf_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + pdc_file *fp = (pdc_file *) png_ptr->io_ptr; + char *filename = (char *) pdc_file_name(fp); + + if (!PDC_OK_FREAD(fp, data, length)) { -#endif - pdc_free(p->pdc, (void *) src->buffer_start); + pdc_core *pdc = pdc_file_getpdc(fp); -#ifdef HAVE_LIBPNG + pdc_error(pdc, PDF_E_IMAGE_CORRUPT, "PNG", filename, 0, 0); } -#endif } -#ifdef HAVE_LIBPNG /* * We suppress libpng's warning message by supplying * our own error and warning handlers @@ -294,11 +96,8 @@ pdf_data_source_PNG_terminate(PDF *p, PDF_data_source *src) static void pdf_libpng_warning_handler(png_structp png_ptr, png_const_charp message) { - (void) png_ptr; /* avoid compiler warning "unreferenced parameter" */ - (void) message; /* avoid compiler warning "unreferenced parameter" */ - - /* do nothing */ - return; + PDF *p = (PDF *)png_ptr->mem_ptr; + pdc_logg_cond(p->pdc, 5, trc_image, "\tlibpng warning: %s\n", message); } /* @@ -311,11 +110,13 @@ pdf_libpng_warning_handler(png_structp png_ptr, png_const_charp message) static void pdf_libpng_error_handler(png_structp png_ptr, png_const_charp message) { + PDF *p = (PDF *)png_ptr->mem_ptr; + #ifdef PDF_ALIGN16 jmp_buf jbuf; #endif - (void) message; /* avoid compiler warning "unreferenced parameter" */ + pdc_logg_cond(p->pdc, 5, trc_image, "\tlibpng error: %s\n", message); #ifdef PDF_ALIGN16 memcpy(jbuf, png_jmpbuf(png_ptr), sizeof (jmp_buf)); @@ -355,20 +156,6 @@ pdf_is_PNG_file(PDF *p, pdc_file *fp) return pdc_true; } -static void /* CDPDF - moved to inside the HAVE_LIBPNG definition */ -pdf_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - pdc_file *fp = (pdc_file *) png_ptr->io_ptr; - char *filename = (char *) pdc_file_name(fp); - - if (!PDC_OK_FREAD(fp, data, length)) - { - pdc_core *pdc = pdc_file_getpdc(fp); - - pdc_error(pdc, PDF_E_IMAGE_CORRUPT, "PNG", filename, 0, 0); - } -} - int pdf_process_PNG_data( PDF *p, @@ -376,7 +163,7 @@ pdf_process_PNG_data( { static const char *fn = "pdf_process_PNG_data"; pdc_file *save_fp; - spng_info s_info; + size_t bytecount; #ifdef PDF_ALIGN16 jmp_buf jbuf; #endif @@ -404,8 +191,10 @@ pdf_process_PNG_data( image->info.png.png_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp) NULL, - (png_error_ptr)pdf_libpng_error_handler, (png_error_ptr)pdf_libpng_warning_handler, /* CDPDF - added type cast */ - p, (png_malloc_ptr) pdf_libpng_malloc, + (png_error_ptr) pdf_libpng_error_handler, + (png_error_ptr) pdf_libpng_warning_handler, + p, + (png_malloc_ptr) pdf_libpng_malloc, (png_free_ptr) pdf_libpng_free); if (!image->info.png.png_ptr) @@ -446,7 +235,8 @@ pdf_process_PNG_data( } /* from file or from memory */ - png_set_read_fn(image->info.png.png_ptr, image->fp, (png_rw_ptr)pdf_png_read_data); /* CDPDF - added type cast */ + png_set_read_fn(image->info.png.png_ptr, image->fp, + (png_rw_ptr) pdf_png_read_data); png_set_sig_bytes(image->info.png.png_ptr, 8); png_read_info(image->info.png.png_ptr, image->info.png.info_ptr); @@ -667,6 +457,14 @@ pdf_process_PNG_data( image->info.png.rowbytes = png_get_rowbytes(image->info.png.png_ptr, image->info.png.info_ptr); + /* Check for overflow */ + bytecount = image->info.png.rowbytes * height; + if (bytecount / height != image->info.png.rowbytes) + { + errcode = PDF_E_IMAGE_TOO_LARGE; + goto PDF_PNG_ERROR; + } + image->info.png.raster = (pdc_byte *) pdc_calloc(p->pdc,image->info.png.rowbytes * height, fn); @@ -691,60 +489,50 @@ pdf_process_PNG_data( image->fp = pdc_fsearch_fopen(p->pdc, image->filename, NULL, NULL, PDC_FILE_BINARY); - if (image->fp != NULL && - spng_init(p, image, &s_info) == SPNG_ERR_OK && image->use_raw) - { - pdc_fclose(save_fp); - image->predictor = pred_png; - image->compression = pdf_comp_flate; - } - else - { - if (image->fp != (pdc_file *) 0) - pdc_fclose(image->fp); + if (image->fp != (pdc_file *) 0) + pdc_fclose(image->fp); - image->fp = save_fp; + image->fp = save_fp; + + /* Provide a suitable background for images with alpha channel */ + if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_color_16p image_background; - /* Provide a suitable background for images with alpha channel */ - if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) + if (png_get_bKGD(image->info.png.png_ptr, image->info.png.info_ptr, + &image_background)) { - png_color_16p image_background; + png_set_background(image->info.png.png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + } + else + { + png_color_16 my_white; - if (png_get_bKGD(image->info.png.png_ptr, image->info.png.info_ptr, - &image_background)) + if (bit_depth == 8) { - png_set_background(image->info.png.png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + my_white.red = 0xFF; + my_white.green = 0xFF; + my_white.blue = 0xFF; + my_white.gray = 0xFF; } else { - png_color_16 my_white; - - if (bit_depth == 8) - { - my_white.red = 0xFF; - my_white.green = 0xFF; - my_white.blue = 0xFF; - my_white.gray = 0xFF; - } - else - { - my_white.red = 0xFFFF; - my_white.green = 0xFFFF; - my_white.blue = 0xFFFF; - my_white.gray = 0xFFFF; - } - - png_set_background(image->info.png.png_ptr, &my_white, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + my_white.red = 0xFFFF; + my_white.green = 0xFFFF; + my_white.blue = 0xFFFF; + my_white.gray = 0xFFFF; } - } - /* fetch the actual image data */ - png_read_image(image->info.png.png_ptr, row_pointers); + png_set_background(image->info.png.png_ptr, &my_white, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + } } + /* fetch the actual image data */ + png_read_image(image->info.png.png_ptr, row_pointers); + image->in_use = pdc_true; /* mark slot as used */ pdf_put_image(p, imageslot, pdc_true, pdc_true); @@ -787,6 +575,12 @@ pdf_process_PNG_data( pdc_set_errmsg(p->pdc, errcode, "PNG", stemp, 0, 0); break; + case PDF_E_IMAGE_TOO_LARGE: + pdc_set_errmsg(p->pdc, errcode, "PNG", stemp, + pdc_errprintf(p->pdc, "%ld", (long) image->width), + pdc_errprintf(p->pdc, "%ld", (long) image->height)); + break; + case 0: /* error code and message already set */ break; } @@ -800,56 +594,20 @@ pdf_process_PNG_data( pdc_bool pdf_is_PNG_file(PDF *p, pdc_file *fp) { + (void) p; + (void) fp; + return pdc_false; } -/* simple built-in PNG reader without libpng */ - int -pdf_process_PNG_data( - PDF *p, - int imageslot) +pdf_process_PNG_data(PDF *p, int imageslot) { - static const char fn[] = "pdf_process_PNG_data"; - spng_info s_info; - pdf_image *image; - - image = &p->images[imageslot]; - - image->src.init = pdf_data_source_PNG_init; - image->src.fill = pdf_data_source_PNG_fill; - image->src.terminate = pdf_data_source_PNG_terminate; - image->src.private_data = (void *) image; - - if (spng_init(p, image, &s_info) == SPNG_ERR_OK && image->use_raw) - { - image->predictor = pred_png; - image->compression = pdf_comp_flate; /* CDPDF - fixed function name */ - - image->width = (pdc_scalar) s_info.width; - image->height = (pdc_scalar) s_info.height; - image->bpc = s_info.bit_depth; - - image->components = 3; - - /* other types are rejected in spng_init() */ - image->colorspace = - (s_info.color_type == 0 ? DeviceGray : DeviceRGB); + (void) imageslot; + pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "PNG", 0, 0, 0); - - } - else - { - pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "PNG", 0, 0, 0); - return -1; - } - - image->in_use = pdc_true; /* mark slot as used */ - - pdf_put_image(p, imageslot, pdc_true, pdc_true); - - return image->corrupt ? -1 : imageslot; + return -1; } #endif /* !HAVE_LIBPNG */ diff --git a/src/pdflib/pdflib/p_shading.c b/src/pdflib/pdflib/p_shading.c index e027ce6..de0f762 100644 --- a/src/pdflib/pdflib/p_shading.c +++ b/src/pdflib/pdflib/p_shading.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_shading.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_shading.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib routines for smooth shading * @@ -68,13 +68,12 @@ void pdf_write_page_shadings(PDF *p) { int i, total = 0; - int bias = p->curr_ppt->sh_bias; for (i = 0; i < p->shadings_number; i++) if (p->shadings[i].used_on_current_page) total++; - if (total > 0 || bias) + if (total > 0) { pdc_puts(p->out, "/Shading"); pdc_begin_dict(p->out); @@ -87,12 +86,11 @@ pdf_write_page_shadings(PDF *p) if (p->shadings[i].used_on_current_page) { p->shadings[i].used_on_current_page = pdc_false; /* reset */ - pdc_printf(p->out, "/Sh%d", bias + i); + pdc_printf(p->out, "/Sh%d", i); pdc_objref(p->out, "", p->shadings[i].obj_id); } } - if (!bias) pdc_end_dict(p->out); } } @@ -201,15 +199,13 @@ pdf__shading_pattern(PDF *p, int shading, const char *optlist) void pdf__shfill(PDF *p, int shading) { - int bias = p->curr_ppt->sh_bias; - if (p->compatibility == PDC_1_3) pdc_error(p->pdc, PDF_E_SHADING13, 0, 0, 0, 0); pdf_check_handle(p, shading, pdc_shadinghandle); pdf_end_text(p); - pdc_printf(p->out, "/Sh%d sh\n", bias + shading); + pdc_printf(p->out, "/Sh%d sh\n", shading); p->shadings[shading].used_on_current_page = pdc_true; } diff --git a/src/pdflib/pdflib/p_subsett.c b/src/pdflib/pdflib/p_subsett.c index 47eece6..de2a821 100644 --- a/src/pdflib/pdflib/p_subsett.c +++ b/src/pdflib/pdflib/p_subsett.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_subsett.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_subsett.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib subsetting routines * diff --git a/src/pdflib/pdflib/p_table.c b/src/pdflib/pdflib/p_table.c index dc45525..c619666 100644 --- a/src/pdflib/pdflib/p_table.c +++ b/src/pdflib/pdflib/p_table.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_table.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_table.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib table function * diff --git a/src/pdflib/pdflib/p_tagged.c b/src/pdflib/pdflib/p_tagged.c index 339b848..92c3eb7 100644 --- a/src/pdflib/pdflib/p_tagged.c +++ b/src/pdflib/pdflib/p_tagged.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_tagged.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_tagged.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib marked content routines * @@ -21,6 +21,7 @@ #include "p_intern.h" #include "p_layer.h" #include "p_tagged.h" +#include "pc_strconst.h" @@ -49,5 +50,6 @@ + diff --git a/src/pdflib/pdflib/p_tagged.h b/src/pdflib/pdflib/p_tagged.h index 8dab696..2e6017d 100644 --- a/src/pdflib/pdflib/p_tagged.h +++ b/src/pdflib/pdflib/p_tagged.h @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_tagged.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_tagged.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib marked content header * diff --git a/src/pdflib/pdflib/p_template.c b/src/pdflib/pdflib/p_template.c index b6a4f6d..6237467 100644 --- a/src/pdflib/pdflib/p_template.c +++ b/src/pdflib/pdflib/p_template.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_template.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_template.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib template routines * @@ -26,7 +26,7 @@ int pdf_embed_image(PDF *p, int im) { pdf_image *image = &p->images[im]; - char optlist[2048], *ol; + char optlist[PDC_GEN_BUFSIZE], *ol; pdc_scalar width, height; int templ; @@ -39,13 +39,14 @@ pdf_embed_image(PDF *p, int im) if (image->iconname) - sprintf(ol, "iconname {%s}", image->iconname); + pdc_sprintf(p->pdc, pdc_false, ol, "iconname {%s}", image->iconname); /* create template */ templ = pdf__begin_template(p, width, height, optlist); /* fit image */ - sprintf(optlist, "boxsize {%g %g} fitmethod meet", width, height); + pdc_sprintf(p->pdc, pdc_false, optlist, "boxsize {%g %g} fitmethod meet", + width, height); pdf__fit_image(p, im, 0, 0, optlist); /* end template */ @@ -65,6 +66,9 @@ static const pdc_defopt pdf_begin_template_options[] = { {"topdown", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + {"transparencygroup", pdc_stringlist, PDC_OPT_PDC_1_4, 1, 1, + 1.0, PDF_MAX_NAMESTRING, NULL}, + {"OPI-1.3", pdc_stringlist, PDF_OPIOPT_FLAG, 1, 1, 0.0, 32000.0, NULL}, {"OPI-2.0", pdc_stringlist, PDF_OPIOPT_FLAG | PDC_OPT_IGNOREIF1, @@ -114,6 +118,9 @@ pdf__begin_template(PDF *p, pdc_scalar width, pdc_scalar height, image->topdown_save = (p->ydirection == -1) ? pdc_true : pdc_false; topdown = image->topdown_save; image->in_use = pdc_true; /* mark slot as used */ + image->tgroup.colorspace = color_none; + image->tgroup.isolated = pdc_false; + image->tgroup.knockout = pdc_false; /* parsing optlist */ pdf_set_clientdata(p, &cdata); @@ -123,11 +130,16 @@ pdf__begin_template(PDF *p, pdc_scalar width, pdc_scalar height, /* save and check options */ if (optlist && *optlist) { + char **slist; + image->verbose = pdf_get_errorpolicy(p, resopts, image->verbose); keyword = "topdown"; pdc_get_optvalues(keyword, resopts, &topdown, NULL); + if (pdc_get_optvalues("transparencygroup", resopts, NULL, &slist)) + pdf_set_transgroup(p, slist[0], &image->tgroup); + keyword = "iconname"; if (pdc_get_optvalues(keyword, resopts, NULL, NULL)) iconname = (char *) pdc_save_lastopt(resopts, PDC_OPT_SAVE1ELEM); @@ -168,6 +180,9 @@ pdf__begin_template(PDF *p, pdc_scalar width, pdc_scalar height, pdc_printf(p->out, "/BBox[0 0 %f %f]\n", width, height); + if (image->tgroup.colorspace != color_none) + pdf_write_transgroup(p, &image->tgroup); + diff --git a/src/pdflib/pdflib/p_text.c b/src/pdflib/pdflib/p_text.c index 105df11..b932bc0 100644 --- a/src/pdflib/pdflib/p_text.c +++ b/src/pdflib/pdflib/p_text.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_text.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_text.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib text routines * @@ -428,7 +428,8 @@ pdf_init_text_options(PDF *p, pdf_text_options *to) static pdf_text_optflags pdf_toptflags[] = { to_font, to_fontsize, to_textrendering, to_charspacing, - to_horizscaling, to_italicangle, to_wordspacing, to_textrise + to_horizscaling, to_italicangle, to_fakebold, to_wordspacing, + to_textrise, to_underlinewidth, to_underlineposition }; void @@ -454,6 +455,13 @@ pdf_set_text_options(PDF *p, pdf_text_options *to) if (!(currto->mask & (1 << tflag)) && to->font == currto->font) break; + if (currto->font != -1 && + (p->fonts[to->font].metricflags & font_italic) != + (p->fonts[currto->font].metricflags & font_italic)) + { + to->mask |= (1 << to_italicangle); + currto->mask = to->mask; /* otherwise order dependent */ + } ts->font = currto->font = to->font; continue; @@ -593,7 +601,8 @@ pdf_calculate_text_options(PDF *p, pdf_text_options *to, pdc_bool force, { pdc_bool kminfs = pdc_false; - if (to->mask & (1 << to_fontsize) || force) + if (to->mask & (1U << to_fontsize) || + (force && to->fontsize != PDC_FLOAT_MIN)) { pdc_scalar fontsize; @@ -632,12 +641,9 @@ pdf_calculate_text_options(PDF *p, pdf_text_options *to, pdc_bool force, fontsize *= 1000.0 / fm; } - if (fontscale < 1.0 && fabs(fontsize) < minfontsize) + if (fontscale < 1.0 && PDC_ABS(fontsize) < minfontsize) { - if (fontsize > 0) - fontsize = minfontsize; - else - fontsize = -minfontsize; + fontsize = PDC_SIGN(fontsize) * minfontsize; kminfs = pdc_true; } to->fontsize = fontsize; @@ -919,7 +925,7 @@ pdf_begin_text(PDF *p) (currto->mask & (1L << to_fontsize)) || !ts->glyphinit)) { pdc_printf(p->out, "/F%d %f Tf\n", - ppt->fn_bias + currto->font, p->ydirection * currto->fontsize); + currto->font, p->ydirection * currto->fontsize); currfont->used_in_current_doc = pdc_true; currfont->used_on_current_page = pdc_true; @@ -998,6 +1004,31 @@ pdf_reset_tstate(PDF *p) /* ------------------- Text string checking function ---------------------- */ +struct pdf_fitres_s +{ + pdc_bool verbose; + pdc_vector start; /* text start position */ + pdc_vector end; /* text end position */ + pdc_vector writingdir; /* unit vector of text writing direction */ + pdc_vector perpendiculardir;/* unit vector perpendicular to writing dir. */ + pdc_vector scale; /* x/y scaling */ + pdc_scalar angle; /* rotation angle of writingdir in degree */ + pdc_scalar width; /* textline width */ + pdc_scalar height; /* textline height */ + pdc_scalar mwidth; /* textline width with margins */ + pdc_scalar mheight; /* textline height with margins */ + pdc_scalar ascender; /* textline ascender */ + pdc_scalar capheight; /* textline capheight */ + pdc_scalar xheight; /* textline xheight */ + pdc_scalar descender; /* textline descender */ + int unmappedchars; /* number of characters not contained + * in the encoding and not in the font */ + int replacedchars; /* number of characters replaced by + * typografically similar characters */ + int unknownchars; /* number of characters replaced by + * given replcement character */ +}; + typedef struct pdf_ligat_s pdf_ligat; struct pdf_ligat_s @@ -1067,7 +1098,7 @@ pdf_cleanup_ligat(PDF *p, pdf_ligat *list) int pdf_get_approximate_uvlist(PDF *p, pdf_font *currfont, pdc_encodingvector *ev, - int usv, pdc_bool replace, + int usv, pdc_bool replace, pdf_fitres *fitres, pdc_ushort *uvlist, pdc_ushort *cglist) { int cg = 0, nv = 1; @@ -1090,6 +1121,13 @@ pdf_get_approximate_uvlist(PDF *p, pdf_font *currfont, pdc_encodingvector *ev, uvlist[0] = 0; } nv = 1; + + if (fitres != NULL) + fitres->unknownchars++; + } + else if (fitres != NULL) + { + fitres->replacedchars++; } return nv; @@ -1168,14 +1206,14 @@ pdf_get_input_textformat(pdf_font *currfont, * (pdc_malloc_tmp, pdc_free_tmp) containing the converted string * if flag PDF_USE_TMPALLOC is set. * - * If return value is -1 an error was occurred, otherwise >= 0. - * glyphcheck = none: the number of unmapped glyphs will be returned. + * If return value is pdc_false an error was occurred, otherwise pdc_true. * */ -int +pdc_bool pdf_check_textstring(PDF *p, const char *text, int len, int flags, - pdf_text_options *to, pdc_byte **outtext_p, int *outlen, + pdf_text_options *to, pdf_fitres *fitres, + pdc_byte **outtext_p, int *outlen, int *outcharlen, pdc_bool verbose) { static const char fn[] = "pdf_check_textstring"; @@ -1191,13 +1229,13 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, pdc_text_format intextformat = to->textformat; pdc_text_format outtextformat = pdc_utf16; + int maxlen = PDF_MAXDICTSIZE; int charlen = 1, newcharlen = 1; int convflags = PDC_CONV_NOBOM; - int unmapgids = 0; pdf_ligat *ligat, *ligatlist = NULL; pdc_byte *intext = (pdc_byte *) text, *outtext = NULL; - int newlen = -1, maxlen, replchar; + int newlen = -1, replchar; if (logg1) { @@ -1237,6 +1275,10 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, if (logg2) pdc_logg(p->pdc, "\t\ttext is passed through as is\n"); + if (intextformat > pdc_bytes2) + pdc_warning(p->pdc, PDF_E_TEXT_BADTEXTFORMAT, + pdc_get_textformat(intextformat), 0, 0, 0); + outtext = (pdc_byte *) ((flags & PDF_USE_TMPALLOC) ? pdc_malloc_tmp(p->pdc, (size_t) len + 2, fn, NULL, NULL) : pdc_malloc(p->pdc, (size_t) len + 2, fn)); @@ -1327,12 +1369,29 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, } /* maximal text string length - found out emprirically! */ - maxlen = (currfont->codesize == 1) ? PDF_MAXARRAYSIZE : PDF_MAXDICTSIZE; - if (!(flags & PDF_KEEP_TEXTLEN) && *outlen > maxlen) + if (*outlen > maxlen && !(flags & PDF_KEEP_TEXTLEN)) { - pdc_set_errmsg(p->pdc, PDF_E_TEXT_TOOLONG, - pdc_errprintf(p->pdc, "%d", maxlen), 0, 0, 0); - goto PDF_CHECK_TEXT_ERROR; + int textlen = *outlen; + + if (!to->kerning && to->wordspacing == 0.0) + { + if (currfont->codesize == 1) + textlen /= charlen; + maxlen = PDF_MAXTEXTSIZE; + } + else + { + if (currfont->codesize == 2) + maxlen *= charlen; + } + + if (textlen > maxlen) + { + pdc_set_errmsg(p->pdc, PDF_E_TEXT_TOOLONG, + pdc_errprintf(p->pdc, "%d", textlen), + pdc_errprintf(p->pdc, "%d", maxlen), 0, 0); + goto PDF_CHECK_TEXT_ERROR; + } } len = *outlen / charlen; @@ -1360,7 +1419,6 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, /* glyph id for code value not available */ if (gid <= 0) { - unmapgids++; if (to->glyphcheck == text_error) { pdc_set_errmsg(p->pdc, PDF_E_FONT_CODENOTFOUND1, @@ -1374,7 +1432,13 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, pdc_errprintf(p->pdc, "x%02X", code), currfont->ft.name, 0, 0); code = currfont->replacementcode; + + if (fitres != NULL) + fitres->unknownchars++; } + + if (fitres != NULL) + fitres->unmappedchars++; } } @@ -1435,7 +1499,6 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, /* encoding vector hasn't defined [Uni]code */ if (usv <= 0 || code <= 0) { - unmapgids++; if (to->glyphcheck == text_error) { if (usv <= 0) @@ -1458,6 +1521,7 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, usvp = (usv <= 0) ? code : usv; nv = pdf_get_approximate_uvlist(p, currfont, ev, usv, pdc_true, + fitres, uvlist, cglist); usv = (int) uvlist[0]; code = (int) cglist[0]; @@ -1468,6 +1532,9 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, enc, charlen, uvlist, cglist, nv); } } + + if (fitres != NULL) + fitres->unmappedchars++; } else { @@ -1476,7 +1543,6 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, /* glyph id for code not available */ if (gid <= 0 && currfont->gid0code != code) { - unmapgids++; if (to->glyphcheck == text_error) { pdc_set_errmsg(p->pdc, PDF_E_FONT_CODENOTFOUND2, @@ -1495,6 +1561,7 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, usvp = (usv <= 0) ? code : usv; nv = pdf_get_approximate_uvlist(p, currfont, ev, usv, pdc_true, + fitres, uvlist, cglist); usv = (int) uvlist[0]; code = (int) cglist[0]; @@ -1505,6 +1572,9 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, enc, charlen, uvlist, cglist, nv); } } + + if (fitres != NULL) + fitres->unmappedchars++; } } } @@ -1603,7 +1673,11 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, "\tChecked and converted text of length %d: \"%T\"\n", *outlen, outtext, *outlen); } - return unmapgids; + + if (*outlen) + return pdc_true; + + verbose = pdc_false; PDF_CHECK_TEXT_ERROR: @@ -1618,12 +1692,12 @@ pdf_check_textstring(PDF *p, const char *text, int len, int flags, pdf_cleanup_ligat(p, ligatlist); if (verbose) - pdc_error(p->pdc, -1, 0, 0, 0, 0); + PDC_RETHROW(p->pdc); *outtext_p = NULL; *outlen = 0; - return -1; + return pdc_false; } @@ -1790,10 +1864,9 @@ pdf__stringwidth(PDF *p, const char *text, int len, int font, pdc_scalar width = 0, height = 0; pdf_text_options to = *p->curr_ppt->currto; - if (text && len == 0) - len = (int) strlen(text); - if (text == NULL || len <= 0) - return width; + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXTEXTSIZE); + if (!len) + return 0.0; pdf_check_handle(p, font, pdc_fonthandle); @@ -1802,11 +1875,12 @@ pdf__stringwidth(PDF *p, const char *text, int len, int font, /* convert text string */ to.font = font; to.fontsize = fontsize; - pdf_check_textstring(p, text, len, PDF_KEEP_TEXTLEN | PDF_USE_TMPALLOC, - &to, &utext, &len, &charlen, pdc_true); - if (utext && len) + if (pdf_check_textstring(p, text, len, PDF_KEEP_TEXTLEN | PDF_USE_TMPALLOC, + &to, NULL, &utext, &len, &charlen, pdc_true)) + { width = pdf_calculate_textsize(p, utext, len, charlen, &to, -1, &height, pdc_true); + } return width; } @@ -1835,7 +1909,7 @@ pdf_put_fieldtext(PDF *p, const char *text, int font) { pdf_put_hypertext(p, text); } - else + else if (font > -1) { static const char fn[] = "pdf_put_fieldtext"; pdf_font *currfont = &p->fonts[font]; @@ -2301,15 +2375,9 @@ pdf__show_text( int charlen = 1; pdc_scalar width = 0, height = 0; - if (text && len == 0) - len = (int) strlen(text); - if (text == NULL || len <= 0) - { - if (cont) - len = 0; - else - return; - } + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXTEXTSIZE); + if (!len && !cont) + return; /* no font set */ if (currto->font == -1) @@ -2318,14 +2386,17 @@ pdf__show_text( if (len) { /* convert text string */ - pdf_check_textstring(p, text, len, PDF_USE_TMPALLOC, - currto, &utext, &len, &charlen, pdc_true); - if (utext == NULL || (!cont && !len)) + if (pdf_check_textstring(p, text, len, PDF_USE_TMPALLOC, + currto, NULL, &utext, &len, &charlen, pdc_true)) + { + /* width and height of text string */ + width = pdf_calculate_textsize(p, utext, len, charlen, + currto, -1, &height, pdc_true); + } + else if (!cont) + { return; - - /* width and height of text string */ - width = pdf_calculate_textsize(p, utext, len, charlen, - currto, -1, &height, pdc_true); + } } else { @@ -2350,9 +2421,8 @@ pdf__xshow(PDF *p, const char *text, int len, const pdc_scalar *xadvancelist) size_t nbytes = 0; pdc_scalar width, height; - if (text && len == 0) - len = (int) strlen(text); - if (text == NULL || !len) + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXTEXTSIZE); + if (!len) return; /* no font set */ @@ -2360,28 +2430,28 @@ pdf__xshow(PDF *p, const char *text, int len, const pdc_scalar *xadvancelist) pdc_error(p->pdc, PDF_E_TEXT_NOFONT, 0, 0, 0, 0); /* convert text string */ - pdf_check_textstring(p, text, len, PDF_USE_TMPALLOC, - currto, &utext, &len, &charlen, pdc_true); - if (utext == NULL || !len) - return; - - /* allocating glyph widths arrays */ - nbytes = (size_t) (len / charlen) * sizeof(pdc_scalar); - currto->xadvancelist = (pdc_scalar *) pdc_malloc_tmp(p->pdc, - nbytes, fn, NULL, NULL); - memcpy(currto->xadvancelist, xadvancelist, nbytes); - currto->nglyphs = len / charlen; + if (pdf_check_textstring(p, text, len, PDF_USE_TMPALLOC, + currto, NULL, &utext, &len, &charlen, pdc_true)) + { + /* allocating glyph widths arrays */ + nbytes = (size_t) (len / charlen) * sizeof(pdc_scalar); + currto->xadvancelist = (pdc_scalar *) pdc_malloc_tmp(p->pdc, + nbytes, fn, NULL, NULL); + memcpy(currto->xadvancelist, xadvancelist, nbytes); + currto->nglyphs = len / charlen; - /* length of text */ - width = pdf_calculate_textsize(p, utext, len, charlen, - currto, -1, &height, pdc_true); + /* length of text */ + width = pdf_calculate_textsize(p, utext, len, charlen, + currto, -1, &height, pdc_true); - /* place text */ - pdf_place_text(p, utext, len, charlen, currto, width, height, pdc_false); + /* place text */ + pdf_place_text(p, utext, len, charlen, currto, width, height, + pdc_false); - currto->xadvancelist = NULL; - currto->nglyphs = 0; + currto->xadvancelist = NULL; + currto->nglyphs = 0; + } } @@ -2391,24 +2461,6 @@ pdf__xshow(PDF *p, const char *text, int len, const pdc_scalar *xadvancelist) /* ----------------------- Text fitting function ------------------------ */ -struct pdf_fittext_s -{ - pdc_vector start; /* text start position */ - pdc_vector end; /* text end position */ - pdc_vector writingdir; /* unit vector of text writing direction */ - pdc_vector perpendiculardir;/* unit vector perpendicular to writing dir. */ - pdc_vector scale; /* x/y scaling */ - pdc_scalar angle; /* rotation angle of writingdir in degree */ - pdc_scalar width; /* textline width */ - pdc_scalar height; /* textline height */ - pdc_scalar mwidth; /* textline width with margins */ - pdc_scalar mheight; /* textline height with margins */ - pdc_scalar ascender; /* textline ascender */ - pdc_scalar capheight; /* textline capheight */ - pdc_scalar xheight; /* textline xheight */ - pdc_scalar descender; /* textline descender */ -}; - /* definitions of fit text options */ static const pdc_defopt pdf_fit_textline_options[] = @@ -2482,9 +2534,8 @@ pdf_parse_textline_options(PDF *p, const char *text, int len, { pdf_ppt *ppt = p->curr_ppt; - if (text && len == 0) - len = (int) strlen(text); - if (text == NULL || len <= 0) + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXTEXTSIZE); + if (!len) return pdc_false; /* initialize text options */ @@ -2508,8 +2559,8 @@ pdf_parse_textline_options(PDF *p, const char *text, int len, return pdc_true; } -int -pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, +pdc_bool +pdf_fit_textline_internal(PDF *p, pdf_fitres *fitres, pdf_text_options *to, pdf_fit_options *fit, pdc_matrix *matrix) { @@ -2531,9 +2582,11 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, pdc_scalar ascender, capheight, xheight, descender; pdc_scalar x, y, tx = 0, ty = 0, basey = 0; pdc_bool hasfitbox = pdc_false; + pdc_bool hasboxwidth = pdc_false; + pdc_bool verbose = pdc_true; pdc_scalar font2user; int indangle = fit->orientate / 90; - int unmapgids = 0, i; + int i; (void) ppt; @@ -2552,12 +2605,13 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, fontsizeref); if (!blind) pdf_set_text_options(p, to); + else + verbose = fitres->verbose; /* convert text string */ - unmapgids = pdf_check_textstring(p, to->text, to->textlen, PDF_USE_TMPALLOC, - to, &utext, &len, &charlen, pdc_true); - if (utext == NULL || !len) - return -1; + if (!pdf_check_textstring(p, to->text, to->textlen, PDF_USE_TMPALLOC, + to, fitres, &utext, &len, &charlen, verbose)) + return pdc_false; if (to->nglyphs && len/charlen != to->nglyphs) pdc_warning(p->pdc, PDF_E_TEXT_SIZENOMATCH, @@ -2568,8 +2622,11 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, width = pdf_calculate_textsize(p, utext, len, charlen, to, -1, &height, pdc_true); width = pdf_trim_textwidth(width, to); + + /* incredible bug #1451 if (PDC_FLOAT_ISNULL(width)) return -1; + */ /* font specifics */ font2user = to->fontsize / 1000.0; @@ -2589,7 +2646,8 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, boxheight -= 2 * elemmargin.y; if (boxheight < 0) boxheight = 0; - hasfitbox = boxwidth > PDC_FLOAT_PREC && boxheight > PDC_FLOAT_PREC; + hasboxwidth = boxwidth > PDC_FLOAT_PREC; + hasfitbox = hasboxwidth && boxheight > PDC_FLOAT_PREC; /* kind of text box */ pdf_get_mbox_boxheight(p, fit->matchbox, textyextent); @@ -2680,8 +2738,10 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, switch(enc) { case pdc_cid: + /* non-Unicode compatible CMaps seem to work (see bug #1605) if (currfont->codesize != 2) poschar = -1; + */ break; case pdc_glyphid: @@ -2701,12 +2761,23 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, break; } + if (to->glyphcheck == text_error && poschar == -1) + { + pdc_set_errmsg(p->pdc, PDF_E_TEXT_ALIGNCHARNOTFOUND, + pdc_errprintf(p->pdc, "%04X", fit->alignchar), + 0, 0, 0); + if (verbose) + PDC_RETHROW(p->pdc); + + return pdc_false; + } + /* width and height of text part ranging to decimal character */ decwidth = pdf_calculate_textsize(p, utext, len, charlen, to, poschar, &decheight, pdc_true); /* position found */ - if (decwidth > 0) + if (decwidth > 0 && !PDC_FLOAT_ISNULL(width)) { /* relative position of position character */ pos1 = decwidth / width; @@ -2925,7 +2996,7 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, { pdc_scalar mwidth = 2 * fabs(elemmargin.x); pdc_scalar mheight = 2 * fabs(elemmargin.y); - pdc_scalar vlen; + pdc_scalar wlen, plen; /* start position */ pdc_transform_point(&m, x, y, &tx, &ty); @@ -2950,41 +3021,48 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, /* relative vector from start to end */ tx = fitres->end.x - fitres->start.x; ty = fitres->end.y - fitres->start.y; - vlen = sqrt(tx * tx + ty * ty); + wlen = sqrt(tx * tx + ty * ty); if (!vertical) { /* width and x scaling */ - fitres->width = vlen; - fitres->mwidth = vlen + mwidth; - fitres->scale.x = fitres->width / width; + fitres->width = wlen; + fitres->mwidth = wlen + mwidth; + } + else + { + /* height and y scaling */ + fitres->height = wlen; + fitres->mheight = wlen + mheight; + } - /* unit vector of base line */ - fitres->writingdir.x = tx / vlen; - fitres->writingdir.y = ty / vlen; + /* unit vector of writingdir line */ + if (!PDC_FLOAT_ISNULL(wlen)) + { + fitres->writingdir.x = tx / wlen; + fitres->writingdir.y = ty / wlen; + } + else + { + fitres->writingdir.x = 0; + fitres->writingdir.y = 0; + } + if (!vertical) + { /* relative vector of fontsize */ tx = x; ty = y + p->ydirection * height; pdc_transform_point(&m, tx, ty, &tx, &ty); tx -= fitres->start.x; ty -= fitres->start.y; - vlen = sqrt(tx * tx + ty * ty); + plen = sqrt(tx * tx + ty * ty); /* height and y scaling */ - fitres->height = vlen; - fitres->mheight = vlen + mheight; - fitres->scale.y = fitres->height / height; + fitres->height = plen; + fitres->mheight = plen + mheight; } else { - /* height and y scaling */ - fitres->height = vlen; - fitres->mheight = vlen + mheight; - fitres->scale.y = fitres->height / height; - - /* unit vector of perpendiculardir line */ - fitres->writingdir.x = tx / vlen; - fitres->writingdir.y = ty / vlen; /* relative vector of width */ tx = x + width; @@ -2992,17 +3070,34 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, pdc_transform_point(&m, tx, ty, &tx, &ty); tx -= fitres->start.x; ty -= fitres->start.y; - vlen = sqrt(tx * tx + ty * ty); + plen = sqrt(tx * tx + ty * ty); /* width ans x scaling */ - fitres->width = vlen; - fitres->mwidth = vlen + mwidth; - fitres->scale.x = fitres->width / width; + fitres->width = plen; + fitres->mwidth = plen + mwidth; } /* unit vector of perpendiculardir line */ - fitres->perpendiculardir.x = tx / vlen; - fitres->perpendiculardir.y = ty / vlen; + if (!PDC_FLOAT_ISNULL(plen)) + { + fitres->perpendiculardir.x = tx / plen; + fitres->perpendiculardir.y = ty / plen; + } + else + { + fitres->perpendiculardir.x = 0; + fitres->perpendiculardir.y = 0; + } + + if (!PDC_FLOAT_ISNULL(width)) + fitres->scale.x = fitres->width / width; + else + fitres->scale.x = 1.0; + + if (!PDC_FLOAT_ISNULL(height)) + fitres->scale.y = fitres->height / height; + else + fitres->scale.y = 1.0; /* rotation angle of base line */ fitres->angle = atan2(fitres->writingdir.y, fitres->writingdir.x) / @@ -3030,17 +3125,20 @@ pdf_fit_textline_internal(PDF *p, pdf_fittext *fitres, /* create a link - deprecated - */ if (to->link) { - pdf_check_textstring(p, to->text, to->textlen, + if (pdf_check_textstring(p, to->text, to->textlen, PDF_USE_TMPALLOC | PDF_KEEP_UNICODE, - to, &utext, &len, &charlen, pdc_true); - pdf_create_link(p, to->linktype, x, y + p->ydirection * descender, - x + width, y + p->ydirection * to->fontsize, - to->link, (char *) utext, len); - pdc_free_tmp(p->pdc, utext); + to, NULL, &utext, &len, &charlen, pdc_true)) + { + pdf_create_link(p, to->linktype, + x, y + p->ydirection * descender, + x + width, y + p->ydirection * to->fontsize, + to->link, (char *) utext, len); + pdc_free_tmp(p->pdc, utext); + } } } - return unmapgids; + return pdc_true; } void @@ -3048,10 +3146,11 @@ pdf_calculate_textline_size(PDF *p, pdf_text_options *to, pdf_fit_options *fit, pdc_scalar *width, pdc_scalar *height) { pdf_ppt *ppt = p->curr_ppt; - pdf_fittext fitres; + pdf_fitres fitres; pdc_matrix ctminv; /* calculate textline size for table cells */ + fitres.verbose = pdc_true; fitres.width = 0.0; fitres.height = 0.0; pdf_fit_textline_internal(p, &fitres, to, fit, NULL); @@ -3120,8 +3219,13 @@ static const pdc_keyconn pdf_info_keylist[] = {"capheight", 14}, {"xheight", 15}, {"descender", 16}, - {"unmappedglyphs", 17}, - {"angle", 18}, + {"angle", 17}, + + {"unmappedglyphs", 20}, /* deprecated */ + {"unmappedchars", 20}, + {"replacedchars", 21}, + {"unknownchars", 22}, + {"wellformed", 23}, {NULL, 0} }; @@ -3132,8 +3236,8 @@ pdf__info_textline(PDF *p, const char *text, int len, const char *keyword, pdf_ppt *ppt = p->curr_ppt; pdf_text_options to; pdf_fit_options fit; - pdf_fittext fitres; - double tinfo = 0; + pdf_fitres fitres; + double tinfo = 0.0; int retval, infokey; if (!keyword || !*keyword) @@ -3149,10 +3253,14 @@ pdf__info_textline(PDF *p, const char *text, int len, const char *keyword, if (retval) { /* calculate textline */ + fitres.verbose = to.glyphwarning; + fitres.unmappedchars = 0; + fitres.replacedchars = 0; + fitres.unknownchars = 0; retval = pdf_fit_textline_internal(p, &fitres, &to, &fit, NULL); pdf_cleanup_fit_options(p, &fit); - if (retval > -1) + if (retval) { pdf_font *currfont = &p->fonts[to.font]; pdc_matrix ctminv; @@ -3277,11 +3385,24 @@ pdf__info_textline(PDF *p, const char *text, int len, const char *keyword, break; case 17: - tinfo = (double) retval; + tinfo = (double) fitres.angle; break; - case 18: - tinfo = (double) fitres.angle; + case 20: + tinfo = (double) fitres.unmappedchars; + break; + + case 21: + tinfo = (double) fitres.replacedchars; + break; + + case 22: + tinfo = (double) fitres.unknownchars; + break; + + /* wellformed */ + case 23: + tinfo = (double) 1; break; } } @@ -3292,6 +3413,7 @@ pdf__info_textline(PDF *p, const char *text, int len, const char *keyword, + /*****************************************************************************/ /** deprecated historical text formatting function **/ /*****************************************************************************/ @@ -3363,11 +3485,7 @@ pdf__show_boxed( pdf_alignment mode = text_left; pdc_bool blind = pdc_false; - /* text length */ - if (text == NULL) - return 0; - if (!len) - len = (int) strlen(text); + len = pdc_check_text_length(p->pdc, &text, len, PDF_MAXTEXTSIZE); if (!len) return 0; @@ -3451,10 +3569,9 @@ pdf__show_boxed( int charlen; /* convert text string */ - pdf_check_textstring(p, text, len, + if (!pdf_check_textstring(p, text, len, PDF_KEEP_CONTROL | PDF_KEEP_TEXTLEN | PDF_USE_TMPALLOC, - currto, &utext, &len, &charlen, pdc_true); - if (utext == NULL || !len) + currto, NULL, &utext, &len, &charlen, pdc_true)) return 0; utext[len] = 0; diff --git a/src/pdflib/pdflib/p_textflow.c b/src/pdflib/pdflib/p_textflow.c index 006facb..fc4ab3d 100644 --- a/src/pdflib/pdflib/p_textflow.c +++ b/src/pdflib/pdflib/p_textflow.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_textflow.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_textflow.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib textflow function * diff --git a/src/pdflib/pdflib/p_tiff.c b/src/pdflib/pdflib/p_tiff.c index 5ed382f..3116a50 100644 --- a/src/pdflib/pdflib/p_tiff.c +++ b/src/pdflib/pdflib/p_tiff.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_tiff.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_tiff.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * TIFF processing for PDFlib * @@ -22,7 +22,7 @@ #ifndef HAVE_LIBTIFF -pdc_bool /* CDPDF fixed last parameter declaration */ +pdc_bool pdf_is_TIFF_file(PDF *p, pdc_file *fp, pdf_tiff_info *tiff, pdc_bool check) { (void) p; @@ -38,7 +38,7 @@ pdf_process_TIFF_data( PDF *p, int imageslot) { - pdf_image *image = &p->images[imageslot]; + (void) imageslot; pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "TIFF", 0, 0, 0); @@ -114,7 +114,7 @@ pdf_libtiff_error(TIFF *t, const char* module, const char* fmt, va_list ap) char buffer[PDF_TIFF_LENGTH_MAX]; /* Create the message */ - pdc_vsnprintf(buffer, PDF_TIFF_LENGTH_MAX, fmt, ap); + pdc_vsnprintf(p->pdc, buffer, PDF_TIFF_LENGTH_MAX, fmt, ap); pdc_logg(p->pdc, "\tlibtiff(%s): %s\n", module, buffer); } } @@ -240,6 +240,7 @@ pdf_data_source_TIFF_fill(PDF *p, PDF_data_source *src) } else { + { if (image->info.tiff.cur_line++ == image->height) { PDC_EXIT_TRY(p->pdc); @@ -308,6 +309,7 @@ pdf_data_source_TIFF_fill(PDF *p, PDF_data_source *src) pdc_error(p->pdc, PDF_E_IMAGE_BADCOMP, pdc_errprintf(p->pdc, "%d", image->components), pdf_get_image_filename(p, image), 0, 0); + } } } } @@ -365,7 +367,7 @@ pdf_process_TIFF_data( int imageslot) { static const char *fn = "pdf_process_TIFF_data"; - uint32 w, h; + uint32 width, height; uint16 unit, bpc, compression, photometric, extra, *sinfo; uint16 orientation, planarconfig; uint16 *rmap, *gmap, *bmap; @@ -407,11 +409,11 @@ pdf_process_TIFF_data( TIFFGetField(MYTIFF, TIFFTAG_COMPRESSION, &compression); - TIFFGetField(MYTIFF, TIFFTAG_IMAGEWIDTH, &w); - image->width = (pdc_scalar) w; + TIFFGetField(MYTIFF, TIFFTAG_IMAGEWIDTH, &width); + image->width = (pdc_scalar) width; - TIFFGetField(MYTIFF, TIFFTAG_IMAGELENGTH, &h); - image->height = (pdc_scalar) h; + TIFFGetField(MYTIFF, TIFFTAG_IMAGELENGTH, &height); + image->height = (pdc_scalar) height; TIFFGetFieldDefaulted(MYTIFF, TIFFTAG_BITSPERSAMPLE, &bpc); image->bpc = bpc; @@ -465,14 +467,14 @@ pdf_process_TIFF_data( /* Catch some rare properties related to compression, photometric, * and bpc which are definitely not supported (neither in pass-through - * mode nor libtiff) in order to provide a better error message than + * mode nor libtiff) in order to provide a better error message than * the generic "Error reading data". */ /* Unsupported compression types */ switch ((int) compression) { - case /* 34661 */ COMPRESSION_JBIG: + case /* 34661 */ COMPRESSION_JBIG: case /* 34712 */ COMPRESSION_JP2000: case 9 /* JBIG T85 */: case 10 /* TIFF-FX JBIG (T.82) MRC (T.43) */: @@ -575,7 +577,7 @@ pdf_process_TIFF_data( if (strips > 25 && compression != COMPRESSION_OJPEG && compression != COMPRESSION_JPEG && photometric != PHOTOMETRIC_PALETTE && - image->width * image->width < PDF_TIFF_THRESHOLD) + image->width * image->height < PDF_TIFF_THRESHOLD) { image->use_raw = pdc_false; } @@ -808,7 +810,7 @@ pdf_process_TIFF_data( if (planarconfig == PLANARCONFIG_SEPARATE && (compression == COMPRESSION_OJPEG || compression==COMPRESSION_JPEG)) { - errcode = PDF_E_TIFF_UNSUPP_JPEG_SEPARATE; + errcode = PDF_E_TIFF_UNSUPP_SEPARATE; goto PDF_TIFF_ERROR; } @@ -835,6 +837,7 @@ pdf_process_TIFF_data( TIFFGetField(MYTIFF, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { image->components = 3; + image->bpc = 8; } pdc_logg_cond(p->pdc, 1, trc_image, "\tno passthrough mode...\n"); } @@ -928,6 +931,8 @@ pdf_process_TIFF_data( image->src.init = pdf_data_source_TIFF_init; image->src.fill = pdf_data_source_TIFF_fill; image->src.terminate = pdf_data_source_TIFF_terminate; + image->in_use = pdc_true; /* mark slot as used */ + image->src.next_byte = NULL; if (image->use_raw) { uint32 row, rowsperstrip; @@ -945,6 +950,25 @@ pdf_process_TIFF_data( goto PDF_TIFF_ERROR; } + /* CCITT compression implicitly carries + * photometric==PHOTOMETRIC_MINISWHITE. Although the combination + * of CCITT compression and palette probably doesn't conform + * to the TIFF spec, we accept it, but must invert the color + * palette in order to match Acrobat's behavior. + * Note that most TIFF viewers either ignore the palette in + * this case or display the image with wrong colors. + */ + if (compression == COMPRESSION_CCITTRLE || + compression == COMPRESSION_CCITTRLEW || + compression == COMPRESSION_CCITTFAX3 || + compression == COMPRESSION_CCITTFAX4) + { + image->invert = !image->invert; + pdc_logg_cond(p->pdc, 1, trc_image, + "\tinverting colors for CCITT-compressed " + "image with palette...\n"); + } + cs.type = Indexed; cs.val.indexed.palette_size = 1 << bpc; cs.val.indexed.colormap = &colormap; @@ -952,7 +976,7 @@ pdf_process_TIFF_data( cs.val.indexed.base = DeviceRGB; -#define CVT(x) (uint16) (((x) * 255) / ((1L<<16)-1)) +#define CVT(x) (uint16) ((x)>>8) /* TODO: properly deal with 16-bit palette entries in PDF 1.5 */ if (pdf_check_colormap(cs.val.indexed.palette_size, rmap, gmap, bmap) == 16) @@ -999,7 +1023,8 @@ pdf_process_TIFF_data( */ image->info.tiff.cur_line = 0; image->height = (pdc_scalar) - (image->rowsperstrip > (int) h ? (int) h : image->rowsperstrip); + (image->rowsperstrip > (int) height ? + (int) height : image->rowsperstrip); /* * Images may also be written to the output before the first page @@ -1012,10 +1037,10 @@ pdf_process_TIFF_data( pdf_put_image(p, imageslot, pdc_true, pdc_false); for (row = (uint32) image->rowsperstrip, strip = 1; - row < h; row += (uint32) image->rowsperstrip, strip++) { - - image->height = (pdc_scalar) (row+image->rowsperstrip > h ? - (int) (h - row) : image->rowsperstrip); + row < height; row += (uint32) image->rowsperstrip, strip++) + { + image->height = (pdc_scalar) (row+image->rowsperstrip > height ? + (int) (height - row) : image->rowsperstrip); /* * tell pdf_data_source_TIFF_fill() to read only data of the @@ -1023,16 +1048,20 @@ pdf_process_TIFF_data( */ image->info.tiff.cur_line = strip; pdf_put_image(p, imageslot, pdc_false, pdc_false); + /* Refresh, in case p->images reallocate */ + image = &p->images[imageslot]; } - image->height = (pdc_scalar) h; + image->height = (pdc_scalar) height; image->no -= (image->strips - 1); /* number of first strip */ /* Special handling for multi-strip images (see comment above) */ if (PDF_GET_STATE(p) == pdf_state_page) pdf_begin_contents_section(p); - } else { /* !use_raw */ + } + else /* !use_raw */ + { size_t npixels; @@ -1056,15 +1085,20 @@ pdf_process_TIFF_data( image->pixelmode = pdc_true; } - if (image->pixelmode) + if (planarconfig == PLANARCONFIG_SEPARATE) { - npixels = (size_t) (w * h); + errcode = PDF_E_TIFF_UNSUPP_SEPARATE; + goto PDF_TIFF_ERROR; + } + else if (image->pixelmode) + { + npixels = (size_t) (width * height); image->info.tiff.raster = (uint32 *) pdc_malloc(p->pdc, (size_t) (npixels * sizeof (uint32)), fn); if (!TIFFReadRGBAImageOriented(MYTIFF, - w, h, image->info.tiff.raster, orientation, 1)) + width, height, image->info.tiff.raster, orientation, 1)) { errcode = PDC_E_IO_READ; goto PDF_TIFF_ERROR; @@ -1072,33 +1106,41 @@ pdf_process_TIFF_data( } else { - int linecounter = 0; + int linecounter = 0, sclsize = TIFFScanlineSize(MYTIFF); - npixels = (size_t) (TIFFScanlineSize(MYTIFF) * h); - image->info.tiff.raster = (uint32 *) - pdc_malloc(p->pdc, (size_t) npixels, fn); + npixels = (size_t) (sclsize * height); + image->info.tiff.raster = (uint32 *)pdc_malloc(p->pdc, npixels, fn); - while (linecounter < image->height) - { - if (TIFFReadScanline(MYTIFF, - (tdata_t) (image->info.tiff.raster + - ((int)image->height - linecounter - 1) * (int)image->width), - (uint32) linecounter, (tsample_t) 0) == -1) + while (linecounter < (int) height) { - errcode = PDC_E_IO_READ; - goto PDF_TIFF_ERROR; - } - linecounter++; - } - } + size_t ndots = (size_t)((height - linecounter - 1) * width); + + if (npixels <= sizeof(uint32) * ndots) + { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_TIFF_ERROR; + } + + if (TIFFReadScanline(MYTIFF, + (tdata_t) (image->info.tiff.raster + ndots), + (uint32) linecounter, (tsample_t) 0) == -1) + { + errcode = PDC_E_IO_READ; + goto PDF_TIFF_ERROR; + } + linecounter++; + } + } pdf_put_image(p, imageslot, pdc_true, pdc_true); - if (image->info.tiff.raster != NULL) + if (image->info.tiff.raster != NULL){ pdc_free(p->pdc, (void *) image->info.tiff.raster); + image->info.tiff.raster = NULL; + } + } - image->in_use = pdc_true; /* mark slot as used */ if (!image->corrupt) { @@ -1130,7 +1172,7 @@ pdf_process_TIFF_data( case PDF_E_IMAGE_COLORMAP: case PDF_E_IMAGE_BADMASK: case PDF_E_TIFF_CMYK_MASK: - case PDF_E_TIFF_UNSUPP_JPEG_SEPARATE: + case PDF_E_TIFF_UNSUPP_SEPARATE: case PDF_E_TIFF_16BITCMYK_UNSUPP: case PDF_E_TIFF_16BIT_UNSUPP: pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); diff --git a/src/pdflib/pdflib/p_truetype.c b/src/pdflib/pdflib/p_truetype.c index 80f2f10..c8b8ec3 100644 --- a/src/pdflib/pdflib/p_truetype.c +++ b/src/pdflib/pdflib/p_truetype.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_truetype.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_truetype.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib TrueType handling routines * @@ -248,9 +248,11 @@ pdf_get_metrics_tt(PDF *p, pdf_font *font, const char *fontname, pdc_logg(p->pdc, "\tFull font name: \"%s\"\n" "\tPostScript font name: \"%s\"\n" - "\tFont embedding: %s\n", + "\tFont embedding: %s\n" + "\tVertical font: %s\n", font->ft.name, font->ft.m.name, - PDC_BOOLSTR(font->opt.embedding)); + PDC_BOOLSTR(font->opt.embedding), + PDC_BOOLSTR(font->ft.vertical)); if (ttf->tab_name->producer != NULL) pdc_logg(p->pdc, "\tFont producer: \"%s\"\n", @@ -266,6 +268,7 @@ pdf_get_metrics_tt(PDF *p, pdf_font *font, const char *fontname, flags = TT_FONT_code2gid | TT_FONT_m_widths; + /* Create font mapping and width arrays */ foundglyphs = fnt_set_tt_fontarrays(ttf, flags); diff --git a/src/pdflib/pdflib/p_type1.c b/src/pdflib/pdflib/p_type1.c index 8483710..bfdd403 100644 --- a/src/pdflib/pdflib/p_type1.c +++ b/src/pdflib/pdflib/p_type1.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_type1.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_type1.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib Type1 font handling routines * @@ -130,12 +130,10 @@ PFA_data_fill(PDF *p, PDF_data_source *src) (!pdc_isxdigit(s[i+1]) && !pdc_isspace(s[i+1]))) { pdc_fclose(t1_private->fontfile); - pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFA", "?", 0, 0); + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFA", "", 0, 0); } -#ifndef PDFLIB_EBCDIC s[i/2] = (char) (16*HexToBin[s[i]-'0'] + HexToBin[s[i+1]-'0']); -#else -#endif + src->bytes_available++; } t1_private->length[2] += src->bytes_available; @@ -186,13 +184,19 @@ pdf_read_pfb_segment(PDF *p, PDF_data_source *src, t1_private_data *t1, int i) length |= (size_t) (pdf_t1getc(t1) & 0xff) << 16; length |= (size_t) (pdf_t1getc(t1) & 0xff) << 24; + pdc_logg_cond(p->pdc, 5, trc_font, + " and length x%04X", length); + if (src->buffer_start) pdc_free(p->pdc, (void *) src->buffer_start); src->buffer_start = (pdc_byte *) pdc_malloc(p->pdc, length, fn); - if (t1->fontfile) { + if (t1->fontfile) + { len = pdc_fread(src->buffer_start, 1, length, t1->fontfile); - } else { + } + else + { len = length; if (t1->pos + len > t1->end) len = (unsigned int)(t1->end - t1->pos); @@ -204,54 +208,61 @@ pdf_read_pfb_segment(PDF *p, PDF_data_source *src, t1_private_data *t1, int i) src->next_byte = src->buffer_start; src->bytes_available = len; - return (len != length) ? pdc_true : pdc_false;; + return (len != length) ? pdc_false : pdc_true; } -static int +static pdc_bool PFB_data_fill(PDF *p, PDF_data_source *src) { - t1_private_data *t1; - unsigned char c, type; - pdc_bool err = pdc_false; + pdc_bool logg = pdc_logg_is_enabled(p->pdc, 5, trc_font); + t1_private_data *t1 = (t1_private_data *) src->private_data; + pdc_bool succ = pdc_false; + pdc_byte c, type; + int i; - t1 = (t1_private_data *) src->private_data; + c = (pdc_byte) pdf_t1getc(t1); - c = (unsigned char) pdf_t1getc(t1); - type = (unsigned char) pdf_t1getc(t1); + if (c == PFB_MARKER) + { + type = (pdc_byte) pdf_t1getc(t1); - if (t1->length[1] == (size_t) 0) { - if (c != PFB_MARKER || type != PFB_ASCII) { - err = pdc_true; - } else { - err = pdf_read_pfb_segment(p, src, t1, 1); - } + if (logg) + pdc_logg(p->pdc, "\t\t\treading segment of type x%02X", type); - } else if (t1->length[2] == (size_t) 0) { - if (c != PFB_MARKER || type != PFB_BINARY) { - err = pdc_true; - } else { - err = pdf_read_pfb_segment(p, src, t1, 2); + for (i = 1; i < 4; i++) + { + if (t1->length[i] == (size_t) 0) + { + succ = pdf_read_pfb_segment(p, src, t1, i); + break; + } } - } else if (t1->length[3] == 0) { - if (c != PFB_MARKER || type != PFB_ASCII) { - err = pdc_true; - } else { - err = pdf_read_pfb_segment(p, src, t1, 3); + if (i < 4) + { + if (succ) + { + if (logg) + pdc_logg(p->pdc, " successful\n"); + return pdc_true; + } + } + else + { + if (logg) + pdc_logg(p->pdc, " (EOF)\n"); + return pdc_false; } - } else if (c != PFB_MARKER || type != PFB_EOF) { - err = pdc_true; - } else { - return pdc_false; } - if (err) { - if (t1->fontfile) - pdc_fclose(t1->fontfile); - pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFB", "?", 0, 0); - } + if (logg) + pdc_logg(p->pdc, " unsuccessful\n"); - return pdc_true; + if (t1->fontfile) + pdc_fclose(t1->fontfile); + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFB", "", 0, 0); + + return pdc_false; } static void @@ -286,25 +297,32 @@ pdf_t1open_fontfile(PDF *p, pdf_font *font, const char *filename, t1_private_data *t1_private = NULL; pdc_file *fp = NULL; const char *stemp = NULL; - unsigned char magic[PFA_TESTBYTE]; + pdc_byte magic[PFA_TESTBYTE]; char fullname[PDC_FILENAMELEN]; int fflags = PDC_FILE_BINARY; - int ispfb = pdc_true; + pdc_bool ispfb = pdc_true; if (filename) { + pdc_bool retval = pdc_true; + pdc_bool fnamegiven = (strcmp(filename, FNT_MISSING_FILENAME) == 0) ? + pdc_false : pdc_true; + (void) retval; - fp = pdc_fsearch_fopen(p->pdc, filename, fullname, "PostScript Type1 ", - fflags); - if (fp == NULL) + if (fnamegiven) { - if (t1src) - pdc_error(p->pdc, -1, 0, 0, 0, 0); - return pdc_check_fopen_errmsg(p->pdc, requested); - } + fp = pdc_fsearch_fopen(p->pdc, filename, fullname, + "PostScript Type1 ", fflags); + if (fp == NULL) + { + if (t1src) + PDC_RETHROW(p->pdc); + return pdc_check_fopen_errmsg(p->pdc, requested); + } - pdc_logg_cond(p->pdc, 1, trc_font, - "\tLoading PostScript Type1 fontfile \"%s\":\n", fullname); + pdc_logg_cond(p->pdc, 1, trc_font, + "\tLoading PostScript Type1 fontfile \"%s\":\n", fullname); + } } @@ -332,7 +350,7 @@ pdf_t1open_fontfile(PDF *p, pdf_font *font, const char *filename, pdc_fclose(fp); pdc_set_errmsg(p->pdc, PDF_E_T1_NOFONT, stemp, 0, 0, 0); if (t1src) - pdc_error(p->pdc, -1, 0, 0, 0, 0); + PDC_RETHROW(p->pdc); return pdc_false; } ispfb = pdc_false; @@ -364,7 +382,7 @@ pdf_t1open_fontfile(PDF *p, pdf_font *font, const char *filename, } if (t1_private->fontfile == NULL) - pdc_error(p->pdc, -1, 0, 0, 0, 0); + PDC_RETHROW(p->pdc); } else if (font->ft.img) { diff --git a/src/pdflib/pdflib/p_type3.c b/src/pdflib/pdflib/p_type3.c index c177443..d31592f 100644 --- a/src/pdflib/pdflib/p_type3.c +++ b/src/pdflib/pdflib/p_type3.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_type3.c,v 1.2 2009/06/23 03:18:34 scuri Exp $ +/* $Id: p_type3.c,v 1.3 2009/10/20 18:14:16 scuri Exp $ * * Routines for Type 3 (user-defined) fonts * @@ -147,6 +147,7 @@ pdf_handle_t3font(PDF *p, const char *fontname, pdc_encoding enc, /* copy data from available font (see pdf__begin_font()) */ font->ft.m.type = fnt_Type3; font->ft.matrix = deffont->ft.matrix; + font->ft.bbox = deffont->ft.bbox; font->t3font = deffont->t3font; font->ft.numglyphs = deffont->t3font->next_glyph; nalloc = (size_t) font->ft.numglyphs; @@ -321,7 +322,6 @@ pdf__begin_font( const char *optlist) { static const char fn[] = "pdf__begin_font"; - char *fname; pdc_resopt *results; pdf_font tmpfont, *font; pdf_font_options fo; @@ -335,11 +335,10 @@ pdf__begin_font( pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); /* Converting fontname */ - fname = pdf_convert_name(p, fontname, len, PDC_CONV_WITHBOM); - if (fname == NULL || *fname == '\0') + fontname = pdf_convert_name(p, fontname, len, + PDC_CONV_WITHBOM | PDC_CONV_TMPALLOC); + if (fontname == NULL || *fontname == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); - fontname = pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, fname); - pdc_free(p->pdc, fname); pdc_logg_cond(p->pdc, 1, trc_font, "\tBegin of Type3 font \"%s\"\n", fontname); @@ -633,7 +632,7 @@ pdf__begin_glyph( /* see comment in p_font.c for explanation */ glyph->width = 1000 * wx * font->ft.matrix.a; - /* if the pdc_strdup above fails, cleanup won't touch this slot. */ + /* if the strdup above fails, cleanup won't touch this slot. */ t3font->next_glyph++; } glyph->pass = t3font->pass; @@ -692,7 +691,7 @@ pdf__begin_glyph( } else { - PDF_SET_STATE(p, pdf_state_glyphmetric); + PDF_SET_STATE(p, pdf_state_glyphmetrics); } pdc_pop_errmsg(p->pdc); diff --git a/src/pdflib/pdflib/p_util.c b/src/pdflib/pdflib/p_util.c index 2728236..8b3f5e6 100644 --- a/src/pdflib/pdflib/p_util.c +++ b/src/pdflib/pdflib/p_util.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_util.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_util.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib utility functions * @@ -320,6 +320,9 @@ pdf_convert_hypertext(PDF *p, const char *text, int len, /* conversion to UTF-16-BE or PDFDocEncoding / EBCDIC */ pdf_set_convertflags(p, &convflags); + if (pdc_logg_is_enabled(p->pdc, 3, trc_text)) + convflags |= PDC_CONV_LOGGING; + pdc_convert_string(p->pdc, hypertextformat, codepage, inev, intext, len, &textformat, outev, &outtext, outlen, @@ -332,9 +335,13 @@ pdf_convert_hypertext(PDF *p, const char *text, int len, pdc_text_format outtextformat = PDC_UTF8; pdc_byte *newtext = NULL; + convflags = PDC_CONV_WITHBOM; + if (pdc_logg_is_enabled(p->pdc, 3, trc_text)) + convflags |= PDC_CONV_LOGGING; + pdc_convert_string(p->pdc, textformat, 0, NULL, outtext, *outlen, &outtextformat, NULL, &newtext, outlen, - PDC_CONV_WITHBOM, verbose); + convflags, verbose); pdc_free(p->pdc, outtext); outtext = newtext; } @@ -346,61 +353,101 @@ pdf_convert_hypertext(PDF *p, const char *text, int len, /* * Conversion from [EBCDIC-]UTF-8 to UTF-16 and from EBCDIC to PDFDoc */ -static void -pdf_put_hypertext_ext(PDF *p, const char *text, pdc_bool isfilename) + +char * +pdf_convert_pdfstring(PDF *p, const char *text, int inlen, int convflags, + int *outlen) { pdc_byte *newtext = NULL; - pdc_encodingvector *outev = pdc_get_encoding_vector(p->pdc, pdc_pdfdoc); - int len = (int) pdc_strlen(text); - int convflags = PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES; if (pdc_is_utf8_bytecode(text)) { pdc_text_format textformat = PDC_UTF8; pdc_text_format outtextformat = pdc_utf16be; + pdc_encodingvector *outev = pdc_get_encoding_vector(p->pdc, pdc_pdfdoc); pdf_set_convertflags(p, &convflags); - pdc_convert_string(p->pdc, textformat, 0, NULL, (pdc_byte *) text, len, - &outtextformat, outev, &newtext, &len, - convflags, pdc_true); - text = (const char *) newtext; - } - if (isfilename) - { - if (pdc_is_utf16be_unicode(text)) - pdc_error(p->pdc, PDC_E_IO_UNSUPP_UNINAME, 0, 0, 0, 0); - pdc_put_pdffilename(p->out, text, len); + pdc_convert_string(p->pdc, textformat, 0, NULL, + (pdc_byte *) text, inlen, + &outtextformat, outev, &newtext, outlen, + convflags, pdc_true); } else { - pdc_put_pdfstring(p->out, text, len); + newtext = (pdc_byte *) text; + *outlen = inlen; } - if (newtext != NULL) - pdc_free(p->pdc, newtext); + return (char *) newtext; } void pdf_put_hypertext(PDF *p, const char *text) { - pdf_put_hypertext_ext(p, text, pdc_false); + int convflags = PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES; + int inlen = (int) pdc_strlen(text); + int outlen; + + char *newtext = pdf_convert_pdfstring(p, text, inlen, convflags, &outlen); + + pdc_put_pdfstring(p->out, newtext, outlen); + + if (newtext != text) + pdc_free(p->pdc, newtext); } void pdf_put_pdffilename(PDF *p, const char *text) { - pdf_put_hypertext_ext(p, text, pdc_true); + int convflags = PDC_CONV_FILENAME | PDC_CONV_TRYBYTES; + int inlen = (int) pdc_strlen(text); + int outlen; + + char *newtext = pdf_convert_pdfstring(p, text, inlen, convflags, &outlen); + + pdc_put_pdffilename(p->out, newtext, outlen); + + if (newtext != text) + pdc_free(p->pdc, newtext); +} + +void +pdf_put_pdfunifilename(PDF *p, const char *text) +{ + int convflags = PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES; + int inlen = (int) pdc_strlen(text); + int outlen; + + char *newtext = pdf_convert_pdfstring(p, text, inlen, convflags, &outlen); + + pdc_put_pdffilename(p->out, newtext, outlen); + + if (newtext != text) + pdc_free(p->pdc, newtext); } /* ------------------------ name strings -------------------------------*/ static void -pdf_prepare_name_string(PDF *p, const char *name, int len, +pdf_prepare_name_string(PDF *p, const char *name, int len, int maxlen, char **newname, int *newlen, pdc_encoding *htenc, int *htcp) { + if (name == NULL) + { + len = 0; + name = ""; + } + + if (len < 0 || len > maxlen) + { + pdc_error(p->pdc, PDC_E_ILLARG_STRINGLEN, + pdc_errprintf(p->pdc, "%d", len), + pdc_errprintf(p->pdc, "%d", PDC_SHRT_MAX), 0, 0); + } + *newname = (char *) name; *newlen = len; *htenc = pdc_invalidenc; @@ -422,9 +469,13 @@ pdf_convert_name(PDF *p, const char *name, int len, int flags) pdc_encoding htenc; int htcp; - pdf_prepare_name_string(p, name, len, &newname, &newlen, &htenc, &htcp); + pdf_prepare_name_string(p, name, len, PDC_SHRT_MAX, + &newname, &newlen, &htenc, &htcp); flags |= PDC_CONV_EBCDIC; + if (pdc_logg_is_enabled(p->pdc, 3, trc_text)) + flags |= PDC_CONV_LOGGING; + resname = pdc_convert_name_ext(p->pdc, newname, newlen, htenc, htcp, flags); if (newname != name) pdc_free(p->pdc, newname); @@ -442,10 +493,13 @@ pdf_convert_filename(PDF *p, const char *filename, int len, pdc_encoding htenc; int htcp; - pdf_prepare_name_string(p, filename, len, &newfilename, &newlen, - &htenc, &htcp); + pdf_prepare_name_string(p, filename, len, PDC_FILENAMELEN - 1, + &newfilename, &newlen, &htenc, &htcp); flags |= PDC_CONV_EBCDIC; + if (pdc_logg_is_enabled(p->pdc, 3, trc_text)) + flags |= PDC_CONV_LOGGING; + resfilename = pdc_convert_filename_ext(p->pdc, newfilename, len, paramname, htenc, htcp, flags); if (newfilename != filename) @@ -455,15 +509,15 @@ pdf_convert_filename(PDF *p, const char *filename, int len, } void -pdf_add_resource(PDF *p, const char *category, const char *resname) +pdf_add_pdflib_resource(PDF *p, const char *category, const char *resname) { char *newresname; int newlen; pdc_encoding htenc; int htcp; - pdf_prepare_name_string(p, resname, 0, &newresname, &newlen, - &htenc, &htcp); + pdf_prepare_name_string(p, resname, 0, PDC_FILENAMELEN, + &newresname, &newlen, &htenc, &htcp); if (newlen) { char *tmpresname = pdc_utf16_to_utf8(p->pdc, newresname, newlen, @@ -496,8 +550,10 @@ pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, { pdc_byte *string = NULL; pdc_encodingvector *inev = NULL, *outev = NULL; - pdc_text_format intextformat = pdc_bytes, outtextformat = pdc_utf16be; - int convflags = PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES; + pdc_text_format intextformat = pdc_bytes; + pdc_text_format outtextformat = pdc_utf16be; + pdc_text_format textformat; + int convflags = PDC_CONV_WITHBOM; pdc_bool isutf8; int i, outlen; @@ -517,8 +573,10 @@ pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, inev = pdc_get_encoding_vector(p->pdc, enc); } - /* PDFDocEncoding */ outev = pdc_get_encoding_vector(p->pdc, pdc_pdfdoc); + + /* conversion to PDFDocEncoding if possible */ + convflags |= PDC_CONV_TRYBYTES; } else { @@ -531,9 +589,10 @@ pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, } return 0; } - else if (enc >= 0) + else if (enc >= 0 && !isutf8) { - outev = pdc_get_encoding_vector(p->pdc, enc); + /* bug #2069: always conversion to UTF-16BE */ + inev = pdc_get_encoding_vector(p->pdc, enc); } } @@ -556,16 +615,17 @@ pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, string = (pdc_byte *) strlist[i]; { - if (ishypertext || isutf8) + if (ishypertext || isutf8 || inev != NULL) { intextformat = isutf8 ? PDC_UTF8 : pdc_bytes; - if (pdc_logg_is_enabled(p->pdc, 2, trc_optlist)) + if (pdc_logg_is_enabled(p->pdc, 3, trc_text)) convflags |= PDC_CONV_LOGGING; pdf_set_convertflags(p, &convflags); + textformat = outtextformat; pdc_convert_string(p->pdc, intextformat, codepage, inev, string, (int) strlen((char *) string), - &outtextformat, outev, &string, &outlen, + &textformat, outev, &string, &outlen, convflags, pdc_true); pdc_free(p->pdc, strlist[i]); strlist[i] = (char *) string; @@ -588,6 +648,98 @@ pdf_get_opt_textlist(PDF *p, const char *keyword, pdc_resopt *resopts, return ns; } +char * +pdf_get_opt_filename(PDF *p, const char *keyword, pdc_resopt *resopts, + pdc_encoding enc, int codepage) +{ + pdc_bool logg1 = pdc_logg_is_enabled(p->pdc, 1, trc_optlist); + pdc_bool logg3 = pdc_logg_is_enabled(p->pdc, 3, trc_text); + pdc_byte *filename = NULL; + char **strlist; + + if (pdc_get_optvalues(keyword, resopts, NULL, &strlist)) + { + pdc_encodingvector *inev = NULL, *outev = NULL; + pdc_text_format intextformat = pdc_bytes; + pdc_text_format outtextformat = pdc_utf16; /* sic! */ + int convflags = PDC_CONV_NOBOM | PDC_CONV_TRYBYTES | PDC_CONV_NEWALLOC; + pdc_bool isutf8; + int ic, outlen; + + /* whole option list or string list is in UTF-8 */ + isutf8 = pdc_is_lastopt_utf8(resopts); + + if (!isutf8) + { + if (enc < 0 && enc != pdc_unicode && enc != pdc_cid) + enc = pdf_get_hypertextencoding(p, "auto", &codepage, + pdc_true); + if (enc >= 0) + inev = pdc_get_encoding_vector(p->pdc, enc); + } + else + { + intextformat = PDC_UTF8; + } + + if (logg1) + { + if (isutf8) + { + pdc_logg(p->pdc, "\tOption \"%s\" is "PDC_UTF8_STRG" encoded\n", + keyword); + } + else + { + pdc_logg(p->pdc, "\tOption \"%s\" is %s encoded\n", + keyword, pdc_get_user_encoding(p->pdc, enc)); + } + } + + outev = pdc_get_encoding_vector(p->pdc, pdc_winansi); + + if (logg3) + convflags |= PDC_CONV_LOGGING; + pdf_set_convertflags(p, &convflags); + + pdc_convert_string(p->pdc, intextformat, codepage, inev, + (pdc_byte *) strlist[0], (int) strlen(strlist[0]), + &outtextformat, outev, &filename, &outlen, + convflags, pdc_true); + + if (outtextformat == pdc_utf16) + { + pdc_ushort uv, *unifilename = (pdc_ushort *) filename; + int code; + + if (p->compatibility < PDC_1_7) + pdc_error(p->pdc, PDC_E_IO_UNSUPP_PDFUNINAME, 0, 0, 0, 0); + + /* we must replace non-WinAnsi characters by period + * and omit the BOM to get a WinAnsi string. + */ + outlen /= 2; + for (ic = 0; ic < outlen; ic++) + { + uv = unifilename[ic]; + + code = pdc_get_encoding_bytecode(p->pdc, outev, uv); + if (code <= 0) + uv = PDC_UNICODE_PERIOD; + + filename[ic] = (char) uv; + } + filename[ic] = 0; + } + + if (logg3) + pdc_logg_hexdump(p->pdc, "output filename", "\t\t", + (char *) filename, strlen((char *) filename)); + } + + return (char *) filename; +} + char * pdf_get_opt_utf8name(PDF *p, const char *keyword, pdc_resopt *resopts) { @@ -623,9 +775,10 @@ pdf_get_errorpolicy(PDF *p, pdc_resopt *resopts, pdc_bool verbose) /* -------------------------- handle check -------------------------------*/ -void -pdf_check_handle(PDF *p, int handle, pdc_opttype type) +int +pdf_check_opt_handle(void *opaque, int handle, pdc_opttype type) { + PDF *p = (PDF*)opaque; int minval = 0, maxval = 0; pdc_bool empty = pdc_false; @@ -701,13 +854,23 @@ pdf_check_handle(PDF *p, int handle, pdc_opttype type) } if (handle < minval || handle > maxval || empty) + return PDC_E_ILLARG_HANDLE; + + return 0; +} + +void +pdf_check_handle(PDF *p, int handle, pdc_opttype type) +{ + if (pdf_check_opt_handle(p, handle, type)) { - const char *stemp1 = pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, - pdc_get_handletype(type)); - const char *stemp2 = pdc_errprintf(p->pdc, "%d", - (p->pdc->hastobepos && type != pdc_stringhandle) ? - handle + 1 : handle); - pdc_error(p->pdc, PDC_E_ILLARG_HANDLE, stemp1, stemp2, 0, 0); + if (p->pdc->hastobepos && type != pdc_stringhandle) + handle++; + + pdc_error(p->pdc, PDC_E_ILLARG_HANDLE, + pdc_errprintf(p->pdc, "%.*s", PDC_ERR_MAXSTRLEN, + pdc_get_handletype(type)), + pdc_errprintf(p->pdc, "%d", handle), 0, 0); } } diff --git a/src/pdflib/pdflib/p_xgstate.c b/src/pdflib/pdflib/p_xgstate.c index 0e62df9..32acf55 100644 --- a/src/pdflib/pdflib/p_xgstate.c +++ b/src/pdflib/pdflib/p_xgstate.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_xgstate.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_xgstate.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Extended graphics state handling * @@ -234,13 +234,12 @@ void pdf_write_page_extgstates(PDF *p) { int i, total = 0; - int bias = p->curr_ppt->eg_bias; for (i = 0; i < p->extgstates_number; i++) if (p->extgstates[i].used_on_current_page) total++; - if (total > 0 || bias) + if (total > 0) { pdc_puts(p->out, "/ExtGState"); pdc_begin_dict(p->out); @@ -253,12 +252,11 @@ pdf_write_page_extgstates(PDF *p) if (p->extgstates[i].used_on_current_page) { p->extgstates[i].used_on_current_page = pdc_false; /* reset */ - pdc_printf(p->out, "/GS%d", bias + i); + pdc_printf(p->out, "/GS%d", i); pdc_objref(p->out, "", p->extgstates[i].obj_id); } } - if (!bias) pdc_end_dict(p->out); } } @@ -505,10 +503,14 @@ pdf__create_gstate(PDF *p, const char *optlist) void pdf__set_gstate(PDF *p, int gstate) { - int bias = p->curr_ppt->eg_bias; + pdf_extgstateresource *gs; pdf_check_handle(p, gstate, pdc_gstatehandle); - pdc_printf(p->out, "/GS%d gs\n", bias + gstate); + pdc_printf(p->out, "/GS%d gs\n", gstate); p->extgstates[gstate].used_on_current_page = pdc_true; + + gs = &p->extgstates[gstate]; + if (gs->opacity_fill != pdc_undef || gs->opacity_stroke != pdc_undef) + pdf_set_autotgroup(p, pdc_true); } diff --git a/src/pdflib/pdflib/p_xmp.c b/src/pdflib/pdflib/p_xmp.c index eec4002..5db2615 100644 --- a/src/pdflib/pdflib/p_xmp.c +++ b/src/pdflib/pdflib/p_xmp.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_xmp.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_xmp.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib Metadata (XMP) related routines * @@ -23,3 +23,8 @@ + + + + + diff --git a/src/pdflib/pdflib/pdflib.c b/src/pdflib/pdflib/pdflib.c index 7ecd1f3..c369abe 100644 --- a/src/pdflib/pdflib/pdflib.c +++ b/src/pdflib/pdflib/pdflib.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: pdflib.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: pdflib.c,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * PDFlib API functions * @@ -330,6 +330,21 @@ pdf_exit_handle_api(PDF *p, int retval) return retval; } +static void +pdf_logg_is_deprecated(PDF *p, const char *fn, int version) +{ + pdc_logg_cond(p->pdc, 2, trc_api, + "[Function \"%s\" is deprecated since PDFlib %d]\n", + fn, version); +} + +static void +pdf_logg_is_unsupported(PDF *p, const char *fn) +{ + pdc_logg_cond(p->pdc, 2, trc_api, + "[Function \"%s\" is unsupported]\n", fn); +} + /*************************** * @@ -628,6 +643,8 @@ PDF_attach_file( int len_descr = description ? (int) pdc_strlen(description) : 0; int len_auth = author ? (int) pdc_strlen(author) : 0; + pdf_logg_is_deprecated(p, fn, 6); + pdf__attach_file(p, llx, lly, urx, ury, filename, 0, description, len_descr, author, len_auth, mimetype, icon); @@ -659,6 +676,8 @@ PDF_attach_file2( author, len_auth, len_auth, mimetype, icon)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__attach_file(p, llx, lly, urx, ury, filename, len_filename, description, len_descr, author, len_auth, mimetype, icon); @@ -688,6 +707,8 @@ PDF_add_note( int len_cont = contents ? (int) pdc_strlen(contents) : 0; int len_title = title ? (int) pdc_strlen(title) : 0; + pdf_logg_is_deprecated(p, fn, 6); + pdf__add_note(p, llx, lly, urx, ury, contents, len_cont, title, len_title, icon, open); @@ -715,6 +736,8 @@ PDF_add_note2( (void *) p, llx, lly, urx, ury, contents, len_cont, len_cont, title, len_title, len_title, icon, open)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__add_note(p, llx, lly, urx, ury, contents, len_cont, title, len_title, icon, open); @@ -723,67 +746,73 @@ PDF_add_note2( } PDFLIB_API void PDFLIB_CALL -PDF_add_pdflink( +PDF_add_launchlink( PDF *p, double llx, double lly, double urx, double ury, - const char *filename, - int page, - const char *optlist) + const char *filename) { - static const char fn[] = "PDF_add_pdflink"; + static const char fn[] = "PDF_add_launchlink"; if (pdf_enter_api(p, fn, pdf_state_page, - "(p_%p, %f, %f, %f, %f, \"%s\", %d, \"%T\")\n", - (void *) p, llx, lly, urx, ury, filename, page, - optlist, 0)) + "(p_%p, %f, %f, %f, %f, \"%s\")\n", + (void *)p, llx, lly, urx, ury, filename)) { - pdf__add_pdflink(p, llx, lly, urx, ury, filename, page, optlist); + pdf_logg_is_deprecated(p, fn, 6); + + pdf__add_launchlink(p, llx, lly, urx, ury, filename); pdc_logg_exit_api(p->pdc, pdc_true, NULL); } } PDFLIB_API void PDFLIB_CALL -PDF_add_launchlink( +PDF_add_locallink( PDF *p, double llx, double lly, double urx, double ury, - const char *filename) + int page, + const char *optlist) { - static const char fn[] = "PDF_add_launchlink"; + static const char fn[] = "PDF_add_locallink"; if (pdf_enter_api(p, fn, pdf_state_page, - "(p_%p, %f, %f, %f, %f, \"%s\")\n", - (void *)p, llx, lly, urx, ury, filename)) + "(p_%p, %f, %f, %f, %f, %d, \"%T\")\n", + (void *) p, llx, lly, urx, ury, page, optlist, 0)) { - pdf__add_launchlink(p, llx, lly, urx, ury, filename); + pdf_logg_is_deprecated(p, fn, 6); + + pdf__add_locallink(p, llx, lly, urx, ury, page, optlist); pdc_logg_exit_api(p->pdc, pdc_true, NULL); } } PDFLIB_API void PDFLIB_CALL -PDF_add_locallink( +PDF_add_pdflink( PDF *p, double llx, double lly, double urx, double ury, + const char *filename, int page, const char *optlist) { - static const char fn[] = "PDF_add_locallink"; + static const char fn[] = "PDF_add_pdflink"; if (pdf_enter_api(p, fn, pdf_state_page, - "(p_%p, %f, %f, %f, %f, %d, \"%T\")\n", - (void *) p, llx, lly, urx, ury, page, optlist, 0)) + "(p_%p, %f, %f, %f, %f, \"%s\", %d, \"%T\")\n", + (void *) p, llx, lly, urx, ury, filename, page, + optlist, 0)) { - pdf__add_locallink(p, llx, lly, urx, ury, page, optlist); + pdf_logg_is_deprecated(p, fn, 6); + + pdf__add_pdflink(p, llx, lly, urx, ury, filename, page, optlist); pdc_logg_exit_api(p->pdc, pdc_true, NULL); } @@ -804,6 +833,8 @@ PDF_add_weblink( "(p_%p, %f, %f, %f, %f, \"%s\")\n", (void *) p, llx, lly, urx, ury, url)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__add_weblink(p, llx, lly, urx, ury, url); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -845,6 +876,8 @@ PDF_set_border_color( (pdf_state) (pdf_state_document | pdf_state_page), "(p_%p, %f, %f, %f)\n", (void *) p, red, green, blue)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__set_border_color(p, red, green, blue); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -863,6 +896,8 @@ PDF_set_border_dash( (pdf_state) (pdf_state_document | pdf_state_page), "(p_%p, %f, %f)\n", (void *) p, b, w)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__set_border_dash(p, b, w); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -881,6 +916,8 @@ PDF_set_border_style( (pdf_state) (pdf_state_document | pdf_state_page), "(p_%p, \"%s\", %f)\n", (void *) p, style, width)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__set_border_style(p, style, width); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1020,6 +1057,8 @@ PDF_setgray(PDF *p, double g) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n", (void *) p, g)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "fillstroke", "gray", g, 0, 0, 0); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1034,6 +1073,8 @@ PDF_setgray_fill(PDF *p, double gray) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n", (void *) p, gray)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "fill", "gray", gray, 0, 0, 0); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1048,6 +1089,8 @@ PDF_setgray_stroke(PDF *p, double gray) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f)\n", (void *) p, gray)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "stroke", "gray", gray, 0, 0, 0); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1062,6 +1105,8 @@ PDF_setrgbcolor(PDF *p, double r, double g, double b) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n", (void *) p, r, g, b)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "fillstroke", "rgb", r, g, b, 0); pdc_logg_exit_api(p->pdc, pdc_false, NULL); @@ -1076,6 +1121,8 @@ PDF_setrgbcolor_fill(PDF *p, double r, double g, double b) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n", (void *) p, r, g, b)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "fill", "rgb", r, g, b, 0); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1090,6 +1137,8 @@ PDF_setrgbcolor_stroke(PDF *p, double r, double g, double b) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, %f, %f, %f)\n", (void *) p, r, g, b)) { + pdf_logg_is_deprecated(p, fn, 5); + pdf__setcolor(p, "stroke", "rgb", r, g, b, 0); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1151,6 +1200,8 @@ PDF_close(PDF *p) if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p)\n", (void *) p)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__end_document(p, ""); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1204,6 +1255,8 @@ PDF_open_file(PDF *p, const char *filename) if (pdf_enter_api(p, fn, pdf_state_object, "(p_%p, \"%s\")\n", (void *) p, filename)) { + pdf_logg_is_deprecated(p, fn, 6); + retval = pdf__begin_document(p, filename, 0, ""); } @@ -1221,6 +1274,8 @@ PDF_open_mem( if (pdf_enter_api(p, fn, pdf_state_object, "(p_%p, wp_%p)\n", (void *) p, (void *) writeproc)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__begin_document_callback(p, writeproc, ""); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -1425,6 +1480,8 @@ PDF_rcurveto(PDF *p, "(p_%p, %f, %f, %f, %f, %f, %f)\n", (void *) p, x_1, y_1, x_2, y_2, x_3, y_3)) { + pdf_logg_is_unsupported(p, fn); + pdf__rcurveto(p, x_1, y_1, x_2, y_2, x_3, y_3); pdc_logg_exit_api(p->pdc, pdc_false, NULL); @@ -1454,6 +1511,8 @@ PDF_rlineto(PDF *p, double x, double y) if (pdf_enter_api(p, fn, pdf_state_path, "(p_%p, %f, %f)\n", (void *) p, x, y)) { + pdf_logg_is_unsupported(p, fn); + pdf__rlineto(p, x, y); pdc_logg_exit_api(p->pdc, pdc_false, NULL); @@ -1469,6 +1528,8 @@ PDF_rmoveto(PDF *p, double x, double y) (pdf_state) (pdf_state_content | pdf_state_path), "(p_%p, %f, %f)\n", (void *) p, x, y)) { + pdf_logg_is_unsupported(p, fn); + pdf__rmoveto(p, x, y); pdc_logg_exit_api(p->pdc, pdc_false, NULL); @@ -1552,7 +1613,7 @@ PDF_create_fieldgroup( { static const char fn[] = "PDF_create_fieldgroup"; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, \"%T\", /*c*/%d, \"%T\")\n", (void *) p, name, len, len, optlist, 0)) { @@ -1585,6 +1646,8 @@ PDF_findfont( "(p_%p, \"%s\", \"%s\", %d)\n", (void *) p, fontname, encoding, embed)) { + pdf_logg_is_deprecated(p, fn, 6); + if (embed < 0 || embed > 1) pdc_error(p->pdc, PDC_E_ILLARG_INT, "embed", pdc_errprintf(p->pdc, "%d", embed), 0, 0); @@ -1602,7 +1665,7 @@ PDF_info_font(PDF *p, int font, const char *keyword, const char *optlist) static const char fn[] = "PDF_info_font"; double retval = 0; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, \"%s\", \"%s\")\n", (void *) p, font, keyword, optlist)) { @@ -1853,7 +1916,11 @@ PDF_setpolydash(PDF *p, float *darray, int length) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, darray_%p, /*c*/%d)\n", (void *) p, (void *) darray, length)) { - char optlist[1024], *sopt; + char optlist[PDC_GEN_BUFSIZE], *sopt; + + if (length > PDF_MAX_DASHLENGTH) + pdc_error(p->pdc, PDC_E_ILLARG_TOOMANY, "darray", + pdc_errprintf(p->pdc, "%d", PDF_MAX_DASHLENGTH), 0, 0); sopt = optlist; sopt += pdc_sprintf(p->pdc, pdc_false, optlist, "dasharray {"); @@ -1921,6 +1988,9 @@ PDF_add_bookmark( "(p_%p, \"%T\", %d, %d)\n", (void *) p, text, 0, parent, open)) { int len = text ? (int) pdc_strlen(text) : 0; + + pdf_logg_is_deprecated(p, fn, 6); + retval = pdf__add_bookmark(p, text, len, parent, open); pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval); } @@ -1943,6 +2013,8 @@ PDF_add_bookmark2( "(p_%p, \"%T\", /*c*/%d, %d, %d)\n", (void *) p, text, len, len, parent, open)) { + pdf_logg_is_deprecated(p, fn, 6); + retval = pdf__add_bookmark(p, text, len, parent, open); pdc_logg_exit_api(p->pdc, pdc_true, "[%d]\n", retval); } @@ -2099,7 +2171,7 @@ PDF_fit_image( static const char fn[] = "PDF_fit_image"; /* scope check dependent on image type in kernel function */ - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_firsttest, "(p_%p, %d, %f, %f, \"%T\")\n", (void *) p, image, x, y, optlist, 0)) { if (p->pdc->hastobepos) image -= 1; @@ -2154,7 +2226,9 @@ PDF_open_CCITT( (void *) p, filename, width, height, BitReverse, K, BlackIs1)) { - char optlist[128]; + char optlist[PDC_GEN_BUFSIZE]; + + pdf_logg_is_deprecated(p, fn, 6); pdc_sprintf(p->pdc, pdc_false, optlist, "width %d height %d bitreverse %s K %d invert %s", @@ -2192,9 +2266,11 @@ PDF_open_image( width, height, components, bpc, params)) { const char *filename = data; - char optlist[512]; + char optlist[PDC_GEN_BUFSIZE]; pdc_bool memory = pdc_false; + pdf_logg_is_deprecated(p, fn, 6); + if (type == NULL || *type == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "type", 0, 0, 0); @@ -2293,7 +2369,9 @@ PDF_open_image_file( "(p_%p, \"%s\", \"%s\", \"%s\", %d)\n", (void *) p, type, filename, stringparam, intparam)) { - char optlist[128]; + char optlist[PDC_GEN_BUFSIZE]; + + pdf_logg_is_deprecated(p, fn, 6); optlist[0] = 0; if (stringparam != NULL && *stringparam != '\0') @@ -2338,10 +2416,12 @@ PDF_place_image( static const char fn[] = "PDF_place_image"; /* scope check dependent on image type in kernel function */ - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_firsttest, "(p_%p, %d, %f, %f, %f)\n", (void *) p, image, x, y, scale)) { - char optlist[128]; + char optlist[PDC_GEN_BUFSIZE]; + + pdf_logg_is_deprecated(p, fn, 6); pdc_sprintf(p->pdc, pdc_false, optlist, "dpi none scale %f", scale); if (p->pdc->hastobepos) image -= 1; @@ -2529,6 +2609,8 @@ PDF_begin_page(PDF *p, double width, double height) if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p, %f, %f)\n", (void *) p, width, height)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__begin_page(p, width, height); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -2556,6 +2638,8 @@ PDF_end_page(PDF *p) if (pdf_enter_api(p, fn, pdf_state_page, "(p_%p)\n", (void *) p)) { + pdf_logg_is_deprecated(p, fn, 6); + pdf__end_page_ext(p, ""); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -3259,7 +3343,7 @@ PDF_add_table_cell(PDF *p, int table, int column, int row, const char *text, static const char fn[] = "PDF_add_table_cell"; int retval = -1; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, %d, %d, \"%T\", /*c*/%d, \"%T\")\n", (void *) p, table, column, row, text, len, len, optlist, 0)) { @@ -3274,7 +3358,7 @@ PDF_delete_table(PDF *p, int table, const char *optlist) { static const char fn[] = "PDF_delete_table"; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, \"%T\")\n", (void *) p, table, optlist, 0)) { pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0); @@ -3308,7 +3392,7 @@ PDF_info_table(PDF *p, int table, const char *keyword) static const char fn[] = "PDF_info_table"; double retval = -1; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, \"%s\")\n", (void *) p, table, keyword)) { pdc_error(p->pdc, PDF_E_UNSUPP_TABLES, 0, 0, 0, 0); @@ -3432,6 +3516,8 @@ PDF_begin_template(PDF *p, double width, double height) if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page), "(p_%p, %f, %f)\n", (void *) p, width, height)) { + pdf_logg_is_deprecated(p, fn, 7); + retval = pdf__begin_template(p, width, height, ""); } @@ -3444,8 +3530,8 @@ PDF_begin_template_ext(PDF *p, double width, double height, const char *optlist) static const char fn[] = "\nPDF_begin_template_ext"; int retval = -1; - if (pdf_enter_api(p, fn, pdf_state_document, "(p_%p, %f, %f, \"%T\")\n", - (void *) p, width, height, optlist, 0)) + if (pdf_enter_api(p, fn, (pdf_state) (pdf_state_document | pdf_state_page), + "(p_%p, %f, %f, \"%T\")\n", (void *) p, width, height, optlist, 0)) { retval = pdf__begin_template(p, width, height, optlist); } @@ -3612,6 +3698,8 @@ PDF_show_boxed( "(p_%p, \"%T\", %f, %f, %f, %f, \"%s\", \"%s\")\n", (void *) p, text, 0, left, bottom, width, height, hmode, feature)) { + pdf_logg_is_deprecated(p, fn, 6); + retval = pdf__show_boxed(p, text, 0, left, bottom, width, height, hmode, feature); @@ -3641,6 +3729,8 @@ PDF_show_boxed2( (void *) p, text, len, len, left, bottom, width, height, hmode, feature)) { + pdf_logg_is_deprecated(p, fn, 6); + retval = pdf__show_boxed(p, text, len, left, bottom, width, height, hmode, feature); @@ -3730,6 +3820,8 @@ PDF_xshow(PDF *p, const char *text, int len, const double *xadvancelist) if (pdf_enter_api(p, fn, pdf_state_content, "(p_%p, \"%T\", %d, %p)\n", (void *) p, text, len, len, xadvancelist)) { + pdf_logg_is_unsupported(p, fn); + pdf__xshow(p, text, len, xadvancelist); pdc_logg_exit_api(p->pdc, pdc_true, NULL); @@ -3750,7 +3842,7 @@ PDF_add_textflow(PDF *p, int textflow, const char *text, int len, static const char fn[] = "PDF_add_textflow"; int retval = -1; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, \"%T\", /*c*/%d, \"%T\")\n", (void *) p, textflow, text, len, len, optlist, 0)) { @@ -3766,7 +3858,7 @@ PDF_create_textflow(PDF *p, const char *text, int len, const char *optlist) static const char fn[] = "PDF_create_textflow"; int retval = -1; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, \"%T\", /*c*/%d, \"%T\")\n", (void *) p, text, len, len, optlist, 0)) { @@ -3781,7 +3873,7 @@ PDF_delete_textflow(PDF *p, int textflow) { static const char fn[] = "PDF_delete_textflow"; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d)\n", (void *) p, textflow)) { pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0); @@ -3821,7 +3913,7 @@ PDF_info_textflow(PDF *p, int textflow, const char *keyword) static const char fn[] = "PDF_info_textflow"; double retval = -1; - if (pdf_enter_api(p, fn, pdf_state_all, + if (pdf_enter_api(p, fn, pdf_state_documentall, "(p_%p, %d, \"%s\")\n", (void *) p, textflow, keyword)) { pdc_error(p->pdc, PDF_E_UNSUPP_TEXTFLOWS, 0, 0, 0, 0); @@ -3896,7 +3988,7 @@ PDF_end_glyph(PDF *p) static const char fn[] = "PDF_end_glyph"; if (pdf_enter_api(p, fn, - (pdf_state) (pdf_state_glyph | pdf_state_glyphmetric | + (pdf_state) (pdf_state_glyph | pdf_state_glyphmetrics | pdf_state_glyphignore), "(p_%p)\n", (void *) p)) { diff --git a/src/pdflib/pdflib/pdflib.h b/src/pdflib/pdflib/pdflib.h index 23468dd..65311cb 100644 --- a/src/pdflib/pdflib/pdflib.h +++ b/src/pdflib/pdflib/pdflib.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------------* | PDFlib - A library for generating PDF on the fly | +---------------------------------------------------------------------------+ - | Copyright (c) 1997-2006 Thomas Merz and PDFlib GmbH. All rights reserved. | + | Copyright (c) 1997-2009 Thomas Merz and PDFlib GmbH. All rights reserved. | +---------------------------------------------------------------------------+ | | | This software is subject to the PDFlib license. It is NOT in the | @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: pdflib.h,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: pdflib.h,v 1.2 2009/10/20 18:14:16 scuri Exp $ * * Public function declarations for PDFlib Lite, PDFlib, PDFlib+PDI, and PPS; * see PDFlib API reference for details. @@ -37,8 +37,8 @@ extern "C" { #define PDFLIB_MAJORVERSION 7 /* major version number */ #define PDFLIB_MINORVERSION 0 /* minor version number */ -#define PDFLIB_REVISION 2 /* revision number */ -#define PDFLIB_VERSIONSTRING "7.0.2" /* The whole bunch */ +#define PDFLIB_REVISION 4 /* revision number */ +#define PDFLIB_VERSIONSTRING "7.0.4p4" /* The whole bunch */ /* @@ -1512,6 +1512,7 @@ typedef enum #pragma deprecated(PDF_open_image) #pragma deprecated(PDF_open_image_file) #pragma deprecated(PDF_open_mem) +#pragma deprecated(PDF_open_pdi) #pragma deprecated(PDF_place_image) #pragma deprecated(PDF_place_pdi_page) #pragma deprecated(PDF_set_border_color) diff --git a/src/sim/cd_truetype.c b/src/sim/cd_truetype.c index be0e860..bd06830 100644 --- a/src/sim/cd_truetype.c +++ b/src/sim/cd_truetype.c @@ -128,8 +128,7 @@ static void cdTT_checkversion(cdTT_Text* tt_text) FT_Int major, minor, patch; FT_Library_Version(tt_text->library, &major, &minor, &patch); if (major != FREETYPE_MAJOR || - minor != FREETYPE_MINOR || - patch != FREETYPE_PATCH) + minor != FREETYPE_MINOR) { printf("CD - Canvas Draw: Warning - Different FreeType library used!\n" " Compiled = %d.%d.%d\n" -- cgit v1.2.3