glib/poppler-document.cc            |   32 ++++++++++++++++++++++++++++++--
 glib/poppler-document.h             |    4 +++-
 glib/reference/poppler-sections.txt |    1 +
 3 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit 2ac091c8c1fefe21caf1c2d032c57f90c6674844
Author: Marek Kasik <[email protected]>
Date:   Tue Jan 25 15:58:05 2022 +0100

    glib: New method for getting all signature fields
    
    This commit adds new method poppler_document_get_signature_fields()
    which returns GList of all signature fields for the document.
    This is needed as some documents have signature fields which are not
    associated to any page and hence are unaccessible now.

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 7c275454..787d05d8 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -2,12 +2,11 @@
  * Copyright (C) 2005, Red Hat, Inc.
  *
  * Copyright (C) 2016 Jakub Alba <[email protected]>
- * Copyright (C) 2018-2019 Marek Kasik <[email protected]>
+ * Copyright (C) 2018, 2019, 2021, 2022 Marek Kasik <[email protected]>
  * Copyright (C) 2019 Masamichi Hosoda <[email protected]>
  * Copyright (C) 2019, 2021 Oliver Sander <[email protected]>
  * Copyright (C) 2020 Albert Astals Cid <[email protected]>
  * Copyright (C) 2021 AndrĂ© Guerreiro <[email protected]>
- * Copyright (C) 2021 Marek Kasik <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1787,6 +1786,35 @@ gint poppler_document_get_n_signatures(const 
PopplerDocument *document)
     return document->doc->getNumSignatureFields();
 }
 
+/**
+ * poppler_document_get_signature_fields:
+ * @document: A #PopplerDocument
+ *
+ * Returns a #GList containing all signature #PopplerFormField<!-- -->s in the 
document.
+ *
+ * Return value: (element-type PopplerFormField) (transfer full): a list of 
all signature form fields.
+ *
+ * Since: 22.02.0
+ **/
+GList *poppler_document_get_signature_fields(PopplerDocument *document)
+{
+    std::vector<FormFieldSignature *> signature_fields;
+    FormWidget *widget;
+    GList *result = nullptr;
+    gsize i;
+
+    signature_fields = document->doc->getSignatureFields();
+
+    for (i = 0; i < signature_fields.size(); i++) {
+        widget = signature_fields[i]->getCreateWidget();
+
+        if (widget != nullptr)
+            result = g_list_prepend(result, _poppler_form_field_new(document, 
widget));
+    }
+
+    return g_list_reverse(result);
+}
+
 /**
  * poppler_document_get_page_layout:
  * @document: A #PopplerDocument
diff --git a/glib/poppler-document.h b/glib/poppler-document.h
index 595c2de7..3dabfa2f 100644
--- a/glib/poppler-document.h
+++ b/glib/poppler-document.h
@@ -2,7 +2,7 @@
  * Copyright (C) 2004, Red Hat, Inc.
  *
  * Copyright (C) 2016 Jakub Alba <[email protected]>
- * Copyright (C) 2018, 2019, 2021 Marek Kasik <[email protected]>
+ * Copyright (C) 2018, 2019, 2021, 2022 Marek Kasik <[email protected]>
  * Copyright (C) 2019 Masamichi Hosoda <[email protected]>
  * Copyright (C) 2021 AndrĂ© Guerreiro <[email protected]>
  *
@@ -419,6 +419,8 @@ gboolean poppler_document_has_javascript(PopplerDocument 
*document);
 
 /* Signatures */
 POPPLER_PUBLIC
+GList *poppler_document_get_signature_fields(PopplerDocument *document);
+POPPLER_PUBLIC
 gint poppler_document_get_n_signatures(const PopplerDocument *document);
 
 /* Interface for getting the Index of a poppler_document */
diff --git a/glib/reference/poppler-sections.txt 
b/glib/reference/poppler-sections.txt
index ac542e78..0a20ffae 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -190,6 +190,7 @@ poppler_document_get_print_n_copies
 poppler_document_get_print_page_ranges
 poppler_document_get_print_scaling
 poppler_document_get_producer
+poppler_document_get_signature_fields
 poppler_document_get_subject
 poppler_document_get_title
 poppler_document_has_attachments

Reply via email to