void pdf_error(PDF *p, int type, const char *fmt, ...) { static const char fn[] = "pdf_error"; char msg[2048]; va_list ap; va_start(ap, fmt); vsprintf(msg, fmt, ap); PDF_TRACE(("\n[%s\t(pdf(%p), %d (%s), \"%s\");]\n", fn, (void *) p, type, pdf_error_names[type], msg)); /* * We catch non-fatals here since user-supplied error handlers * don't know about the debug level. */ if (PDF_GET_STATE(p) != pdf_state_error /* avoid recursive errors */ && (type != PDF_NonfatalError || ((PDF *)p)->debug['w'])) { PDF_PUSH_STATE(p, fn, pdf_state_error); (p->errorhandler)(p, type, msg); /* If the error handler returns the error was non-fatal */ PDF_POP_STATE(p, fn); } PDF_TRACE(("[error handler returned]\n")); va_end(ap); }
static void pdf_end_path(PDF *p) { pdf_ppt *ppt = p->curr_ppt; PDF_POP_STATE(p, "pdf_end_path"); ppt->gstate[ppt->sl].x = 0; ppt->gstate[ppt->sl].y = 0; }
/* Finish the pattern definition. */ PDFLIB_API void PDFLIB_CALL PDF_end_pattern(PDF *p) { static const char fn[] = "PDF_end_pattern"; long length; PDF_TRACE(("%s\t(pdf[%p]);\n", fn, (void *) p)); if (PDF_SANITY_CHECK_FAILED(p)) return; PDF_CHECK_SCOPE(p, fn, pdf_state_pattern); /* check whether PDF_save() and PDF_restore() calls are balanced */ if (p->sl > 0) pdf_error(p, PDF_RuntimeError, "Unmatched save level at end of pattern"); pdf_end_text(p); p->contents = c_none; if (p->compresslevel) pdf_compress_end(p); length = pdf_tell(p) - p->start_contents_pos; pdf_end_stream(p); pdf_end_obj(p); /* pattern */ pdf_begin_obj(p, p->contents_length_id); /* Length object */ pdf_printf(p, "%ld\n", length); pdf_end_obj(p); pdf_begin_obj(p, p->res_id); /* Resource object */ pdf_begin_dict(p); /* Resource dict */ pdf_write_page_procsets(p); /* ProcSet resources */ 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 */ pdf_end_dict(p); /* resource dict */ pdf_end_obj(p); /* resource object */ PDF_POP_STATE(p, fn); if (p->flush & PDF_FLUSH_PAGE) pdf_flush_stream(p); }