[Poppler-bugs] [Bug 36653] Missing functions for setting document's properties

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Apr 28 08:27:52 PDT 2011


https://bugs.freedesktop.org/show_bug.cgi?id=36653

--- Comment #2 from Carlos Garcia Campos <carlosgc at gnome.org> 2011-04-28 08:27:52 PDT ---
(From update of attachment 46136)
Hey rodrigo, patch looks goot to me. Common parts should be in the core, so
that other frontends could use them too. Frontends currently get the info dict
directly, so it's probably a good time to add a PDFInfo class in the core with
setters and getters. See comments inline.

>From 3ce14bcbf198fc93365d664b0db5745680967764 Mon Sep 17 00:00:00 2001
>From: Rodrigo Moya <rodrigo at gnome-db.org>
>Date: Thu, 28 Apr 2011 10:24:05 +0200
>Subject: [PATCH] glib: Add _set functions for some PopplerDocument properties
>
>---
> glib/poppler-document.cc |  154 ++++++++++++++++++++++++++++++++++++++++++++++
> glib/poppler-document.h  |    6 ++
> 2 files changed, 160 insertions(+), 0 deletions(-)
>
>diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
>index 710a5b3..360aa42 100644
>--- a/glib/poppler-document.cc
>+++ b/glib/poppler-document.cc
>@@ -607,6 +607,46 @@ char *_poppler_goo_string_to_utf8(GooString *s)
>   return result;
> }
> 
>+GooString *_poppler_goo_string_from_utf8(const gchar *source)
>+{
>+  char *s, *utf8;
>+  gsize bytes_written;
>+  GooString *result;
>+
>+  utf8 = g_locale_to_utf8 (source, strlen (source), NULL, &bytes_written, NULL);

you shouldn't need this, we assume all strings used by the poppler-glib api are
always utf-8, like glib/gtk+.

>+  s = g_convert (utf8, bytes_written,
>+		 "UTF-16BE", "UTF-8", NULL, &bytes_written, NULL);
>+  
>+  result = new GooString (s, bytes_written);

that's the only part that should be in the glib forntend

>+  if (!result->hasUnicodeMarker()) {
>+    result->insert(0, 0xff);
>+    result->insert(0, 0xfe);
>+  }

This should be in the core.

>+  g_free (s);
>+  g_free (utf8);
>+
>+  return result;
>+}
>+
>+static gboolean
>+mark_as_modified (PopplerDocument *document, Object *obj)
>+{
>+  gboolean result = FALSE;
>+  XRef *xref;
>+  Object info_dict;
>+
>+  xref = document->doc->getXRef ();
>+  if (xref != NULL) {
>+    xref->getDocInfoNF (&info_dict);
>+    xref->setModifiedObject (obj, info_dict.getRef ());

info_dict should be freed here with info_dict.free();

>+    result = TRUE;
>+  }
>+
>+  return result;
>+}

This method should be part fo the core too.

> static gchar *
> info_dict_get_string (Dict *info_dict, const gchar *key)
> {
>@@ -763,6 +803,44 @@ poppler_document_get_title (PopplerDocument *document)
> }
> 

if we add the PDFDocInfo class, all get/set methods would simply use that
class.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Poppler-bugs mailing list