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();
}
Exemple #2
0
int pdfextract_main(int argc, char **argv)
{
    char *infile;
    char *password = "";
    int c, o;

    while ((c = fz_getopt(argc, argv, "p:r")) != -1)
    {
        switch (c)
        {
        case 'p':
            password = fz_optarg;
            break;
        case 'r':
            dorgb++;
            break;
        default:
            usage();
            break;
        }
    }

    if (fz_optind == argc)
        usage();

    infile = argv[fz_optind++];

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

    doc = pdf_open_document(ctx, infile);
    if (pdf_needs_password(ctx, doc))
        if (!pdf_authenticate_password(ctx, doc, password))
            fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", infile);

    if (fz_optind == argc)
    {
        int len = pdf_count_objects(ctx, doc);
        for (o = 1; o < len; o++)
            showobject(o);
    }
    else
    {
        while (fz_optind < argc)
        {
            showobject(atoi(argv[fz_optind]));
            fz_optind++;
        }
    }

    pdf_close_document(ctx, doc);
    fz_flush_warnings(ctx);
    fz_drop_context(ctx);
    return 0;
}
Exemple #3
0
int main(int argc, char **argv)
{
	fz_error error;
	char *infile;
	char *password = "";
	int c, o;

	while ((c = fz_getopt(argc, argv, "p:r")) != -1)
	{
		switch (c)
		{
		case 'p': password = fz_optarg; break;
		case 'r': dorgb++; break;
		default: usage(); break;
		}
	}

	if (fz_optind == argc)
		usage();

	infile = argv[fz_optind++];

	ctx = fz_context_init(&fz_alloc_default);
	if (ctx == NULL)
		die(fz_error_note(ctx, 1, "failed to initialise context"));

	error = pdf_open_xref(ctx, &xref, infile, password);
	if (error)
		die(fz_error_note(ctx, error, "cannot open input file '%s'", infile));

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

	pdf_free_xref(xref);

	fz_flush_warnings(ctx);
	fz_context_fin(ctx);

	return 0;
}
Exemple #4
0
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();
}
Exemple #5
0
void
showmain(int argc, char **argv)
{
	int c;

	while ((c = getopt(argc, argv, "bd")) != -1)
	{
		switch (c)
		{
		case 'b': showbinary ++; break;
		case 'd': showdecode ++; break;
		default:
			  showusage();
			  break;
		}
	}

	if (optind == argc)
		showusage();

	opensrc(argv[optind++], "", 0);

	if (optind == argc)
		showtrailer();

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