summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-08-28 17:34:23 +0200
committerTor Andersson <tor.andersson@artifex.com>2012-08-28 17:34:23 +0200
commit2597722d7aa1be523058bc8449120d32768f44b3 (patch)
tree63090b06d0479a237e32d28795d279c511eee25f /pdf
parent25552e9f2ec3f17a0ce1cbd8d7818170d132959a (diff)
downloadmupdf-2597722d7aa1be523058bc8449120d32768f44b3.tar.xz
Add fz_open_document_with_stream function.
Use a "magic" string for filetype detection: filename or mime-type.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/mupdf-internal.h2
-rw-r--r--pdf/mupdf.h2
-rw-r--r--pdf/pdf_xref.c9
-rw-r--r--pdf/pdf_xref_aux.c4
4 files changed, 8 insertions, 9 deletions
diff --git a/pdf/mupdf-internal.h b/pdf/mupdf-internal.h
index efd9e109..1aca4aa2 100644
--- a/pdf/mupdf-internal.h
+++ b/pdf/mupdf-internal.h
@@ -206,7 +206,7 @@ struct pdf_document_s
};
pdf_document *pdf_open_document_no_run(fz_context *ctx, const char *filename);
-pdf_document *pdf_open_document_no_run_with_stream(fz_stream *file);
+pdf_document *pdf_open_document_no_run_with_stream(fz_context *ctx, fz_stream *file);
void pdf_cache_object(pdf_document *doc, int num, int gen);
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index 6ebe4437..8e536777 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -167,7 +167,7 @@ pdf_document *pdf_open_document(fz_context *ctx, const char *filename);
fz_open_file_w or fz_open_fd for opening a stream, and
fz_close for closing an open stream.
*/
-pdf_document *pdf_open_document_with_stream(fz_stream *file);
+pdf_document *pdf_open_document_with_stream(fz_context *ctx, fz_stream *file);
/*
pdf_close_document: Closes and frees an opened PDF document.
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 050a6f53..37cc2081 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -1307,9 +1307,8 @@ static int pdf_meta_shim(fz_document *doc, int key, void *ptr, int size)
}
static pdf_document *
-pdf_new_document(fz_stream *file)
+pdf_new_document(fz_context *ctx, fz_stream *file)
{
- fz_context *ctx = file->ctx;
pdf_document *doc = fz_malloc_struct(ctx, pdf_document);
doc->super.close = pdf_close_document_shim;
@@ -1332,9 +1331,9 @@ pdf_new_document(fz_stream *file)
}
pdf_document *
-pdf_open_document_no_run_with_stream(fz_stream *file)
+pdf_open_document_no_run_with_stream(fz_context *ctx, fz_stream *file)
{
- pdf_document *doc = pdf_new_document(file);
+ pdf_document *doc = pdf_new_document(ctx, file);
pdf_init_document(doc);
return doc;
}
@@ -1350,7 +1349,7 @@ pdf_open_document_no_run(fz_context *ctx, const char *filename)
fz_try(ctx)
{
file = fz_open_file(ctx, filename);
- doc = pdf_new_document(file);
+ doc = pdf_new_document(ctx, file);
pdf_init_document(doc);
}
fz_always(ctx)
diff --git a/pdf/pdf_xref_aux.c b/pdf/pdf_xref_aux.c
index 907e6f17..bf2fe19b 100644
--- a/pdf/pdf_xref_aux.c
+++ b/pdf/pdf_xref_aux.c
@@ -15,9 +15,9 @@ static void pdf_run_page_shim(fz_document *doc, fz_page *page, fz_device *dev, f
}
pdf_document *
-pdf_open_document_with_stream(fz_stream *file)
+pdf_open_document_with_stream(fz_context *ctx, fz_stream *file)
{
- pdf_document *doc = pdf_open_document_no_run_with_stream(file);
+ pdf_document *doc = pdf_open_document_no_run_with_stream(ctx, file);
doc->super.run_page = pdf_run_page_shim;
return doc;
}