Hi,

   Thank you all once again for giving me valuable suggestions. I modified
the previous patch. I attached the new patch with this mail.
Iam curiously waiting for to commit my patch.

Please let me know when you commit this patch.

Thanks
--
A Srinivas

On Wed, Jun 23, 2010 at 12:30 AM, <[email protected]>wrote:

> Send poppler mailing list submissions to
>        [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.freedesktop.org/mailman/listinfo/poppler
> or, via email, send a message with subject or body 'help' to
>        [email protected]
>
> You can reach the person managing the list at
>        [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of poppler digest..."
>
>
> Today's Topics:
>
>   1. poppler/GfxState.cc (Albert Astals Cid)
>   2. Branch 'poppler-0.14' - poppler/GfxState.cc (Albert Astals Cid)
>   3. Re: Patch go Get PDF ID (Albert Astals Cid)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 21 Jun 2010 12:38:22 -0700 (PDT)
> From: [email protected] (Albert Astals Cid)
> Subject: [poppler] poppler/GfxState.cc
> To: [email protected]
> Message-ID: <[email protected]>
>
>  poppler/GfxState.cc |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> New commits:
> commit 38e5d28a184d0ca8df71a7ea910ce85d7a225e4e
> Author: Albert Astals Cid <[email protected]>
> Date:   Mon Jun 21 20:38:00 2010 +0100
>
>    more pow 0.5 -> sqrt
>
> diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
> index 7140efc..fe3ee77 100644
> --- a/poppler/GfxState.cc
> +++ b/poppler/GfxState.cc
> @@ -672,9 +672,9 @@ void GfxCalGrayColorSpace::getRGB(GfxColor *color,
> GfxRGB *rgb) {
>   r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
>   g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
>   b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
> -  rgb->r = dblToCol(pow(clip01(r * kr), 0.5));
> -  rgb->g = dblToCol(pow(clip01(g * kg), 0.5));
> -  rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
> +  rgb->r = dblToCol(sqrt(clip01(r * kr)));
> +  rgb->g = dblToCol(sqrt(clip01(g * kg)));
> +  rgb->b = dblToCol(sqrt(clip01(b * kb)));
>   rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
>  }
>
> @@ -1246,9 +1246,9 @@ void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB
> *rgb) {
>   r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
>   g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
>   b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
> -  rgb->r = dblToCol(pow(clip01(r * kr), 0.5));
> -  rgb->g = dblToCol(pow(clip01(g * kg), 0.5));
> -  rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
> +  rgb->r = dblToCol(sqrt(clip01(r * kr)));
> +  rgb->g = dblToCol(sqrt(clip01(g * kg)));
> +  rgb->b = dblToCol(sqrt(clip01(b * kb)));
>  }
>
>  void GfxLabColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 21 Jun 2010 12:38:48 -0700 (PDT)
> From: [email protected] (Albert Astals Cid)
> Subject: [poppler] Branch 'poppler-0.14' - poppler/GfxState.cc
> To: [email protected]
> Message-ID: <[email protected]>
>
>  poppler/GfxState.cc |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> New commits:
> commit 714db8900b2f72bd63811a16bfb81beb23397bba
> Author: Albert Astals Cid <[email protected]>
> Date:   Mon Jun 21 20:38:00 2010 +0100
>
>    more pow 0.5 -> sqrt
>
> diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
> index 4f83e61..b59a478 100644
> --- a/poppler/GfxState.cc
> +++ b/poppler/GfxState.cc
> @@ -672,9 +672,9 @@ void GfxCalGrayColorSpace::getRGB(GfxColor *color,
> GfxRGB *rgb) {
>   r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
>   g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
>   b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
> -  rgb->r = dblToCol(pow(clip01(r * kr), 0.5));
> -  rgb->g = dblToCol(pow(clip01(g * kg), 0.5));
> -  rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
> +  rgb->r = dblToCol(sqrt(clip01(r * kr)));
> +  rgb->g = dblToCol(sqrt(clip01(g * kg)));
> +  rgb->b = dblToCol(sqrt(clip01(b * kb)));
>   rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
>  }
>
> @@ -1246,9 +1246,9 @@ void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB
> *rgb) {
>   r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
>   g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
>   b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
> -  rgb->r = dblToCol(pow(clip01(r * kr), 0.5));
> -  rgb->g = dblToCol(pow(clip01(g * kg), 0.5));
> -  rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
> +  rgb->r = dblToCol(sqrt(clip01(r * kr)));
> +  rgb->g = dblToCol(sqrt(clip01(g * kg)));
> +  rgb->b = dblToCol(sqrt(clip01(b * kb)));
>  }
>
>  void GfxLabColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 21 Jun 2010 23:50:22 +0100
> From: Albert Astals Cid <[email protected]>
> Subject: Re: [poppler] Patch go Get PDF ID
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: Text/Plain;  charset="us-ascii"
>
> A Dilluns, 21 de juny de 2010, srinivas adicherla va escriure:
> > Hi,
> >
> >     I made some changes to the recent patch. I removed the function
> > setID().
> >
> >
> >    Please let me know when you commit this patch.
> >
> > Thanks & regards
> > A Srinivas
>
> Hi, some minor comments, just for safety
>
> +  if (obj.isNull())
> +  {
> +    obj.free();
> +    return NULL;
> +  }
>
> should be
>
> +  if (!obj.isArray())
> +  {
> +    obj.free();
> +    return NULL;
> +  }
>
> And you should be checking that val1 and val2 are strings too before doing
> getString().
>
> And probably you want to call Set instead of append over permanent_id and
> update_id.
>
> Albert
>
>
> ------------------------------
>
> _______________________________________________
> poppler mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/poppler
>
>
> End of poppler Digest, Vol 64, Issue 38
> ***************************************
>
Index: poppler-0.14.0/poppler/PDFDoc.h
===================================================================
--- poppler-0.14.0/poppler/PDFDoc.h	(revision 210)
+++ poppler-0.14.0/poppler/PDFDoc.h	(working copy)
@@ -206,6 +206,9 @@
   int getPDFMajorVersion() { return pdfMajorVersion; }
   int getPDFMinorVersion() { return pdfMinorVersion; }
 
