fz_stream * pdf_open_stream_with_offset(fz_context *ctx, pdf_document *doc, int num, pdf_obj *dict, fz_off_t stm_ofs) { if (stm_ofs == 0) fz_throw(ctx, FZ_ERROR_GENERIC, "object is not a stream"); return pdf_open_filter(ctx, doc, doc->file, dict, num, stm_ofs, NULL); }
fz_stream * pdf_open_stream_with_offset(pdf_document *xref, int num, int gen, pdf_obj *dict, int stm_ofs) { if (stm_ofs == 0) fz_throw(xref->ctx, "object is not a stream"); return pdf_open_filter(xref->file, xref, dict, num, gen, stm_ofs, NULL); }
fz_error pdf_open_stream_at(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs) { if (stm_ofs) { *stmp = pdf_open_filter(xref->file, xref, dict, num, gen); fz_seek(xref->file, stm_ofs, 0); return fz_okay; } return fz_throw("object is not a stream"); }
static fz_stream * pdf_open_image_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen, fz_compression_params *params) { pdf_xref_entry *x; if (num <= 0 || num >= pdf_xref_len(ctx, doc)) fz_throw(ctx, FZ_ERROR_GENERIC, "object id out of range (%d %d R)", num, gen); x = pdf_cache_object(ctx, doc, num, gen); if (x->stm_ofs == 0 && x->stm_buf == NULL) fz_throw(ctx, FZ_ERROR_GENERIC, "object is not a stream"); return pdf_open_filter(ctx, doc, doc->file, x->obj, orig_num, orig_gen, x->stm_ofs, params); }
fz_stream * pdf_open_image_stream(pdf_document *xref, int num, int gen, int orig_num, int orig_gen, pdf_image_params *params) { pdf_xref_entry *x; if (num < 0 || num >= xref->len) fz_throw(xref->ctx, "object id out of range (%d %d R)", num, gen); x = xref->table + num; pdf_cache_object(xref, num, gen); /* RJW: "cannot load stream object (%d %d R)", num, gen */ if (x->stm_ofs == 0 && x->stm_buf == NULL) fz_throw(xref->ctx, "object is not a stream"); return pdf_open_filter(xref->file, xref, x->obj, orig_num, orig_gen, x->stm_ofs, params); }
/* * Open a stream for reading uncompressed data. * Put the opened file in xref->stream. * Using xref->file while a stream is open is a Bad idea. */ fz_error pdf_open_stream(fz_stream **stmp, pdf_xref *xref, int num, int gen) { pdf_xref_entry *x; fz_error error; if (num < 0 || num >= xref->len) return fz_throw("object id out of range (%d %d R)", num, gen); x = xref->table + num; error = pdf_cache_object(xref, num, gen); if (error) return fz_rethrow(error, "cannot load stream object (%d %d R)", num, gen); if (x->stm_ofs) { *stmp = pdf_open_filter(xref->file, xref, x->obj, num, gen); fz_seek(xref->file, x->stm_ofs, 0); return fz_okay; } return fz_throw("object is not a stream"); }