static fz_document * svg_open_document_with_stream(fz_context *ctx, fz_stream *file) { fz_buffer *buf; fz_document *doc; buf = fz_read_all(ctx, file, 0); fz_try(ctx) doc = svg_open_document_with_buffer(ctx, buf); fz_always(ctx) fz_drop_buffer(ctx, buf); fz_catch(ctx) fz_rethrow(ctx); return doc; }
fz_display_list * fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf, float *w, float *h) { fz_document *doc; fz_display_list *list; doc = svg_open_document_with_buffer(ctx, buf); fz_try(ctx) { list = fz_new_display_list_from_page_number(ctx, doc, 0); *w = ((svg_document*)doc)->width; *h = ((svg_document*)doc)->height; } fz_always(ctx) fz_drop_document(ctx, doc); fz_catch(ctx) fz_rethrow(ctx); return list; }