HI,
Please don't consider the srinivas_poppler3.patch from the previous mail.
I attached it here.
Thanks
--
A Srinivas
On Mon, Jul 5, 2010 at 3:33 PM, <[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. 2 commits - glib/poppler-attachment.cc
> glib/poppler-document.cc glib/poppler-features.h.in
> glib/poppler-media.cc glib/poppler-page.cc (Carlos Garcia Campos)
> 2. Patch to Get PDF ID (srinivas adicherla)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 5 Jul 2010 02:17:21 -0700 (PDT)
> From: [email protected] (Carlos Garcia Campos)
> Subject: [poppler] 2 commits - glib/poppler-attachment.cc
> glib/poppler-document.cc glib/poppler-features.h.in
> glib/poppler-media.cc glib/poppler-page.cc
> To: [email protected]
> Message-ID: <[email protected]>
>
> glib/poppler-attachment.cc | 4 ++--
> glib/poppler-document.cc | 12 ++++++------
> glib/poppler-features.h.in | 6 ++++--
> glib/poppler-media.cc | 4 ++--
> glib/poppler-page.cc | 4 ++--
> 5 files changed, 16 insertions(+), 14 deletions(-)
>
> New commits:
> commit 092aa901b9ec35a48bc1fb229ad16a3b00eef5f2
> Author: Carlos Garcia Campos <[email protected]>
> Date: Mon Jul 5 11:16:49 2010 +0200
>
> [glib] docs: add some more introspection annotations
>
> diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
> index 6ff20b2..d3281ba 100644
> --- a/glib/poppler-attachment.cc
> +++ b/glib/poppler-attachment.cc
> @@ -157,7 +157,7 @@ save_helper (const gchar *buf,
> * poppler_attachment_save:
> * @attachment: A #PopplerAttachment.
> * @filename: name of file to save
> - * @error: return location for error, or %NULL.
> + * @error: (allow-none): return location for error, or %NULL.
> *
> * Saves @attachment to a file indicated by @filename. If @error is set,
> %FALSE
> * will be returned. Possible errors include those in the #G_FILE_ERROR
> domain
> @@ -215,7 +215,7 @@ poppler_attachment_save (PopplerAttachment
> *attachment,
> * @attachment: A #PopplerAttachment.
> * @save_func: a function that is called to save each block of data that
> the save routine generates.
> * @user_data: user data to pass to the save function.
> - * @error: return location for error, or %NULL.
> + * @error: (allow-none): return location for error, or %NULL.
> *
> * Saves @attachment by feeding the produced data to @save_func. Can be
> used
> * when you want to store the attachment to something other than a file,
> such as
> diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
> index c013e25..288bf11 100644
> --- a/glib/poppler-document.cc
> +++ b/glib/poppler-document.cc
> @@ -133,8 +133,8 @@ _poppler_document_new_from_pdfdoc (PDFDoc *newDoc,
> /**
> * poppler_document_new_from_file:
> * @uri: uri of the file to load
> - * @password: password to unlock the file with, or %NULL
> - * @error: Return location for an error, or %NULL
> + * @password: (allow-none): password to unlock the file with, or %NULL
> + * @error: (allow-none): Return location for an error, or %NULL
> *
> * Creates a new #PopplerDocument. If %NULL is returned, then @error will
> be
> * set. Possible errors include those in the #POPPLER_ERROR and
> #G_FILE_ERROR
> @@ -205,8 +205,8 @@ poppler_document_new_from_file (const char *uri,
> * poppler_document_new_from_data:
> * @data: the pdf data contained in a char array
> * @length: the length of #data
> - * @password: password to unlock the file with, or %NULL
> - * @error: Return location for an error, or %NULL
> + * @password: (allow-none): password to unlock the file with, or %NULL
> + * @error: (allow-none): Return location for an error, or %NULL
> *
> * Creates a new #PopplerDocument. If %NULL is returned, then @error will
> be
> * set. Possible errors include those in the #POPPLER_ERROR and
> #G_FILE_ERROR
> @@ -274,7 +274,7 @@ handle_save_error (int err_code,
> * poppler_document_save:
> * @document: a #PopplerDocument
> * @uri: uri of file to save
> - * @error: return location for an error, or %NULL
> + * @error: (allow-none): return location for an error, or %NULL
> *
> * Saves @document. Any change made in the document such as
> * form fields filled by the user will be saved.
> @@ -311,7 +311,7 @@ poppler_document_save (PopplerDocument *document,
> * poppler_document_save_a_copy:
> * @document: a #PopplerDocument
> * @uri: uri of file to save
> - * @error: return location for an error, or %NULL
> + * @error: (allow-none): return location for an error, or %NULL
> *
> * Saves a copy of the original @document.
> * Any change made in the document such as
> diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc
> index ab2270a..a909dde 100644
> --- a/glib/poppler-media.cc
> +++ b/glib/poppler-media.cc
> @@ -195,7 +195,7 @@ save_helper (const gchar *buf,
> * poppler_media_save:
> * @poppler_media: a #PopplerMedia
> * @filename: name of file to save
> - * @error: return location for error, or %NULL.
> + * @error: (allow-none): return location for error, or %NULL.
> *
> * Saves embedded stream of @poppler_media to a file indicated by
> @filename.
> * If @error is set, %FALSE will be returned.
> @@ -257,7 +257,7 @@ poppler_media_save (PopplerMedia *poppler_media,
> * @poppler_media: a #PopplerMedia
> * @save_func: a function that is called to save each block of data that
> the save routine generates.
> * @user_data: user data to pass to the save function.
> - * @error: return location for error, or %NULL.
> + * @error: (allow-none): return location for error, or %NULL.
> *
> * Saves embedded stream of @poppler_media by feeding the produced data to
> @save_func. Can be used
> * when you want to store the media clip stream to something other than a
> file, such as
> diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
> index b96a755..031edc7 100644
> --- a/glib/poppler-page.cc
> +++ b/glib/poppler-page.cc
> @@ -84,8 +84,8 @@ poppler_page_finalize (GObject *object)
> /**
> * poppler_page_get_size:
> * @page: A #PopplerPage
> - * @width: return location for the width of @page
> - * @height: return location for the height of @page
> + * @width: (allow-none): return location for the width of @page
> + * @height: (allow-none): return location for the height of @page
> *
> * Gets the size of @page at the current scale and rotation.
> **/
> commit 6c4e14fd90d5ef2d6670a980ab2476b6fab58df7
> Author: Carlos Garcia Campos <[email protected]>
> Date: Mon Jul 5 10:49:59 2010 +0200
>
> [glib] docs: fix POPPLER_CHECK_VERSION() docs
>
> diff --git a/glib/poppler-features.h.in b/glib/poppler-features.h.in
> index 6ac0971..4cd37cd 100644
> --- a/glib/poppler-features.h.in
> +++ b/glib/poppler-features.h.in
> @@ -79,8 +79,10 @@
> * @minor: minor version (e.g. 1 for version 0.1.2)
> * @micro: micro version (e.g. 2 for version 0.1.2)
> *
> - * Returns %TRUE if the version of the poppler header files is the same
> - * as or newer than the passed-in version.
> + * Checks the version fo the poppler library
> + *
> + * Returns: %TRUE if the version of the poppler header files is the same
> + * as or newer than the passed-in version
> *
> * Since: 0.12
> */
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 5 Jul 2010 15:33:53 +0530
> From: srinivas adicherla <[email protected]>
> Subject: [poppler] Patch to Get PDF ID
> To: [email protected]
> Message-ID:
> <[email protected]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> By considering valuable suggestions from all, I created 3 patches to get
> the ID from the PDF document.
>
> All patches do the same. But the implementation has different. I request
> all
> to give suggestions that which is the good way, and if there is any other
> better way
> please let me know.
>
> Explanation:
>
> patch1:
> Here I wrote getPermanentID() & getUpdateID() seperate functions.
> I called these from poppler-glib to get the entire ID and return the
> structure PopplerDocumentId.
> But here the repetetion of the code for getting "ID" object from
> trailer dictionary and check the conditions. To elimante that,
>
> pathc2:
> I wrote one more function getID(GooString *id, int index) in
> PDFDoc.cc, and calling this from getPermanentID() and getUpdateID(), by
> passing appropriate index.
> To eliminate this index thing,
>
> patch3:
> I declare one enum PDFID
> {
> permanentID,
> updateID
> }
> and remove getPermanentID() and getUpdateID() functions.
> Added getID(GooString *id, PDFID idType)
>
> Iam not at good in giving names to variable & functions. Please give me
> suggestions.
>
> Please let me know when you commit this patch. If any of the patch is
> considered from the above.
>
> Thanks
> --
> A Srinivas
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.freedesktop.org/archives/poppler/attachments/20100705/b8b77fd4/attachment.html
> >
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: srinivas_poppler1.patch
> Type: text/x-patch
> Size: 8781 bytes
> Desc: not available
> URL: <
> http://lists.freedesktop.org/archives/poppler/attachments/20100705/b8b77fd4/attachment.bin
> >
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: srinivas_poppler2.patch
> Type: text/x-patch
> Size: 8294 bytes
> Desc: not available
> URL: <
> http://lists.freedesktop.org/archives/poppler/attachments/20100705/b8b77fd4/attachment-0001.bin
> >
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: srinivas_poppler3.patch
> Type: text/x-patch
> Size: 8413 bytes
> Desc: not available
> URL: <
> http://lists.freedesktop.org/archives/poppler/attachments/20100705/b8b77fd4/attachment-0002.bin
> >
>
> ------------------------------
>
> _______________________________________________
> poppler mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/poppler
>
>
> End of poppler Digest, Vol 65, Issue 8
> **************************************
>
Index: poppler-0.14.0/poppler/PDFDoc.h
===================================================================
--- poppler-0.14.0/poppler/PDFDoc.h (revision 3)
+++ poppler-0.14.0/poppler/PDFDoc.h (working copy)
@@ -55,6 +55,11 @@
writeForceIncremental
};
+enum PDFID {
+ permanentID,
+ updateID
+};
+
//------------------------------------------------------------------------
// PDFDoc
//------------------------------------------------------------------------
@@ -206,6 +211,9 @@
int getPDFMajorVersion() { return pdfMajorVersion; }
int getPDFMinorVersion() { return pdfMinorVersion; }
+ //Return the PDF ID in the trailer dictionary (if any).
+ GBool getID(GooString *id, PDFID idType);
+
// 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 3)
+++ poppler-0.14.0/poppler/PDFDoc.cc (working copy)
@@ -70,6 +70,7 @@
#define headerSearchSize 1024 // read this many bytes at beginning of
// file to look for '%PDF'
+#define pdfIdLength 32 // PDF Document IDs (PermanentId, UpdateId) length
//------------------------------------------------------------------------
// PDFDoc
@@ -445,6 +446,51 @@
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 *id, PDFID idType) {
+ char tmpid[pdfIdLength+1];
+ Object obj;
+ xref->getTrailerDict()->dictLookup ("ID", &obj);
+
+ if (!obj.isArray())
+ {
+ obj.free();
+ return false;
+ } else if (obj.arrayGetLength() != 2) { // security check
+ return false;
+ }
+
+ Object val;
+ if (idType == permanentID) {
+ obj.arrayGet(0, &val);
+ } else if(idType == updateID) {
+ obj.arrayGet(1, &val);
+ } else
+ return false;
+
+ obj.free();
+
+ if (val.isString()) {
+ GooString *temp;
+ temp = val.getString();
+ if (temp->getLength() != 16) { // security check
+ return false;
+ } else {
+ get_id (temp->getCString(), tmpid);
+ id->Set (tmpid, pdfIdLength);
+ }
+ } else {
+ return false;
+ }
+
+ val.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 3)
+++ 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 3)
+++ 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);
@@ -647,7 +649,8 @@
Catalog *catalog;
gchar *str;
guint flag;
-
+ GooString permanent_id, update_id;
+
switch (prop_id)
{
case PROP_TITLE:
@@ -762,6 +765,14 @@
}
}
break;
+ case PROP_PERMANENT_ID:
+ if (document->doc->getID (&permanent_id, permanentID))
+ g_value_set_string (value, permanent_id.getCString());
+ break;
+ case PROP_UPDATE_ID:
+ if (document->doc->getID (&update_id, updateID))
+ g_value_set_string (value, update_id.getCString());
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -931,6 +942,25 @@
"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 +1958,83 @@
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. This must be freed with
+ * poppler_document_id_free().
+ *
+ * Return value: a new #PopplerDocumentId
+ **/
+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 *documentid)
+{
+ GooString permanent_id,update_id;
+ if (document->doc->getID (&permanent_id, permanentID) &&
+ document->doc->getID (&update_id, updateID)) {
+ g_stpcpy(documentid->permanent_id,permanent_id.getCString());
+ g_stpcpy(documentid->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 3)
+++ poppler-0.14.0/glib/poppler-document.h (working copy)
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include "poppler.h"
+#define DOC_ID_LENGTH 33 // 32 bytes for each of the PDF ID (Permanent Id , Update Id) length, and 1 byte for '\0'
+
G_BEGIN_DECLS
#define POPPLER_TYPE_DOCUMENT (poppler_document_get_type ())
@@ -89,6 +91,11 @@
} PopplerPermissions;
+struct _PopplerDocumentId
+{
+ gchar permanent_id[DOCUMENT_ID_LENGTH];
+ gchar update_id[DOCUMENT_ID_LENGTH];
+};
GType poppler_document_get_type (void) G_GNUC_CONST;
@@ -122,6 +129,15 @@
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 *documentid);
+
/* Interface for getting the Index of a poppler_document */
#define POPPLER_TYPE_INDEX_ITER (poppler_index_iter_get_type ())
GType poppler_index_iter_get_type (void) G_GNUC_CONST;
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler