コード例 #1
0
ファイル: pdfdraw.c プロジェクト: 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();
}
コード例 #2
0
ファイル: SamplePdfTool.cpp プロジェクト: iroot/sopdf
void
drawmain(int argc, char **argv)
{
	fz_error *error;
	char *password = "";
	int c;
	enum { NO_FILE_OPENED, NO_PAGES_DRAWN, DREW_PAGES } state;

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

	if (optind == argc)
		drawusage();

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

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

			opensrc(argv[optind], password, 1);
			state = NO_PAGES_DRAWN;
		}
		else
		{
			drawpages(argv[optind]);
			state = DREW_PAGES;
		}
		optind++;
	}

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

	closesrc();

	fz_droprenderer(drawgc);
}
コード例 #3
0
void
drawmain(int argc, char **argv)
{
    fz_error *error;
    char *password = "";
    int c;

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

    if (optind == argc)
        drawusage();

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

    while (optind < argc)
    {
        if (strstr(argv[optind], ".pdf"))
            opensrc(argv[optind], password, 1);
        else
            drawpages(argv[optind]);
        optind++;
    }

    closesrc();

    fz_droprenderer(drawgc);
}