+  // Return the PDF ID in the trailer dictionary (if any).
+  GBool getID(GooString *permanent_id, GooString *update_id);
+
   // Save this file with another name.
   int saveAs(GooString *name, PDFWriteMode mode=writeStandard);
   // Save this file in the given output stream.
Index: poppler-0.14.0/poppler/PDFDoc.cc
===================================================================
--- poppler-0.14.0/poppler/PDFDoc.cc	(revision 210)
+++ poppler-0.14.0/poppler/PDFDoc.cc	(working copy)
@@ -445,6 +445,49 @@
   return lin;
 }
 
+static void
+get_id(char* encodedid,char *pdfid) {
+  sprintf(pdfid,"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", encodedid[0] & 0xff,encodedid[1] & 0xff,
+										   encodedid[2] & 0xff,encodedid[3] & 0xff,
+										   encodedid[4] & 0xff,encodedid[5] & 0xff,
+										   encodedid[6] & 0xff,encodedid[7] & 0xff,
+										   encodedid[8] & 0xff,encodedid[9] & 0xff,
+										   encodedid[10] & 0xff,encodedid[11] & 0xff,
+										   encodedid[12] & 0xff,encodedid[13] & 0xff,
+										   encodedid[14] & 0xff,encodedid[15] & 0xff);
+}
+
+GBool PDFDoc::getID(GooString *permanent_id,GooString *update_id) {
+
+  Object obj;
+  xref->getTrailerDict()->dictLookup("ID", &obj);
+
+  if (!obj.isArray())
+  {
+    obj.free();
+    return false;
+  }	
+
+  Object val1,val2;	
+  obj.arrayGet(0,&val1);
+  obj.arrayGet(1,&val2);
+  obj.free();
+
+  char tmpid[33];
+  if (val1.isString() && val2.isString()) {
+    get_id(val1.getString()->getCString(),tmpid);
+    permanent_id->Set(tmpid,32);
+    get_id(val2.getString()->getCString(),tmpid);
+    update_id->Set(tmpid,32);
+  } else {
+    return false;
+  }
+
+  val1.free();
+  val2.free();
+  return true;
+}
+
 int PDFDoc::saveAs(GooString *name, PDFWriteMode mode) {
   FILE *f;
   OutStream *outStr;
Index: poppler-0.14.0/glib/poppler.h
===================================================================
--- poppler-0.14.0/glib/poppler.h	(revision 210)
+++ poppler-0.14.0/glib/poppler.h	(working copy)
@@ -80,6 +80,7 @@
 } PopplerSelectionStyle;
 
 typedef struct _PopplerDocument            PopplerDocument;
+typedef struct _PopplerDocumentId	   PopplerDocumentId;
 typedef struct _PopplerIndexIter           PopplerIndexIter;
 typedef struct _PopplerFontsIter           PopplerFontsIter;
 typedef struct _PopplerLayersIter          PopplerLayersIter;
Index: poppler-0.14.0/glib/poppler-document.cc
===================================================================
--- poppler-0.14.0/glib/poppler-document.cc	(revision 210)
+++ poppler-0.14.0/glib/poppler-document.cc	(working copy)
@@ -54,7 +54,9 @@
 	PROP_PAGE_MODE,
 	PROP_VIEWER_PREFERENCES,
 	PROP_PERMISSIONS,
-	PROP_METADATA
+	PROP_METADATA,
+        PROP_PERMANENT_ID,
+	PROP_UPDATE_ID
 };
 
 static void poppler_document_layers_free (PopplerDocument *document);
