Exemplo n.º 1
0
Arquivo: pdfdraw.c Projeto: Limsik/e17
int main(int argc, char **argv)
{
	fz_error error;
	char *password = "";
	int c;
	enum { NO_FILE_OPENED, NO_PAGES_DRAWN, DREW_PAGES } state;

	while ((c = fz_getopt(argc, argv, "b:d:o:r:txm")) != -1)
	{
		switch (c)
		{
		case 'b': drawbands = atoi(fz_optarg); break;
		case 'd': password = fz_optarg; break;
		case 'o': drawpattern = fz_optarg; break;
		case 'r': drawzoom = atof(fz_optarg) / 72.0; break;
		case 't': drawmode = DRAWTXT; break;
		case 'x': drawmode = DRAWXML; break;
		case 'm': benchmark = 1; break;
		default:
			drawusage();
			break;
		}
	}

	if (fz_optind == argc)
		drawusage();

	setcleanup(local_cleanup);

	state = NO_FILE_OPENED;
	while (fz_optind < argc)
	{
		if (strstr(argv[fz_optind], ".pdf") || strstr(argv[fz_optind], ".PDF"))
		{
			if (state == NO_PAGES_DRAWN)
				drawpages("1-");

			closexref();

			error = fz_newrenderer(&drawgc, pdf_devicergb, 0, 1024 * 512);
			if (error)
				die(error);

			openxref(argv[fz_optind], password, 0);
			state = NO_PAGES_DRAWN;
		}
		else
		{
			drawpages(argv[fz_optind]);
			state = DREW_PAGES;
		}
		fz_optind++;
	}

	if (state == NO_PAGES_DRAWN)
		drawpages("1-");

	closexref();
}
int main(int argc, char **argv)
{
    char *password = "";
    int c, o;

    while ((c = fz_getopt(argc, argv, "d:")) != -1)
    {
	switch (c)
	{
	    case 'd': password = fz_optarg; break;
	    default:
		      showusage();
		      break;
	}
    }

    if (fz_optind == argc)
	showusage();

    openxref(argv[fz_optind++], password, 0);

    if (fz_optind == argc)
        for (o = 0; o < xref->len; o++)
            showobject(o, 0);
    else
        while (fz_optind < argc)
        {
            showobject(atoi(argv[fz_optind]), 0);
            fz_optind++;
        }

    closexref();
}
Exemplo n.º 3
0
/*========================================
 * lldb_close -- Close any database contained.
 *  Free LLDATABASE structure.
 *  Safe to call even if not opened
 *======================================*/
