Hi,

Thanks for the comments.  I made those changes and here's the updated patch.

Cheers,
Jason

p.s. I'm subscribed to the list, but I never got your response (I found the 
response in the archives).  Not sure what the deal is.

>/ Hi all,
/
hi Jason, 

>/ Here's a patch against CVS to allow the glib wrapper to access PDF XML
/>/ metadata.  It simply adds a new QObject property and reads the
/>/ metadata
/>/ with Catalog::readMetadata()->toCString().
/>/ 
/>/ Having this functionality would really be handy for me.
/
some comments about your patch below. 

>/ Cheers,
/>/ Jason
/>/ 
/>/  
/>/  typedef struct _PopplerDocumentClass PopplerDocumentClass;
/>/ @@ -691,6 +692,14 @@
/>/         flag |= POPPLER_PERMISSIONS_OK_TO_ADD_NOTES;
/>/        g_value_set_flags (value, flag);
/>/        break;
/>/ +    case PROP_METADATA:
/>/ +      catalog = document->doc->getCatalog ();
/>/ +      if (catalog && catalog->isOk ())
/>/ +       {
/>/ +         GooString *s = catalog->readMetadata ();
/>/ +         g_value_set_string (value, s->getCString());
/
readMetada could return NULL, so you should check it before using
s->getCString(). In addition, readMetadata returns a new allocated
GooString, so it should be freed here, just after using it. 

>/ +       }
/>/ +      break;
/>/      default:
/>/        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
/>/      }/

Index: glib/poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
retrieving revision 1.42
diff -u -r1.42 poppler-document.cc
--- glib/poppler-document.cc	25 Apr 2007 19:59:10 -0000	1.42
+++ glib/poppler-document.cc	12 Jun 2007 23:43:27 -0000
@@ -50,6 +50,7 @@
 	PROP_PAGE_MODE,
 	PROP_VIEWER_PREFERENCES,
 	PROP_PERMISSIONS,
+	PROP_METADATA,
 };
 
 typedef struct _PopplerDocumentClass PopplerDocumentClass;
@@ -691,6 +692,17 @@
 	flag |= POPPLER_PERMISSIONS_OK_TO_ADD_NOTES;
       g_value_set_flags (value, flag);
       break;
+    case PROP_METADATA:
+      catalog = document->doc->getCatalog ();
+      if (catalog && catalog->isOk ())
+	{
+	  GooString *s = catalog->readMetadata ();
+	  if ( s != NULL ) {
+	  	g_value_set_string (value, s->getCString());
+	  	delete s;
+	  }
+	}
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -833,6 +845,15 @@
 			       POPPLER_TYPE_PERMISSIONS,
 			       POPPLER_PERMISSIONS_FULL,
 			       G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_METADATA,
+	   g_param_spec_string ("metadata",
+				"XML Metadata",
+				"Embedded XML metadata",
+				NULL,
+				G_PARAM_READABLE));
 }
 
 static void
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to