Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zathura-pdf-mupdf
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwmt
zathura-pdf-mupdf
Commits
99bff723
Commit
99bff723
authored
Apr 20, 2015
by
Moritz Lipp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse entries in the document information dictionary
parent
c3820b67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
3 deletions
+99
-3
document.c
document.c
+98
-0
plugin.c
plugin.c
+1
-3
No files found.
document.c
View file @
99bff723
...
...
@@ -6,8 +6,12 @@
#include <mupdf/xps.h>
#include <mupdf/pdf.h>
#include <glib-2.0/glib.h>
#include "plugin.h"
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
zathura_error_t
pdf_document_open
(
zathura_document_t
*
document
)
{
...
...
@@ -118,3 +122,97 @@ pdf_document_save_as(zathura_document_t* document, mupdf_document_t*
return
ZATHURA_ERROR_OK
;
}
girara_list_t
*
pdf_document_get_information
(
zathura_document_t
*
document
,
mupdf_document_t
*
mupdf_document
,
zathura_error_t
*
error
)
{
if
(
document
==
NULL
||
mupdf_document
==
NULL
||
error
==
NULL
)
{
if
(
error
!=
NULL
)
{
*
error
=
ZATHURA_ERROR_INVALID_ARGUMENTS
;
}
}
girara_list_t
*
list
=
zathura_document_information_entry_list_new
();
if
(
list
==
NULL
)
{
if
(
error
!=
NULL
)
{
*
error
=
ZATHURA_ERROR_UNKNOWN
;
}
return
NULL
;
}
fz_try
(
mupdf_document
->
ctx
)
{
pdf_obj
*
trailer
=
pdf_trailer
(
mupdf_document
->
ctx
,
(
pdf_document
*
)
mupdf_document
->
document
);
pdf_obj
*
info_dict
=
pdf_dict_get
(
mupdf_document
->
ctx
,
trailer
,
PDF_NAME_Info
);
/* get string values */
typedef
struct
info_value_s
{
const
char
*
property
;
zathura_document_information_type_t
type
;
}
info_value_t
;
static
const
info_value_t
string_values
[]
=
{
{
"Title"
,
ZATHURA_DOCUMENT_INFORMATION_TITLE
},
{
"Author"
,
ZATHURA_DOCUMENT_INFORMATION_AUTHOR
},
{
"Subject"
,
ZATHURA_DOCUMENT_INFORMATION_SUBJECT
},
{
"Keywords"
,
ZATHURA_DOCUMENT_INFORMATION_KEYWORDS
},
{
"Creator"
,
ZATHURA_DOCUMENT_INFORMATION_CREATOR
},
{
"Producer"
,
ZATHURA_DOCUMENT_INFORMATION_PRODUCER
}
};
for
(
unsigned
int
i
=
0
;
i
<
LENGTH
(
string_values
);
i
++
)
{
pdf_obj
*
value
=
pdf_dict_gets
(
mupdf_document
->
ctx
,
info_dict
,
string_values
[
i
].
property
);
if
(
value
==
NULL
)
{
continue
;
}
char
*
str_value
=
pdf_to_str_buf
(
mupdf_document
->
ctx
,
value
);
if
(
str_value
==
NULL
||
strlen
(
str_value
)
==
0
)
{
continue
;
}
zathura_document_information_entry_t
*
entry
=
zathura_document_information_entry_new
(
string_values
[
i
].
type
,
str_value
);
if
(
entry
!=
NULL
)
{
girara_list_append
(
list
,
entry
);
}
}
static
const
info_value_t
time_values
[]
=
{
{
"CreationDate"
,
ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE
},
{
"ModDate"
,
ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE
}
};
for
(
unsigned
int
i
=
0
;
i
<
LENGTH
(
time_values
);
i
++
)
{
pdf_obj
*
value
=
pdf_dict_gets
(
mupdf_document
->
ctx
,
info_dict
,
time_values
[
i
].
property
);
if
(
value
==
NULL
)
{
continue
;
}
char
*
str_value
=
pdf_to_str_buf
(
mupdf_document
->
ctx
,
value
);
if
(
str_value
==
NULL
||
strlen
(
str_value
)
==
0
)
{
continue
;
}
zathura_document_information_entry_t
*
entry
=
zathura_document_information_entry_new
(
time_values
[
i
].
type
,
str_value
// FIXME: Convert to common format
);
if
(
entry
!=
NULL
)
{
girara_list_append
(
list
,
entry
);
}
}
}
fz_catch
(
mupdf_document
->
ctx
)
{
if
(
error
!=
NULL
)
{
*
error
=
ZATHURA_ERROR_UNKNOWN
;
}
return
NULL
;
}
return
list
;
}
plugin.c
View file @
99bff723
...
...
@@ -11,13 +11,11 @@ register_functions(zathura_plugin_functions_t* functions)
functions
->
document_free
=
(
zathura_plugin_document_free_t
)
pdf_document_free
;
functions
->
document_save_as
=
(
zathura_plugin_document_save_as_t
)
pdf_document_save_as
;
functions
->
document_index_generate
=
(
zathura_plugin_document_index_generate_t
)
pdf_document_index_generate
;
functions
->
document_get_information
=
(
zathura_plugin_document_get_information_t
)
pdf_document_get_information
;
functions
->
page_init
=
(
zathura_plugin_page_init_t
)
pdf_page_init
;
functions
->
page_clear
=
(
zathura_plugin_page_clear_t
)
pdf_page_clear
;
functions
->
page_search_text
=
(
zathura_plugin_page_search_text_t
)
pdf_page_search_text
;
functions
->
page_links_get
=
(
zathura_plugin_page_links_get_t
)
pdf_page_links_get
;
#if 0
functions->document_get_information = (zathura_plugin_document_get_information_t) pdf_document_get_information;
#endif
functions
->
page_images_get
=
(
zathura_plugin_page_images_get_t
)
pdf_page_images_get
;
functions
->
page_get_text
=
(
zathura_plugin_page_get_text_t
)
pdf_page_get_text
;
functions
->
page_render
=
(
zathura_plugin_page_render_t
)
pdf_page_render
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment