diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-16 08:06:24 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-16 08:06:24 +0000 |
commit | 9ac2094ac58a63fed6ee71246905a162831675ca (patch) | |
tree | 58f7f1c34d864dd8570dc732ef8837f9f6b1c09e /apps | |
parent | 22c78bd39b2d8316af4c7d20d7f322fa7d534102 (diff) | |
download | mupdf-9ac2094ac58a63fed6ee71246905a162831675ca.tar.xz |
Clarify function names for opening a PDF file.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfapp.c | 2 | ||||
-rw-r--r-- | apps/pdfclean.c | 8 | ||||
-rw-r--r-- | apps/pdfdraw.c | 4 | ||||
-rw-r--r-- | apps/pdfinfo.c | 6 | ||||
-rw-r--r-- | apps/pdfshow.c | 17 |
5 files changed, 22 insertions, 15 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 95885e2a..32de4265 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -103,7 +103,7 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd) */ file = fz_openfile(fd); - error = pdf_newxref(&app->xref, file, NULL); + error = pdf_openxrefwithstream(&app->xref, file, NULL); if (error) pdfapp_error(app, fz_rethrow(error, "cannot open document '%s'", filename)); fz_dropstream(file); diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 0ecbb98e..6824707d 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -225,9 +225,15 @@ static void removeduplicateobjs(void) static void retainpages(int argc, char **argv) { + fz_error error; fz_obj *root, *pages, *kids; int count; + /* Load the old page tree */ + error = pdf_loadpagetree(xref); + if (error) + die(fz_rethrow(error, "cannot load page tree")); + /* Snatch pages entry from root dict */ root = fz_dictgets(xref->trailer, "Root"); pages = fz_keepobj(fz_dictgets(root, "Pages")); @@ -557,7 +563,7 @@ int main(int argc, char **argv) die(fz_throw("cannot open output file '%s'", outfile)); fprintf(out, "%%PDF-%d.%d\n", xref->version / 10, xref->version % 10); - fprintf(out, "%%\342\343\317\323\n\n"); + fprintf(out, "%%\316\274\341\277\246\n\n"); uselist = malloc(sizeof (char) * (xref->len + 1)); ofslist = malloc(sizeof (int) * (xref->len + 1)); diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 3c645d86..f7314ff5 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -222,6 +222,10 @@ int main(int argc, char **argv) if (error) die(fz_rethrow(error, "cannot open document: %s", filename)); + error = pdf_loadpagetree(xref); + if (error) + die(fz_rethrow(error, "cannot load page tree: %s", filename)); + if (showxml) printf("<document name=\"%s\">\n", filename); diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c index af29c0d2..0eae9137 100644 --- a/apps/pdfinfo.c +++ b/apps/pdfinfo.c @@ -980,12 +980,18 @@ int main(int argc, char **argv) } closexref(); + filename = argv[fz_optind]; printf("%s:\n", filename); error = pdf_openxref(&xref, filename, password); if (error) die(fz_rethrow(error, "cannot open input file '%s'", filename)); + + error = pdf_loadpagetree(xref); + if (error) + die(fz_rethrow(error, "cannot load page tree: %s", filename)); pagecount = pdf_getpagecount(xref); + showglobalinfo(); state = NO_INFO_GATHERED; } diff --git a/apps/pdfshow.c b/apps/pdfshow.c index b15fae1b..6d4d2672 100644 --- a/apps/pdfshow.c +++ b/apps/pdfshow.c @@ -160,19 +160,10 @@ int main(int argc, char **argv) if (fz_optind == argc) usage(); - /* Use newxref directly because we don't care about the page tree */ - { - filename = argv[fz_optind++]; - fd = open(filename, O_BINARY | O_RDONLY); - if (fd < 0) - return fz_throw("cannot open file '%s': %s", filename, strerror(errno)); - - file = fz_openfile(fd); - error = pdf_newxref(&xref, file, password); - if (error) - die(fz_rethrow(error, "cannot load document '%s'", filename)); - fz_dropstream(file); - } + filename = argv[fz_optind++]; + error = pdf_openxref(&xref, filename, password); + if (error) + die(fz_rethrow(error, "cannot open document: %s", filename)); if (fz_optind == argc) showtrailer(); |