diff options
-rw-r--r-- | codegen/extradefs/generate_extra_defs_poppler-glib.cc | 1 | ||||
-rw-r--r-- | codegen/m4/convert_poppler-glib.m4 | 1 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | poppler-glib/src/annot.hg | 1 | ||||
-rw-r--r-- | poppler-glib/src/document.ccg | 26 | ||||
-rw-r--r-- | poppler-glib/src/document.hg | 31 | ||||
-rw-r--r-- | poppler-glib/src/page.hg | 3 | ||||
-rw-r--r-- | poppler-glib/src/poppler-glib_docs.xml | 176 | ||||
-rw-r--r-- | poppler-glib/src/poppler-glib_docs_override.xml | 60 | ||||
-rw-r--r-- | poppler-glib/src/poppler-glib_enum.defs | 20 | ||||
-rw-r--r-- | poppler-glib/src/poppler-glib_method.defs | 68 |
11 files changed, 368 insertions, 21 deletions
diff --git a/codegen/extradefs/generate_extra_defs_poppler-glib.cc b/codegen/extradefs/generate_extra_defs_poppler-glib.cc index 154d0f6..413c24a 100644 --- a/codegen/extradefs/generate_extra_defs_poppler-glib.cc +++ b/codegen/extradefs/generate_extra_defs_poppler-glib.cc @@ -51,6 +51,7 @@ int main(int, char**) << get_defs(POPPLER_TYPE_DEST_TYPE) << get_defs(POPPLER_TYPE_DOCUMENT) << get_defs(POPPLER_TYPE_ERROR) + << get_defs(POPPLER_TYPE_FIND_FLAGS) << get_defs(POPPLER_TYPE_FONTS_ITER) << get_defs(POPPLER_TYPE_FONT_INFO) << get_defs(POPPLER_TYPE_FONT_TYPE) diff --git a/codegen/m4/convert_poppler-glib.m4 b/codegen/m4/convert_poppler-glib.m4 index 4068d15..a4b2318 100644 --- a/codegen/m4/convert_poppler-glib.m4 +++ b/codegen/m4/convert_poppler-glib.m4 @@ -12,6 +12,7 @@ _CONV_ENUM(Poppler,AnnotTextState) _CONV_ENUM(Poppler,AnnotType) _CONV_ENUM(Poppler,Backend) _CONV_ENUM(Poppler,DestType) +_CONV_ENUM(Poppler,FindFlags) _CONV_ENUM(Poppler,FontType) _CONV_ENUM(Poppler,FormButtonType) _CONV_ENUM(Poppler,FormChoiceType) diff --git a/configure.ac b/configure.ac index e594468..ec20230 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL -AC_SUBST([POPPLER_GLIBMM_MODULES], ['poppler-glib >= 0.20 glibmm-2.4 >= 2.16 cairomm-1.0 >= 1.10']) +AC_SUBST([POPPLER_GLIBMM_MODULES], ['poppler-glib >= 0.20 glibmm-2.4 >= 2.16 cairomm-1.0 >= 1.10 giomm-2.4 >= 2.16']) PKG_CHECK_MODULES([POPPLER_GLIBMM], [$POPPLER_GLIBMM_MODULES]) # This is only needed for the demos diff --git a/poppler-glib/src/annot.hg b/poppler-glib/src/annot.hg index fb62f61..161c7db 100644 --- a/poppler-glib/src/annot.hg +++ b/poppler-glib/src/annot.hg @@ -52,6 +52,7 @@ class Annot : public Glib::Object public: _WRAP_METHOD(AnnotType get_annot_type() const, poppler_annot_get_annot_type) _WRAP_METHOD(AnnotFlag get_flags() const, poppler_annot_get_flags) + _WRAP_METHOD(void set_flags(AnnotFlag flags) const, poppler_annot_set_flags) _WRAP_METHOD(Glib::ustring get_name() const, poppler_annot_get_name) _WRAP_METHOD(int get_page_index() const, poppler_annot_get_page_index) _WRAP_METHOD(Color get_color() const, poppler_annot_get_color) diff --git a/poppler-glib/src/document.ccg b/poppler-glib/src/document.ccg index 1000b35..ad64334 100644 --- a/poppler-glib/src/document.ccg +++ b/poppler-glib/src/document.ccg @@ -36,6 +36,32 @@ Glib::RefPtr<Document> Document::new_from_data(const std::string& data, const st return retvalue; } +Glib::RefPtr<Document> Document::new_from_stream(const Glib::RefPtr<Gio::InputStream>& stream, + const goffset length, const std::string& password, + const Glib::RefPtr<Gio::Cancellable>& cancellable) +{ + GError* gerror = 0; + Glib::RefPtr<Document> retvalue = Glib::wrap(poppler_document_new_from_stream(stream->gobj(), + length, password.c_str(), cancellable ? cancellable->gobj() : NULL, &gerror)); + if(gerror) + ::Glib::Error::throw_exception(gerror); + + return retvalue; +} + +static Glib::RefPtr<Document> new_from_gio_file(const Glib::RefPtr<Gio::File>& file, + const std::string& password, + const Glib::RefPtr<Gio::Cancellable>& cancellable) +{ + GError* gerror = 0; + Glib::RefPtr<Document> retvalue = Glib::wrap(poppler_document_new_from_gfile(file->gobj(), + password.c_str(), cancellable ? cancellable->gobj() : NULL, &gerror)); + if(gerror) + ::Glib::Error::throw_exception(gerror); + + return retvalue; +} + bool Document::get_id(Glib::ustring& permanent_id, Glib::ustring& update_id) const { Glib::ScopedPtr<gchar> permanent_id_array, update_id_array; diff --git a/poppler-glib/src/document.hg b/poppler-glib/src/document.hg index 594811e..a26ce54 100644 --- a/poppler-glib/src/document.hg +++ b/poppler-glib/src/document.hg @@ -21,6 +21,8 @@ _CONFIGINCLUDE(poppler-glibmmconfig.h) _PINCLUDE(glibmm/private/object_p.h) #include <glibmm/object.h> +#include <giomm/inputstream.h> +#include <giomm/file.h> #include <poppler-glibmm/page.h> #include <poppler-glibmm/action.h> #include <poppler-glibmm/attachment.h> @@ -67,7 +69,34 @@ public: */ static Glib::RefPtr<Document> new_from_data(const std::string& data, const std::string& password = ""); - /** Saves document. Any change made in the document such as form fields + /** Creates a new Poppler::Document reading the PDF contents from @a stream. + * Note that the given Gio::InputStream must be seekable or + * Gio::IO_ERROR_NOT_SUPPORTED will be thrown. + * If <tt>0</tt> is returned, then an exception will be thrown. + * @param stream A Gio::InputStream to read from. + * @param length The stream length, or -1 if not known. + * @param password Password to unlock the file with. + * @param cancellable A Gio::Cancellable, or <tt>0</tt>. + * @return A new Poppler::Document, or <tt>0</tt>. + * @throws Poppler::Error, Glib::FileError, and Gio::Error + */ + static Glib::RefPtr<Document> new_from_stream(const Glib::RefPtr<Gio::InputStream>& stream, + const goffset length = -1, const std::string& password = "", + const Glib::RefPtr<Gio::Cancellable>& cancellable = Glib::RefPtr<Gio::Cancellable>()); + + /** Creates a new Poppler::Document reading the PDF contents from @a file. + * If <tt>0</tt> is returned, then an exception will be thrown. + * @param file A Gio::File to load. + * @param password Password to unlock the file with. + * @param cancellable A Gio::Cancellable, or <tt>0</tt>. + * @return A new Poppler::Document, or <tt>0</tt>. + * @throws Poppler::Error and Glib::FileError + */ + static Glib::RefPtr<Document> new_from_gio_file(const Glib::RefPtr<Gio::File>& file, + const std::string& password = "", + const Glib::RefPtr<Gio::Cancellable>& cancellable = Glib::RefPtr<Gio::Cancellable>()); + + /** Saves document. Any change made in the document such as form fields * filled, annotations added or modified will be saved. * If an error occurs, <tt>false</tt> will be returned. * @param uri Uri of file to save. diff --git a/poppler-glib/src/page.hg b/poppler-glib/src/page.hg index 554b467..c2d4408 100644 --- a/poppler-glib/src/page.hg +++ b/poppler-glib/src/page.hg @@ -39,6 +39,7 @@ class Annot; _WRAP_ENUM(PrintFlags, PopplerPrintFlags) _WRAP_ENUM(SelectionStyle, PopplerSelectionStyle) +_WRAP_ENUM(FindFlags, PopplerFindFlags) /** Poppler::Page is a class that provides access to information about a page * in a document @@ -83,6 +84,7 @@ public: #m4 _CONVERSION(`GList*',`std::vector<Rectangle>', #m4 `Glib::ListHandler<Rectangle,RectangleTraits>::list_to_vector($3, Glib::OWNERSHIP_DEEP)') _WRAP_METHOD(std::vector<Rectangle> find_text(const Glib::ustring& text) const, poppler_page_find_text) + _WRAP_METHOD(std::vector<Rectangle> find_text_with_options(const Glib::ustring& text, FindFlags options) const, poppler_page_find_text_with_options) _WRAP_METHOD(Glib::ustring get_text() const, poppler_page_get_text) @@ -118,6 +120,7 @@ public: _IGNORE(poppler_page_free_annot_mapping) _WRAP_METHOD(void add_annot(const Glib::RefPtr<Annot>& annot) const, poppler_page_add_annot) + _WRAP_METHOD(void remove_annot(const Glib::RefPtr<Annot>& annot) const, poppler_page_remove_annot) _WRAP_PROPERTY("label", Glib::ustring) }; diff --git a/poppler-glib/src/poppler-glib_docs.xml b/poppler-glib/src/poppler-glib_docs.xml index 9ddb0a7..c773cc7 100644 --- a/poppler-glib/src/poppler-glib_docs.xml +++ b/poppler-glib/src/poppler-glib_docs.xml @@ -629,6 +629,26 @@ replacing the current contents. <return></return> </function> +<function name="poppler_annot_set_flags"> +<description> +Sets the flag field specifying various characteristics of the +@poppler_annot. + + +</description> +<parameters> +<parameter name="poppler_annot"> +<parameter_description> a #PopplerAnnot +</parameter_description> +</parameter> +<parameter name="flags"> +<parameter_description> a #PopplerAnnotFlag +</parameter_description> +</parameter> +</parameters> +<return></return> +</function> + <function name="poppler_annot_text_get_icon"> <description> Gets name of the icon of @poppler_annot. @@ -1441,6 +1461,74 @@ domains. </return> </function> +<function name="poppler_document_new_from_gfile"> +<description> +Creates a new #PopplerDocument reading the PDF contents from @file. +Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR +domains. + + +</description> +<parameters> +<parameter name="file"> +<parameter_description> a #GFile to load +</parameter_description> +</parameter> +<parameter name="password"> +<parameter_description> password to unlock the file with, or %NULL +</parameter_description> +</parameter> +<parameter name="cancellable"> +<parameter_description> a #GCancellable, or %NULL +</parameter_description> +</parameter> +<parameter name="error"> +<parameter_description> Return location for an error, or %NULL +</parameter_description> +</parameter> +</parameters> +<return> a new #PopplerDocument, or %NULL + +</return> +</function> + +<function name="poppler_document_new_from_stream"> +<description> +Creates a new #PopplerDocument reading the PDF contents from @stream. +Note that the given #GInputStream must be seekable or %G_IO_ERROR_NOT_SUPPORTED +will be returned. +Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR +domains. + + +</description> +<parameters> +<parameter name="stream"> +<parameter_description> a #GInputStream to read from +</parameter_description> +</parameter> +<parameter name="length"> +<parameter_description> the stream length, or -1 if not known +</parameter_description> +</parameter> +<parameter name="password"> +<parameter_description> password to unlock the file with, or %NULL +</parameter_description> +</parameter> +<parameter name="cancellable"> +<parameter_description> a #GCancellable, or %NULL +</parameter_description> +</parameter> +<parameter name="error"> +<parameter_description> Return location for an error, or %NULL +</parameter_description> +</parameter> +</parameters> +<return> a new #PopplerDocument, or %NULL + +</return> +</function> + <function name="poppler_document_save"> <description> Saves @document. Any change made in the document such as @@ -1584,6 +1672,23 @@ Frees the given #PopplerFontsIter <return></return> </function> +<function name="poppler_fonts_iter_get_encoding"> +<description> +Returns the encoding of the font associated with @iter + + +</description> +<parameters> +<parameter name="iter"> +<parameter_description> a #PopplerFontsIter +</parameter_description> +</parameter> +</parameters> +<return> the font encoding + +</return> +</function> + <function name="poppler_fonts_iter_get_file_name"> <description> The filename of the font associated with @iter or %NULL if @@ -1597,7 +1702,7 @@ the font is embedded </parameter_description> </parameter> </parameters> -<return> the filename of the font or %NULL y font is emebedded +<return> the filename of the font or %NULL if font is embedded </return> </function> @@ -1649,6 +1754,24 @@ Returns the name of the font associated with @iter </return> </function> +<function name="poppler_fonts_iter_get_substitute_name"> +<description> +The name of the substitute font of the font associated with @iter or %NULL if +the font is embedded + + +</description> +<parameters> +<parameter name="iter"> +<parameter_description> a #PopplerFontsIter +</parameter_description> +</parameter> +</parameters> +<return> the name of the substitute font or %NULL if font is embedded + +</return> +</function> + <function name="poppler_fonts_iter_is_embedded"> <description> Returns whether the font associated with @iter is embedded in the document @@ -2913,7 +3036,30 @@ Adds annotation @annot to @page. <function name="poppler_page_find_text"> <description> -A #GList of rectangles for each occurance of the text on the page. +Finds @text in @page with the default options (%POPPLER_FIND_DEFAULT) and +returns a #GList of rectangles for each occurance of the text on the page. +The coordinates are in PDF points. + + +</description> +<parameters> +<parameter name="page"> +<parameter_description> a #PopplerPage +</parameter_description> +</parameter> +<parameter name="text"> +<parameter_description> the text to search for (UTF-8 encoded) +</parameter_description> +</parameter> +</parameters> +<return> a #GList of #PopplerRectangle, +</return> +</function> + +<function name="poppler_page_find_text_with_options"> +<description> +Finds @text in @page with the given #PopplerFindFlags options and +returns a #GList of rectangles for each occurance of the text on the page. The coordinates are in PDF points. @@ -2927,8 +3073,13 @@ The coordinates are in PDF points. <parameter_description> the text to search for (UTF-8 encoded) </parameter_description> </parameter> +<parameter name="options"> +<parameter_description> find options +</parameter_description> +</parameter> </parameters> <return> a #GList of #PopplerRectangle, + </return> </function> @@ -3099,7 +3250,7 @@ Returns a cairo surface for the image of the @page </parameter_description> </parameter> <parameter name="image_id"> -<parameter_description> The image identificator +<parameter_description> The image identifier </parameter_description> </parameter> </parameters> @@ -3419,6 +3570,25 @@ Returns the transition effect of @page </return> </function> +<function name="poppler_page_remove_annot"> +<description> +Removes annotation @annot from @page + + +</description> +<parameters> +<parameter name="page"> +<parameter_description> a #PopplerPage +</parameter_description> +</parameter> +<parameter name="annot"> +<parameter_description> a #PopplerAnnot to remove +</parameter_description> +</parameter> +</parameters> +<return></return> +</function> + <function name="poppler_page_render"> <description> Render the page to the given cairo context. This function diff --git a/poppler-glib/src/poppler-glib_docs_override.xml b/poppler-glib/src/poppler-glib_docs_override.xml index 3cb2ddf..0e9630f 100644 --- a/poppler-glib/src/poppler-glib_docs_override.xml +++ b/poppler-glib/src/poppler-glib_docs_override.xml @@ -325,6 +325,23 @@ Retrieves the flag field specifying various characteristics of the annotation. </return> </function> +<function name="poppler_annot_set_flags"> +<description> +Sets the flag field specifying various characteristics of the annotation. +</description> +<parameters> +<parameter name="poppler_annot"> +<parameter_description> a #PopplerAnnot +</parameter_description> +</parameter> +<parameter name="flags"> +<parameter_description> a #PopplerAnnotFlag +</parameter_description> +</parameter> +</parameters> +<return></return> +</function> + <function name="poppler_annot_get_name"> <description> Retrieves the name of the annotation. @@ -522,7 +539,8 @@ Returns a region containing the area that would be rendered by render_selection( <function name="poppler_page_find_text"> <description> -Obtaines a vector of rectangles for each occurance of the text on the page. +Finds @text in @page with the default options (%POPPLER_FIND_DEFAULT) and +returns a vector of rectangles for each occurance of the text on the page. The coordinates are in PDF points. </description> <parameters> @@ -535,7 +553,31 @@ The coordinates are in PDF points. </parameter_description> </parameter> </parameters> -<return> Returns a vector of #PopplerRectangle +<return> A vector of #PopplerRectangle +</return> +</function> + +<function name="poppler_page_find_text_with_options"> +<description> +Finds @text in @page with the given #PopplerFindFlags options and +returns a vector of rectangles for each occurance of the text on the page. +The coordinates are in PDF points. +</description> +<parameters> +<parameter name="page"> +<parameter_description> a #PopplerPage +</parameter_description> +</parameter> +<parameter name="text"> +<parameter_description> the text to search for (UTF-8 encoded) +</parameter_description> +</parameter> +<parameter name="options"> +<parameter_description> find options +</parameter_description> +</parameter> +</parameters> +<return> A vector of #PopplerRectangle, </return> </function> @@ -766,18 +808,4 @@ Retrieves the action (#PopplerAction) that shall be performed when the annotatio </return> </function> -<function name="poppler_fonts_iter_get_file_name"> -<description> -The filename of the font associated with the iter or %NULL if the font is embedded -</description> -<parameters> -<parameter name="iter"> -<parameter_description> a #PopplerFontsIter -</parameter_description> -</parameter> -</parameters> -<return> The filename of the font or %NULL if the font is emebedded -</return> -</function> - </root> diff --git a/poppler-glib/src/poppler-glib_enum.defs b/poppler-glib/src/poppler-glib_enum.defs index 139817b..b5685f7 100644 --- a/poppler-glib/src/poppler-glib_enum.defs +++ b/poppler-glib/src/poppler-glib_enum.defs @@ -658,6 +658,26 @@ ) ;; Original typedef: +;; typedef enum /*< flags >*/ +;; { +;; POPPLER_FIND_DEFAULT = 0, +;; POPPLER_FIND_CASE_SENSITIVE = 1 << 0, +;; POPPLER_FIND_BACKWARDS = 1 << 1, +;; POPPLER_FIND_WHOLE_WORDS_ONLY = 1 << 2 +;; } PopplerFindFlags; + +(define-flags-extended FindFlags + (in-module "Poppler") + (c-name "PopplerFindFlags") + (values + '("default" "POPPLER_FIND_DEFAULT" "0x0") + '("case-sensitive" "POPPLER_FIND_CASE_SENSITIVE" "1 << 0") + '("backwards" "POPPLER_FIND_BACKWARDS" "1 << 1") + '("whole-words-only" "POPPLER_FIND_WHOLE_WORDS_ONLY" "1 << 2") + ) +) + +;; Original typedef: ;; typedef enum ;; { ;; POPPLER_BACKEND_UNKNOWN, diff --git a/poppler-glib/src/poppler-glib_method.defs b/poppler-glib/src/poppler-glib_method.defs index 5add90c..ccd959c 100644 --- a/poppler-glib/src/poppler-glib_method.defs +++ b/poppler-glib/src/poppler-glib_method.defs @@ -392,6 +392,18 @@ ) ) +(define-flags FindFlags + (in-module "Poppler") + (c-name "PopplerFindFlags") + (gtype-id "POPPLER_TYPE_FIND_FLAGS") + (values + '("default" "POPPLER_FIND_DEFAULT") + '("case-sensitive" "POPPLER_FIND_CASE_SENSITIVE") + '("backwards" "POPPLER_FIND_BACKWARDS") + '("whole-words-only" "POPPLER_FIND_WHOLE_WORDS_ONLY") + ) +) + (define-enum Backend (in-module "Poppler") (c-name "PopplerBackend") @@ -488,6 +500,15 @@ (return-type "PopplerAnnotFlag") ) +(define-method set_flags + (of-object "PopplerAnnot") + (c-name "poppler_annot_set_flags") + (return-type "none") + (parameters + '("PopplerAnnotFlag" "flags") + ) +) + (define-method get_color (of-object "PopplerAnnot") (c-name "poppler_annot_get_color") @@ -816,6 +837,29 @@ ) ) +(define-function poppler_document_new_from_stream + (c-name "poppler_document_new_from_stream") + (return-type "PopplerDocument*") + (parameters + '("GInputStream*" "stream") + '("goffset" "length") + '("const-char*" "password") + '("GCancellable*" "cancellable") + '("GError**" "error") + ) +) + +(define-function poppler_document_new_from_gfile + (c-name "poppler_document_new_from_gfile") + (return-type "PopplerDocument*") + (parameters + '("GFile*" "file") + '("const-char*" "password") + '("GCancellable*" "cancellable") + '("GError**" "error") + ) +) + (define-method save (of-object "PopplerDocument") (c-name "poppler_document_save") @@ -1377,6 +1421,11 @@ (return-type "GType") ) +(define-function poppler_find_flags_get_type + (c-name "poppler_find_flags_get_type") + (return-type "GType") +) + (define-function poppler_backend_get_type (c-name "poppler_backend_get_type") (return-type "GType") @@ -1843,6 +1892,16 @@ ) ) +(define-method find_text_with_options + (of-object "PopplerPage") + (c-name "poppler_page_find_text_with_options") + (return-type "GList*") + (parameters + '("const-char*" "text") + '("PopplerFindFlags" "options") + ) +) + (define-method find_text (of-object "PopplerPage") (c-name "poppler_page_find_text") @@ -1981,6 +2040,15 @@ ) ) +(define-method remove_annot + (of-object "PopplerPage") + (c-name "poppler_page_remove_annot") + (return-type "none") + (parameters + '("PopplerAnnot*" "annot") + ) +) + (define-method get_crop_box (of-object "PopplerPage") (c-name "poppler_page_get_crop_box") |