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[PDC_GEN_BUFSIZE]; pdf_info *info; pdc_id info_id; const char *product = "PDFlib Lite"; const char *security = ""; (void) logg3; if (!p->pdc->smokerun) pdc_logg_cond(p->pdc, 1, trc_api, "[Full product name: \"%s\"]\n", product); info_id = pdc_begin_obj(p->out, PDC_NEW_ID); /* Info object */ pdc_begin_dict(p->out); /* * Although it would be syntactically correct, we must not remove * the space characters after the dictionary keys since this * would break the PDF properties feature in Windows Explorer. */ if (p->userinfo) { for (info = p->userinfo; info != NULL; info = info->next) { pdf_put_pdfname(p, info->key); pdc_puts(p->out, " "); if (strcmp(info->key, "Trapped")) pdf_put_hypertext(p, info->value); else pdf_put_pdfname(p, info->value); pdc_puts(p->out, "\n"); } } pdc_get_timestr(time_str, pdc_false); /* creation date and time */ pdc_puts(p->out, "/CreationDate "); pdf_put_hypertext(p, time_str); pdc_puts(p->out, "\n"); /* modification date and time */ if (moddate) { pdc_puts(p->out, "/ModDate "); pdf_put_hypertext(p, time_str); pdc_puts(p->out, "\n"); } /* * If you change the /Producer entry your license to use * PDFlib will be void! */ if (p->pdc->binding) pdc_sprintf(p->pdc, pdc_false, producer, "%s %s%s (%s/%s)", product, PDFLIB_VERSIONSTRING, security, p->pdc->binding, PDF_PLATFORM); else pdc_sprintf(p->pdc, pdc_false, producer, "%s %s%s (%s)", product, PDFLIB_VERSIONSTRING, security, PDF_PLATFORM); pdc_puts(p->out, "/Producer "); pdf_put_hypertext(p, producer); pdc_puts(p->out, "\n"); pdc_end_dict(p->out); pdc_end_obj(p->out); /* Info object */ return info_id; }
static pdc_id pdf_write_action(PDF *p, pdf_action *action, pdc_id next_id) { pdc_id ret_id = PDC_BAD_ID; int i, flags = 0; ret_id = pdc_begin_obj(p->out, PDC_NEW_ID); /* Action object */ pdc_begin_dict(p->out); /* Action dict */ pdc_puts(p->out, "/Type/Action\n"); pdc_printf(p->out, "/S/%s\n", pdc_get_keyword(action->atype, pdf_action_pdfkeylist)); /* next action */ if (next_id != PDC_BAD_ID) pdc_objref(p->out, "/Next", next_id); else action->obj_id = ret_id; /* destination */ switch (action->atype) { case pdf_goto: case pdf_gotor: pdc_puts(p->out, "/D"); pdf_write_destination(p, action->dest); default: break; } /* file specification */ switch (action->atype) { case pdf_gotor: case pdf_launch: if (action->newwindow != pdc_undef) pdc_printf(p->out, "/NewWindow %s\n", PDC_BOOLSTR(action->newwindow)); case pdf_importdata: if (action->parameters || action->operation || action->defaultdir) { /* Windows-specific launch parameters */ pdc_puts(p->out, "/Win"); pdc_begin_dict(p->out); /* Win dict */ 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_puts(p->out, "/P"); pdf_put_hypertext(p, action->parameters); pdc_puts(p->out, "\n"); pdc_free(p->pdc, action->parameters); action->parameters = NULL; } if (action->operation) { pdc_puts(p->out, "/O"); pdf_put_hypertext(p, action->operation); pdc_puts(p->out, "\n"); action->operation = NULL; } if (action->defaultdir) { pdc_puts(p->out, "/D"); pdf_put_hypertext(p, action->defaultdir); pdc_puts(p->out, "\n"); pdc_free(p->pdc, action->defaultdir); action->defaultdir = NULL; } pdc_end_dict(p->out); /* Win dict */ } else { 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, 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 */ } default: break; } /* URI */ switch (action->atype) { case pdf_uri: pdc_puts(p->out, "/URI"); pdf_put_hypertext(p, action->filename); pdc_puts(p->out, "\n"); /* IsMap */ if (action->ismap == pdc_true) pdc_puts(p->out, "/IsMap true\n"); default: break; } /* Named */ switch (action->atype) { case pdf_named: pdc_puts(p->out, "/N"); pdf_put_pdfname(p, action->menuname); pdc_puts(p->out, "\n"); default: break; } /* name list */ switch (action->atype) { case pdf_hide: if (action->hide == pdc_false) pdc_puts(p->out, "/H false\n"); case pdf_submitform: case pdf_resetform: if (action->nsnames) { pdc_printf(p->out, "/%s", (action->atype == pdf_hide) ? "T" : "Fields"); pdc_begin_array(p->out); for (i = 0; i < action->nsnames; i++) { pdf_put_hypertext(p, action->namelist[i]); if (i < action->nsnames - 1) pdc_puts(p->out, "\n"); else pdc_end_array(p->out); } } default: break; } /* URL */ switch (action->atype) { case pdf_submitform: pdc_puts(p->out, "/F"); pdc_begin_dict(p->out); /* F dict */ pdc_puts(p->out, "/FS/URL\n"); pdc_printf(p->out, "/F"); pdf_put_hypertext(p, action->filename); pdc_puts(p->out, "\n"); pdc_end_dict(p->out); /* F dict */ default: break; } /* Trans */ switch (action->atype) { case pdf_trans: pdc_puts(p->out, "/Trans"); pdc_begin_dict(p->out); /* Trans dict */ pdc_puts(p->out, "/Type/Trans\n"); if (action->transition != trans_replace) pdc_printf(p->out, "/S/%s", pdc_get_keyword(action->transition, pdf_transition_pdfkeylist)); if (action->duration > 0) pdc_printf(p->out, "/D %f\n", action->duration); pdc_end_dict(p->out); /* Trans dict */ default: break; } /* Flags */ switch (action->atype) { case pdf_submitform: flags = (int) action->exportmethod; if (action->submitemptyfields) flags |= (1<<1); if (action->canonicaldate) flags |= (1<<9); case pdf_resetform: if (action->exclude) flags |= (1<<0); if (flags) pdc_printf(p->out, "/Flags %d\n", flags); default: break; } /* Movie */ pdc_end_dict(p->out); /* Action dict */ pdc_end_obj(p->out); /* Action object */ return ret_id; }
void pdf__end_font(PDF *p) { int ig; pdf_font *font; pdf_t3font *t3font; PDF_SET_STATE(p, pdf_state_document); font = &p->fonts[p->t3slot]; t3font = font->t3font; /* error message prefix */ pdc_push_errmsg(p->pdc, PDF_E_T3_FONT_PREFIX, font->apiname, 0, 0, 0); if (t3font->pass == 0) { pdf_t3glyph glyph0 = t3font->glyphs[0]; /* search for .notdef glyph */ if (pdc_strcmp(glyph0.name, (char *) pdc_get_notdef_glyphname())) { for (ig = 0; ig < t3font->next_glyph; ig++) { if (!pdc_strcmp(t3font->glyphs[ig].name, (char *) pdc_get_notdef_glyphname())) break; } if (ig < t3font->next_glyph) { pdc_logg_cond(p->pdc, 2, trc_font, "\tGlyph id %d: \"%s\" will be exchanged " "with glyph id 0: \"%s\"\n", ig, t3font->glyphs[ig].name, glyph0.name); t3font->glyphs[0] = t3font->glyphs[ig]; t3font->glyphs[ig] = glyph0; } else { pdc_warning(p->pdc, PDF_E_T3_MISSNOTDEF, 0, 0, 0, 0); } } } if (t3font->pass != 1) { t3font->charprocs_id = pdc_alloc_id(p->out); pdc_begin_obj(p->out, t3font->charprocs_id); /* CharProcs dict */ pdc_begin_dict(p->out); for (ig = 0; ig < t3font->next_glyph; ig++) { pdf_t3glyph *glyph = &t3font->glyphs[ig]; if (glyph->charproc_id != PDC_BAD_ID) { pdf_put_pdfname(p, glyph->name); pdc_objref(p->out, "", glyph->charproc_id); } } pdc_end_dict(p->out); pdc_end_obj(p->out); /* CharProcs dict */ pdc_begin_obj(p->out, t3font->res_id); pdc_begin_dict(p->out); /* Resource dict */ pdf_write_page_fonts(p); /* Font resources */ pdf_write_page_colorspaces(p); /* Color space resources */ pdf_write_page_pattern(p); /* Pattern resources */ pdf_write_xobjects(p); /* XObject resources */ pdc_end_dict(p->out); /* Resource dict */ pdc_end_obj(p->out); /* Resource object */ pdf_pg_resume(p, -1); if (p->flush & pdc_flush_content) pdc_flush_stream(p->out); /* see pdf__begin_glyph */ pdf_init_tstate(p); pdf_init_gstate(p); pdf_init_cstate(p); } pdc_logg_cond(p->pdc, 1, trc_font, "\tEnd of Type3 font \"%s\"\n", font->apiname); pdc_pop_errmsg(p->pdc); if (!p->pdc->smokerun) pdc_logg_cond(p->pdc, 1, trc_api, "[End font %d]\n", p->t3slot); p->t3slot = -1; }