void lldb_close (LLDATABASE *plldb)
{
    LLDATABASE lldb=0;
    ASSERT(plldb);
    lldb = *plldb;

    if (!lldb) return;

    if (tagtable)
        destroy_table(tagtable);
    tagtable = 0;
    /* TODO: reverse the rest of init_lifelines_postdb -- Perry, 2002.06.05 */
    if (placabbvs) {
        destroy_table(placabbvs);
        placabbvs = NULL;
    }
    free_caches();
    check_node_leaks();
    check_record_leaks();
    closexref();
    ASSERT(BTR == lldb->btree);
    if (lldb->btree) {
        closebtree(lldb->btree);
        lldb->btree = 0;
        BTR = 0;
    }
    dbnotify_close();
    transl_free_predefined_xlats(); /* clear any active legacy translation tables */
    strfree(&readpath_file);
    strfree(&readpath);
    stdfree(lldb);
    *plldb = 0;
}
Exemplo n.º 4
0
Arquivo: pdftool.c Projeto: Limsik/e17
void die(fz_error error)
{
	fz_catch(error, "aborting");
	if (cleanup)
		cleanup();
	closexref();
	exit(1);
}
Exemplo n.º 5
0
Arquivo: pdfshow.c Projeto: Limsik/e17
int main(int argc, char **argv)
{
	char *password = "";
	int c;

	while ((c = fz_getopt(argc, argv, "d:bx")) != -1)
	{
		switch (c)
		{
		case 'd': password = fz_optarg; break;
		case 'b': showbinary ++; break;
		case 'x': showdecode ++; break;
		default:
			showusage();
			break;
		}
	}

	if (fz_optind == argc)
		showusage();

	openxref(argv[fz_optind++], password, 0);

	if (fz_optind == argc)
		showtrailer();

	while (fz_optind < argc)
	{
		if (!strcmp(argv[fz_optind], "trailer"))
			showtrailer();
		else if (!strcmp(argv[fz_optind], "xref"))
			showxref();
		else
			showobject(atoi(argv[fz_optind]), 0);
		fz_optind++;
	}

	closexref();
}
Exemplo n.º 6
0
int pdfinfo_main(int argc, char **argv)
{
	enum { NO_FILE_OPENED, NO_INFO_GATHERED, INFO_SHOWN } state;
	char *filename = "";
	char *password = "";
	int show = ALL;
	int c;

	while ((c = fz_getopt(argc, argv, "mfispxd:")) != -1)
	{
		switch (c)
		{
		case 'm': if (show == ALL) show = DIMENSIONS; else show |= DIMENSIONS; break;
		case 'f': if (show == ALL) show = FONTS; else show |= FONTS; break;
		case 'i': if (show == ALL) show = IMAGES; else show |= IMAGES; break;
		case 's': if (show == ALL) show = SHADINGS; else show |= SHADINGS; break;
		case 'p': if (show == ALL) show = PATTERNS; else show |= PATTERNS; break;
		case 'x': if (show == ALL) show = XOBJS; else show |= XOBJS; break;
		case 'd': password = fz_optarg; break;
		default:
			infousage();
			break;
		}
	}

	if (fz_optind == argc)
		infousage();

	ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
	if (!ctx)
	{
		fprintf(stderr, "cannot initialise context\n");
		exit(1);
	}

	state = NO_FILE_OPENED;
	while (fz_optind < argc)
	{
		if (state == NO_FILE_OPENED || !arg_is_page_range(argv[fz_optind]))
		{
			if (state == NO_INFO_GATHERED)
			{
				showinfo(filename, show, "1-");
			}

			closexref();

			filename = argv[fz_optind];
			printf("%s:\n", filename);
			doc = pdf_open_document_no_run(ctx, filename);
			if (pdf_needs_password(doc))
				if (!pdf_authenticate_password(doc, password))
					fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename);
			pagecount = pdf_count_pages(doc);

			showglobalinfo();
			state = NO_INFO_GATHERED;
		}
		else
		{
			showinfo(filename, show, argv[fz_optind]);
			state = INFO_SHOWN;
		}

		fz_optind++;
	}

	if (state == NO_INFO_GATHERED)
		showinfo(filename, show, "1-");

	closexref();
	fz_free_context(ctx);
	return 0;
}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
	enum { NO_FILE_OPENED, NO_INFO_GATHERED, INFO_SHOWN } state;
	char *filename = "";
	char *password = "";
	int show = ALL;
	int c;

	while ((c = fz_getopt(argc, argv, "mfispxd:")) != -1)
	{
		switch (c)
		{
		case 'm': if (show == ALL) show = DIMENSIONS; else show |= DIMENSIONS; break;
		case 'f': if (show == ALL) show = FONTS; else show |= FONTS; break;
		case 'i': if (show == ALL) show = IMAGES; else show |= IMAGES; break;
		case 's': if (show == ALL) show = SHADINGS; else show |= SHADINGS; break;
		case 'p': if (show == ALL) show = PATTERNS; else show |= PATTERNS; break;
		case 'x': if (show == ALL) show = XOBJS; else show |= XOBJS; break;
		case 'd': password = fz_optarg; break;
		default:
			infousage();
			break;
		}
	}

	if (fz_optind == argc)
		infousage();

	setcleanup(local_cleanup);

	state = NO_FILE_OPENED;
	while (fz_optind < argc)
	{
		if (strstr(argv[fz_optind], ".pdf") || strstr(argv[fz_optind], ".PDF"))
		{
			if (state == NO_INFO_GATHERED)
			{
				printglobalinfo();
				showinfo(filename, show, "1-");
				closexref();
			}

			closexref();
			filename = argv[fz_optind];
			printf("%s:\n", filename);
			openxref(filename, password, 0);
			gatherglobalinfo();
			state = NO_INFO_GATHERED;
		}
		else
		{
			if (state == NO_INFO_GATHERED)
				printglobalinfo();
			showinfo(filename, show, argv[fz_optind]);
			state = INFO_SHOWN;
		}

		fz_optind++;
	}

	if (state == NO_INFO_GATHERED)
	{
		printglobalinfo();
		showinfo(filename, show, "1-");
	}

	closexref();
}