[poppler] getting /Catalog /Lang in poppler-glib

2022-04-14 Thread Pablo Rodríguez
Dear list,

I use the Python bindings for Poppler (through GObject introspection) to
extract some metadata from PDF documents.

Here is a minimal script:


  import sys

  import os

  import gi

  gi.require_version('Poppler', '0.18')

  from gi.repository import Poppler

  gi.require_version('Gst', '1.0')

  from gi.repository import Gst

  Gst.init(sys.argv)

  pdf = "a.pdf"

  uri = Gst.filename_to_uri(os.path.abspath(pdf))

  doc = Poppler.Document.new_from_file(uri, None)

  title = doc.get_title()

  print(title)


Is there a way that I can extract the /Lang value from the /Catalog
dictionary? (Attached PDF document with that entry.)

I’m afraid I searched https://lazka.github.io/pgi-docs/, but I wasn’t
able to find anything that could give the language from the document.

Many thanks for your help,

Pablo


a.pdf
Description: Adobe PDF document


Re: [poppler] getting /Catalog /Lang in poppler-glib

2022-04-14 Thread Albert Astals Cid
El dijous, 14 d’abril de 2022, a les 13:16:58 (CEST), Pablo Rodríguez va 
escriure:
> Dear list,
> 
> I use the Python bindings for Poppler (through GObject introspection) to
> extract some metadata from PDF documents.
> 
> Here is a minimal script:
> 
> 
>   import sys
> 
>   import os
> 
>   import gi
> 
>   gi.require_version('Poppler', '0.18')
> 
>   from gi.repository import Poppler
> 
>   gi.require_version('Gst', '1.0')
> 
>   from gi.repository import Gst
> 
>   Gst.init(sys.argv)
> 
>   pdf = "a.pdf"
> 
>   uri = Gst.filename_to_uri(os.path.abspath(pdf))
> 
>   doc = Poppler.Document.new_from_file(uri, None)
> 
>   title = doc.get_title()
> 
>   print(title)
> 
> 
> Is there a way that I can extract the /Lang value from the /Catalog
> dictionary? (Attached PDF document with that entry.)

No, thought it should be relatively easy to add support for it. Will you 
contribute a patch?

Cheers,
  Albert

> 
> I’m afraid I searched https://lazka.github.io/pgi-docs/, but I wasn’t
> able to find anything that could give the language from the document.
> 
> Many thanks for your help,
> 
> Pablo
> 






[poppler] poppler/Form.cc poppler/Form.h qt5/src qt6/src

2022-04-14 Thread GitLab Mirror
 poppler/Form.cc |3 ++-
 poppler/Form.h  |2 +-
 qt5/src/poppler-form.cc |5 +++--
 qt6/src/poppler-form.cc |5 +++--
 4 files changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 10d74ff226b8b7e930a75b050664272df30c2aba
Author: Alexander Sulfrian 
Date:   Thu Apr 14 00:43:58 2022 +0200

qt: Pass leftFontSize down to 
`FormWidgetSignature::signDocumentWithAppearence`

A similar issue for `PDFDoc::sign` was already fixed in: 
864466a6753014106448f1a6caa68bedf101

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 0aafd912..486a9b4e 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -687,7 +687,7 @@ bool FormWidgetSignature::signDocument(const char 
*saveFilename, const char *cer
 
 bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, 
const char *certNickname, const char *digestName, const char *password, const 
GooString *reason, const GooString *location,
  const 
std::optional , const std::optional 
, const GooString , const GooString 
, double fontSize,
- 
std::unique_ptr &, double borderWidth, 
std::unique_ptr &, std::unique_ptr 
&)
+ double leftFontSize, 
std::unique_ptr &, double borderWidth, 
std::unique_ptr &, std::unique_ptr 
&)
 {
 // Set the appearance
 GooString *aux = getField()->getDefaultAppearance();
@@ -722,6 +722,7 @@ bool FormWidgetSignature::signDocumentWithAppearance(const 
char *saveFilename, c
 ::FormFieldSignature *ffs = static_cast<::FormFieldSignature 
*>(getField());
 ffs->setCustomAppearanceContent(signatureText);
 ffs->setCustomAppearanceLeftContent(signatureTextLeft);
+ffs->setCustomAppearanceLeftFontSize(leftFontSize);
 
 const bool success = signDocument(saveFilename, certNickname, digestName, 
password, reason, location, ownerPassword, userPassword);
 
diff --git a/poppler/Form.h b/poppler/Form.h
index 903482a0..1157147b 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -312,7 +312,7 @@ public:
 // Same as above but adds text, font color, etc.
 bool signDocumentWithAppearance(const char *filename, const char 
*certNickname, const char *digestName, const char *password, const GooString 
*reason = nullptr, const GooString *location = nullptr,
 const std::optional 
 = {}, const std::optional  = {}, const 
GooString  = {}, const GooString  = {}, double 
fontSize = {},
-std::unique_ptr & = 
{}, double borderWidth = {}, std::unique_ptr & = {}, 
std::unique_ptr & = {});
+double leftFontSize = {}, 
std::unique_ptr & = {}, double borderWidth = {}, 
std::unique_ptr & = {}, std::unique_ptr 
& = {});
 
 // checks the length encoding of the signature and returns the hex encoded 
signature
 // if the check passed (and the checked file size as output parameter in 
checkedFileSize)
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 665fb5f4..1144c174 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1102,8 +1102,9 @@ FormFieldSignature::SigningResult 
FormFieldSignature::sign(const QString 
 const auto gSignatureText = 
std::unique_ptr(QStringToUnicodeGooString(data.signatureText()));
 const auto gSignatureLeftText = 
std::unique_ptr(QStringToUnicodeGooString(data.signatureLeftText()));
 
-const bool success = 
fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), 
data.certNickname().toUtf8().constData(), "SHA256", 
data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, 
userPwd,
- *gSignatureText, 
*gSignatureLeftText, data.fontSize(), convertQColor(data.fontColor()), 
data.borderWidth(), convertQColor(data.borderColor()), 
convertQColor(data.backgroundColor()));
+const bool success =
+
fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), 
data.certNickname().toUtf8().constData(), "SHA256", 
data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, 
userPwd, *gSignatureText,
+*gSignatureLeftText, 
data.fontSize(), data.leftFontSize(), convertQColor(data.fontColor()), 
data.borderWidth(), convertQColor(data.borderColor()), 
convertQColor(data.backgroundColor()));
 
 return success ? SigningSuccess : GenericSigningError;
 }
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index 7e963f0f..e97b327b 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -1102,8 +1102,9 @@ FormFieldSignature::SigningResult 
FormFieldSignature::sign(const QString 
 const auto gSignatureText = 
std::unique_ptr(QStringToUnicodeGooString(data.signatureText()));
 const auto gSignatureLeftText =