@@ -762,6 +764,24 @@
 	  }
 	}
       break;
+    case PROP_PERMANENT_ID:
+      {
+        GooString permanent_id,update_id;
+	if (document->doc->getID(&permanent_id,&update_id))
+	{
+	  g_value_set_string(value,permanent_id.getCString());
+	}
+	break;
+      }
+    case PROP_UPDATE_ID:
+      {
+        GooString permanent_id,update_id;
+	if (document->doc->getID(&permanent_id,&update_id))
+	{
+	  g_value_set_string(value,update_id.getCString());
+	}
+	break;
+      }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -931,6 +951,22 @@
 				"Embedded XML metadata",
 				NULL,
 				G_PARAM_READABLE));
+   g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_PERMANENT_ID,
+	   g_param_spec_string ("permanent-id",
+				"Permanent Id",
+				"Permanent Id of the PDF Document",
+				NULL,
+				G_PARAM_READABLE));
+    g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_UPDATE_ID,
+	   g_param_spec_string ("update-id",
+				"Update Id",
+				"Update Id of the PDF Document",
+				NULL,
+				G_PARAM_READABLE));
 }
 
 static void
@@ -1928,7 +1964,81 @@
   return NULL;
 }
 
+/* PopplerDocumentId type */
+POPPLER_DEFINE_BOXED_TYPE (PopplerDocumentId, poppler_document_id,
+			   poppler_document_id_copy,
+			   poppler_document_id_free)
+
+/**
+ * poppler_document_id_new:
+ * 
+ * creates a new #PopplerDocumentId
+ *
+ **/
+PopplerDocumentId *
+poppler_document_id_new (void)
+{
+  return g_new0 (PopplerDocumentId, 1);
+}
+
+/**
+ * poppler_document_id_copy:
+ * @id: a #PopplerDocumentId
+ * 
+ * creates a new #PopplerDocumentId as a copy of @id, it must be freed 
+ * with poppler_document_id_free()
+ **/
+PopplerDocumentId *
+poppler_document_id_copy (PopplerDocumentId *id)
+{
+  PopplerDocumentId *new_id;
+
+  g_return_val_if_fail (id != NULL, NULL);
+  
+  new_id = g_new (PopplerDocumentId, 1);
+  *new_id = *id;
+
+  return new_id;
+}
+
+/**
+ * poppler_document_id_free:
+ * @id: a #PopplerDocumentId
+ * 
+ * Frees @id
+ * 
+ **/
+void
+poppler_document_id_free (PopplerDocumentId *id)
+{
+  g_free (id);
+}
+
+/**
+ * poppler_document_get_id: 	
+ * @document: a #PopplerDocument
+ * @documentid: a #PopplerDocumentId
+ *
+ * Returns true if the pdf file contains the ID
+ *
+ * Return value: a gboolean. %TRUE if document contains an ID else %FALSE
+ */
 gboolean
+poppler_document_get_id (PopplerDocument *document,PopplerDocumentId *id)
+{
+  GooString permanent_id,update_id;
+
+  if (document->doc->getID(&permanent_id,&update_id)) {
+    g_stpcpy(id->permanent_id,permanent_id.getCString());
+    g_stpcpy(id->update_id,update_id.getCString());
+
+    return TRUE;
+  } else {
+      return FALSE;	
+  }
+}
+
+gboolean
 _poppler_convert_pdf_date_to_gtime (GooString *date,
 				    time_t    *gdate) 
 {
Index: poppler-0.14.0/glib/poppler-document.h
===================================================================
--- poppler-0.14.0/glib/poppler-document.h	(revision 210)
+++ poppler-0.14.0/glib/poppler-document.h	(working copy)
@@ -89,8 +89,12 @@
 
 } PopplerPermissions;
 
+struct _PopplerDocumentId
+{
+  gchar permanent_id[33];
+  gchar update_id[33];
+};
 
-
 GType            poppler_document_get_type          (void) G_GNUC_CONST;
 PopplerDocument *poppler_document_new_from_file     (const char       *uri,
 						     const char       *password,
@@ -121,6 +125,13 @@
 /* Form */
 PopplerFormField *poppler_document_get_form_field   (PopplerDocument  *document,
 						     gint              id);
+/* Document Id */
+#define POPPLER_TYPE_DOCUMENT_ID               (poppler_document_id_get_type ())
+GType             poppler_document_id_get_type (void) G_GNUC_CONST;
+PopplerDocumentId *poppler_document_id_new     (void);
+PopplerDocumentId *poppler_document_id_copy    (PopplerDocumentId *id);
+void		  poppler_document_id_free     (PopplerDocumentId *id);	
+gboolean	  poppler_document_get_id      (PopplerDocument *document,PopplerDocumentId *id);
 
 /* Interface for getting the Index of a poppler_document */
 #define POPPLER_TYPE_INDEX_ITER                 (poppler_index_iter_get_type ())
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to