summaryrefslogtreecommitdiff
path: root/src/pdf_bridge.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf_bridge.c')
-rw-r--r--src/pdf_bridge.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/pdf_bridge.c b/src/pdf_bridge.c
index 594db0f9..b1537107 100644
--- a/src/pdf_bridge.c
+++ b/src/pdf_bridge.c
@@ -321,8 +321,8 @@ pardes_pdf_grown_capacity(size_t current, size_t needed, size_t maximum)
return capacity;
}
-static pardes_pdf_document *
-pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t length, int *page_count)
+pardes_pdf_document *
+pardes_pdf_open_memory(const unsigned char *bytes, size_t length, int *page_count)
{
pardes_pdf_document *state;
fz_context *ctx;
@@ -331,7 +331,7 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng
fz_stream *stream = NULL;
int pages = 0;
- if ((path == NULL && bytes == NULL) || page_count == NULL)
+ if (bytes == NULL || page_count == NULL)
return NULL;
state = pardes_pdf_allocate_document();
@@ -356,13 +356,9 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng
fz_try(ctx)
{
fz_register_document_handlers(ctx);
- if (path != NULL) {
- doc = fz_open_document(ctx, path);
- } else {
- buffer = fz_new_buffer_from_copied_data(ctx, bytes, length);
- stream = fz_open_buffer(ctx, buffer);
- doc = fz_open_document_with_stream(ctx, "application/pdf", stream);
- }
+ buffer = fz_new_buffer_from_copied_data(ctx, bytes, length);
+ stream = fz_open_buffer(ctx, buffer);
+ doc = fz_open_document_with_stream(ctx, "application/pdf", stream);
pages = fz_count_pages(ctx, doc);
if (pages < 1)
fz_throw(ctx, FZ_ERROR_FORMAT, "PDF has no pages");
@@ -389,18 +385,6 @@ pardes_pdf_open_source(const char *path, const unsigned char *bytes, size_t leng
return state;
}
-pardes_pdf_document *
-pardes_pdf_open(const char *path, int *page_count)
-{
- return pardes_pdf_open_source(path, NULL, 0, page_count);
-}
-
-pardes_pdf_document *
-pardes_pdf_open_memory(const unsigned char *bytes, size_t length, int *page_count)
-{
- return pardes_pdf_open_source(NULL, bytes, length, page_count);
-}
-
void
pardes_pdf_close(pardes_pdf_document *document)
{