コード例 #1
0
ファイル: gl-main.c プロジェクト: ArtifexSoftware/mupdf
static void do_info(void)
{
    char buf[256];

    int x = canvas_x + 4 * ui.lineheight;
    int y = canvas_y + 4 * ui.lineheight;
    int w = canvas_w - 8 * ui.lineheight;
    int h = 9 * ui.lineheight;

    glBegin(GL_TRIANGLE_STRIP);
    {
        glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
        glVertex2f(x, y);
        glVertex2f(x, y + h);
        glVertex2f(x + w, y);
        glVertex2f(x + w, y + h);
    }
    glEnd();

    x += ui.lineheight;
    y += ui.lineheight + ui.baseline;

    glColor4f(0, 0, 0, 1);
    if (fz_lookup_metadata(ctx, doc, FZ_META_INFO_TITLE, buf, sizeof buf) > 0)
        y = do_info_line(x, y, "Title", buf);
    if (fz_lookup_metadata(ctx, doc, FZ_META_INFO_AUTHOR, buf, sizeof buf) > 0)
        y = do_info_line(x, y, "Author", buf);
    if (fz_lookup_metadata(ctx, doc, FZ_META_FORMAT, buf, sizeof buf) > 0)
        y = do_info_line(x, y, "Format", buf);
    if (fz_lookup_metadata(ctx, doc, FZ_META_ENCRYPTION, buf, sizeof buf) > 0)
        y = do_info_line(x, y, "Encryption", buf);
    if (pdf_specifics(ctx, doc))
    {
        if (fz_lookup_metadata(ctx, doc, "info:Creator", buf, sizeof buf) > 0)
            y = do_info_line(x, y, "PDF Creator", buf);
        if (fz_lookup_metadata(ctx, doc, "info:Producer", buf, sizeof buf) > 0)
            y = do_info_line(x, y, "PDF Producer", buf);
        buf[0] = 0;
        if (fz_has_permission(ctx, doc, FZ_PERMISSION_PRINT))
            fz_strlcat(buf, "print, ", sizeof buf);
        if (fz_has_permission(ctx, doc, FZ_PERMISSION_COPY))
            fz_strlcat(buf, "copy, ", sizeof buf);
        if (fz_has_permission(ctx, doc, FZ_PERMISSION_EDIT))
            fz_strlcat(buf, "edit, ", sizeof buf);
        if (fz_has_permission(ctx, doc, FZ_PERMISSION_ANNOTATE))
            fz_strlcat(buf, "annotate, ", sizeof buf);
        if (strlen(buf) > 2)
            buf[strlen(buf)-2] = 0;
        else
            fz_strlcat(buf, "none", sizeof buf);
        y = do_info_line(x, y, "Permissions", buf);
    }
}
コード例 #2
0
ファイル: win_main.c プロジェクト: n1tehawk/mupdf
INT_PTR CALLBACK
dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	char buf[256];
	wchar_t bufx[256];
	fz_context *ctx = gapp.ctx;
	fz_document *doc = gapp.doc;

	switch(message)
	{
	case WM_INITDIALOG:

		SetDlgItemTextW(hwnd, 0x10, wbuf);

		if (fz_lookup_metadata(ctx, doc, FZ_META_FORMAT, buf, sizeof buf) >= 0)
		{
			SetDlgItemTextA(hwnd, 0x11, buf);
		}
		else
		{
			SetDlgItemTextA(hwnd, 0x11, "Unknown");
			SetDlgItemTextA(hwnd, 0x12, "None");
			SetDlgItemTextA(hwnd, 0x13, "n/a");
			return TRUE;
		}

		if (fz_lookup_metadata(ctx, doc, FZ_META_ENCRYPTION, buf, sizeof buf) >= 0)
		{
			SetDlgItemTextA(hwnd, 0x12, buf);
		}
		else
		{
			SetDlgItemTextA(hwnd, 0x12, "None");
		}

		buf[0] = 0;
		if (fz_has_permission(ctx, doc, FZ_PERMISSION_PRINT))
			strcat(buf, "print, ");
		if (fz_has_permission(ctx, doc, FZ_PERMISSION_COPY))
			strcat(buf, "copy, ");
		if (fz_has_permission(ctx, doc, FZ_PERMISSION_EDIT))
			strcat(buf, "edit, ");
		if (fz_has_permission(ctx, doc, FZ_PERMISSION_ANNOTATE))
			strcat(buf, "annotate, ");
		if (strlen(buf) > 2)
			buf[strlen(buf)-2] = 0;
		else
			strcpy(buf, "none");
		SetDlgItemTextA(hwnd, 0x13, buf);

#define SETUTF8(ID, STRING) \
		if (fz_lookup_metadata(ctx, doc, "info:" STRING, buf, sizeof buf) >= 0) \
		{ \
			MultiByteToWideChar(CP_UTF8, 0, buf, -1, bufx, nelem(bufx)); \
			SetDlgItemTextW(hwnd, ID, bufx); \
		}

		SETUTF8(0x20, "Title");
		SETUTF8(0x21, "Author");
		SETUTF8(0x22, "Subject");
		SETUTF8(0x23, "Keywords");
		SETUTF8(0x24, "Creator");
		SETUTF8(0x25, "Producer");
		SETUTF8(0x26, "CreationDate");
		SETUTF8(0x27, "ModDate");
		return TRUE;

	case WM_COMMAND:
		EndDialog(hwnd, 1);
		return TRUE;
	}
	return FALSE;
}