static void _pdf_doc_clear(struct _pdf_doc *self) { int i, c = mume_docdoc_count_pages(self); if (self->pages) { for (i = 0; i < c; ++i) { if (self->pages[i]) pdf_free_page(self->pages[i]); } free(self->pages); } if (self->disps) { for (i = 0; i < c; ++i) { if (self->disps[i]) fz_free_display_list(self->disps[i]); } free(self->disps); } if (self->glyph_cache) fz_free_glyph_cache(self->glyph_cache); if (self->xref) pdf_free_xref(self->xref); free(self->media_boxes); free(self->page_rotates); _pdf_doc_reset(self); }
void pdfapp_close(pdfapp_t *app) { if (app->cache) fz_free_glyph_cache(app->cache); app->cache = NULL; if (app->image) fz_drop_pixmap(app->image); app->image = NULL; if (app->outline) pdf_free_outline(app->outline); app->outline = NULL; if (app->xref) { if (app->xref->store) pdf_free_store(app->xref->store); app->xref->store = NULL; pdf_free_xref(app->xref); app->xref = NULL; } if (app->xps) { xps_free_context(app->xps); app->xps = NULL; } fz_flush_warnings(); }
Pdf::~Pdf() { pdf_free_xref(xref); --references; if (references == 0) { fz_free_glyph_cache(ctx, cache); cache = 0; fz_free_context(ctx); ctx = 0; } }
void pdfapp_close(pdfapp_t *app) { #if 0 if (app->page) pdf_droppage(app->page); app->page = nil; if (app->image) fz_droppixmap(app->image); app->image = nil; /* if (app->outline) pdf_dropoutline(app->outline); app->outline = nil;*/ if (app->xref->store) pdf_dropstore(app->xref->store); app->xref->store = nil; pdf_closexref(app->xref); app->xref = nil; #else if (app->cache) fz_free_glyph_cache(app->cache); app->cache = NULL; if (app->image) fz_drop_pixmap(app->image); app->image = NULL; if (app->outline) pdf_free_outline(app->outline); app->outline = NULL; if (app->xref) { if (app->xref->store) pdf_free_store(app->xref->store); app->xref->store = NULL; pdf_free_xref(app->xref); app->xref = NULL; } fz_flush_warnings(); #endif }
int main(int argc, char **argv) { int grayscale = 0; int accelerate = 1; xps_context *ctx; int code; int c; while ((c = fz_getopt(argc, argv, "o:p:r:Aadglmtx5")) != -1) { switch (c) { case 'o': output = fz_optarg; break; case 'r': resolution = atof(fz_optarg); break; case 'A': accelerate = 0; break; case 'a': savealpha = 1; break; case 'l': showoutline++; break; case 'm': showtime++; break; case 't': showtext++; break; case 'x': showxml++; break; case '5': showmd5++; break; case 'g': grayscale++; break; case 'd': uselist = 0; break; default: usage(); break; } } if (fz_optind == argc) usage(); if (!showtext && !showxml && !showtime && !showmd5 && !showoutline && !output) { printf("nothing to do\n"); exit(0); } if (accelerate) fz_accelerate(); glyphcache = fz_new_glyph_cache(); colorspace = fz_device_rgb; if (grayscale) colorspace = fz_device_gray; if (output && strstr(output, ".pgm")) colorspace = fz_device_gray; if (output && strstr(output, ".ppm")) colorspace = fz_device_rgb; timing.count = 0; timing.total = 0; timing.min = 1 << 30; timing.max = 0; timing.minpage = 0; timing.maxpage = 0; if (showxml) printf("<?xml version=\"1.0\"?>\n"); while (fz_optind < argc) { filename = argv[fz_optind++]; code = xps_open_file(&ctx, filename); if (code) die(fz_rethrow(code, "cannot open document: %s", filename)); if (showxml) printf("<document name=\"%s\">\n", filename); if (showoutline) drawoutline(ctx); if (showtext || showxml || showtime || showmd5 || output) { if (fz_optind == argc || !isrange(argv[fz_optind])) drawrange(ctx, "1-"); if (fz_optind < argc && isrange(argv[fz_optind])) drawrange(ctx, argv[fz_optind++]); } if (showxml) printf("</document>\n"); xps_free_context(ctx); } if (showtime) { printf("total %dms / %d pages for an average of %dms\n", timing.total, timing.count, timing.total / timing.count); printf("fastest page %d: %dms\n", timing.minpage, timing.min); printf("slowest page %d: %dms\n", timing.maxpage, timing.max); } fz_free_glyph_cache(glyphcache); return 0; }