Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/f0af2265fff4a451ed98ff90fdbe22c3b40dd173
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/f0af2265fff4a451ed98ff90fdbe22c3b40dd173
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/f0af2265fff4a451ed98ff90fdbe22c3b40dd173

The branch, vince/pdf has been updated
       via  f0af2265fff4a451ed98ff90fdbe22c3b40dd173 (commit)
       via  bbb144bcbd8545948cea2ec1973c8203e0b07906 (commit)
      from  0d486a1ffe457478d4303ebc72fc000b853bfcb3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=f0af2265fff4a451ed98ff90fdbe22c3b40dd173
commit f0af2265fff4a451ed98ff90fdbe22c3b40dd173
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    set the pdf title if available

diff --git a/content/handlers/pdf/pdf.c b/content/handlers/pdf/pdf.c
index 657a5e9..288aa58 100644
--- a/content/handlers/pdf/pdf.c
+++ b/content/handlers/pdf/pdf.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 
 #include <nspdf/document.h>
+#include <nspdf/meta.h>
 
 #include "utils/utils.h"
 #include "content/llcache.h"
@@ -117,6 +118,7 @@ static bool pdf_convert(struct content *c)
        nspdferror pdfres;
        const uint8_t *content_data;
        unsigned long content_length;
+       struct lwc_string_s *title;
 
        content_data = (const uint8_t *)content__get_source_data(c,
                                                &content_length);
@@ -129,8 +131,14 @@ static bool pdf_convert(struct content *c)
                return false;
        }
 
+       pdfres = nspdf_get_title(pdfc->doc, &title);
+       if (pdfres == NSPDFERROR_OK) {
+               content__set_title(c, lwc_string_data(title));
+       }
+
        content_set_ready(c);
        content_set_done(c);
+
        return true;
 }
 


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=bbb144bcbd8545948cea2ec1973c8203e0b07906
commit bbb144bcbd8545948cea2ec1973c8203e0b07906
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    use nspdf library to parse document

diff --git a/content/handlers/pdf/pdf.c b/content/handlers/pdf/pdf.c
index 23457a2..657a5e9 100644
--- a/content/handlers/pdf/pdf.c
+++ b/content/handlers/pdf/pdf.c
@@ -27,12 +27,39 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
+#include <nspdf/document.h>
+
 #include "utils/utils.h"
 #include "content/llcache.h"
 #include "content/content_protected.h"
 
 #include "pdf.h"
 
+typedef struct pdf_content {
+       struct content base;
+
+       struct nspdf_doc *doc;
+} pdf_content;
+
+static nserror nspdf2nserr(nspdferror nspdferr)
+{
+       nserror res;
+       switch (nspdferr) {
+       case NSPDFERROR_OK:
+               res = NSERROR_OK;
+               break;
+
+       case NSPDFERROR_NOMEM:
+               res = NSERROR_NOMEM;
+               break;
+
+       default:
+               res = NSERROR_UNKNOWN;
+               break;
+       }
+       return res;
+}
+
 /**
  * Content create entry point.
  */
@@ -45,32 +72,63 @@ pdf_create(const content_handler *handler,
           bool quirks,
           struct content **c)
 {
-       struct content *jpeg;
-       nserror error;
+       struct pdf_content *pdfc;
+       nserror res;
+       nspdferror pdfres;
 
-       jpeg = calloc(1, sizeof(struct content));
-       if (jpeg == NULL)
+       pdfc = calloc(1, sizeof(struct pdf_content));
+       if (pdfc == NULL) {
                return NSERROR_NOMEM;
+       }
+
+       res = content__init(&pdfc->base,
+                           handler,
+                           imime_type,
+                           params,
+                           llcache,
+                           fallback_charset,
+                           quirks);
+       if (res != NSERROR_OK) {
+               free(pdfc);
+               return res;
+       }
 
-       error = content__init(jpeg, handler, imime_type, params,
-                             llcache, fallback_charset, quirks);
-       if (error != NSERROR_OK) {
-               free(jpeg);
-               return error;
+       pdfres = nspdf_document_create(&pdfc->doc);
+       if (pdfres != NSPDFERROR_OK) {
+               free(pdfc);
+               return nspdf2nserr(res);
        }
 
-       *c = jpeg;
+       *c = (struct content *)pdfc;
 
        return NSERROR_OK;
 }
 
 /* exported interface documented in image_cache.h */
-static void pdf_destroy(struct content *content)
+static void pdf_destroy(struct content *c)
 {
+       struct pdf_content *pdfc = (struct pdf_content *)c;
+       nspdf_document_destroy(pdfc->doc);
 }
 
 static bool pdf_convert(struct content *c)
 {
+       struct pdf_content *pdfc = (struct pdf_content *)c;
+       nspdferror pdfres;
+       const uint8_t *content_data;
+       unsigned long content_length;
+
+       content_data = (const uint8_t *)content__get_source_data(c,
+                                               &content_length);
+
+       pdfres = nspdf_document_parse(pdfc->doc,
+                                     content_data,
+                                     content_length);
+       if (pdfres != NSPDFERROR_OK) {
+               content_broadcast_errorcode(c, NSERROR_INVALID);
+               return false;
+       }
+
        content_set_ready(c);
        content_set_done(c);
        return true;


-----------------------------------------------------------------------

Summary of changes:
 content/handlers/pdf/pdf.c |   88 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 77 insertions(+), 11 deletions(-)

diff --git a/content/handlers/pdf/pdf.c b/content/handlers/pdf/pdf.c
index 23457a2..288aa58 100644
--- a/content/handlers/pdf/pdf.c
+++ b/content/handlers/pdf/pdf.c
@@ -27,12 +27,40 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
+#include <nspdf/document.h>
+#include <nspdf/meta.h>
+
 #include "utils/utils.h"
 #include "content/llcache.h"
 #include "content/content_protected.h"
 
 #include "pdf.h"
 
+typedef struct pdf_content {
+       struct content base;
+
+       struct nspdf_doc *doc;
+} pdf_content;
+
+static nserror nspdf2nserr(nspdferror nspdferr)
+{
+       nserror res;
+       switch (nspdferr) {
+       case NSPDFERROR_OK:
+               res = NSERROR_OK;
+               break;
+
+       case NSPDFERROR_NOMEM:
+               res = NSERROR_NOMEM;
+               break;
+
+       default:
+               res = NSERROR_UNKNOWN;
+               break;
+       }
+       return res;
+}
+
 /**
  * Content create entry point.
  */
@@ -45,34 +73,72 @@ pdf_create(const content_handler *handler,
           bool quirks,
           struct content **c)
 {
-       struct content *jpeg;
-       nserror error;
+       struct pdf_content *pdfc;
+       nserror res;
+       nspdferror pdfres;
 
-       jpeg = calloc(1, sizeof(struct content));
-       if (jpeg == NULL)
+       pdfc = calloc(1, sizeof(struct pdf_content));
+       if (pdfc == NULL) {
                return NSERROR_NOMEM;
+       }
 
-       error = content__init(jpeg, handler, imime_type, params,
-                             llcache, fallback_charset, quirks);
-       if (error != NSERROR_OK) {
-               free(jpeg);
-               return error;
+       res = content__init(&pdfc->base,
+                           handler,
+                           imime_type,
+                           params,
+                           llcache,
+                           fallback_charset,
+                           quirks);
+       if (res != NSERROR_OK) {
+               free(pdfc);
+               return res;
        }
 
-       *c = jpeg;
+       pdfres = nspdf_document_create(&pdfc->doc);
+       if (pdfres != NSPDFERROR_OK) {
+               free(pdfc);
+               return nspdf2nserr(res);
+       }
+
+       *c = (struct content *)pdfc;
 
        return NSERROR_OK;
 }
 
 /* exported interface documented in image_cache.h */
-static void pdf_destroy(struct content *content)
+static void pdf_destroy(struct content *c)
 {
+       struct pdf_content *pdfc = (struct pdf_content *)c;
+       nspdf_document_destroy(pdfc->doc);
 }
 
 static bool pdf_convert(struct content *c)
 {
+       struct pdf_content *pdfc = (struct pdf_content *)c;
+       nspdferror pdfres;
+       const uint8_t *content_data;
+       unsigned long content_length;
+       struct lwc_string_s *title;
+
+       content_data = (const uint8_t *)content__get_source_data(c,
+                                               &content_length);
+
+       pdfres = nspdf_document_parse(pdfc->doc,
+                                     content_data,
+                                     content_length);
+       if (pdfres != NSPDFERROR_OK) {
+               content_broadcast_errorcode(c, NSERROR_INVALID);
+               return false;
+       }
+
+       pdfres = nspdf_get_title(pdfc->doc, &title);
+       if (pdfres == NSPDFERROR_OK) {
+               content__set_title(c, lwc_string_data(title));
+       }
+
        content_set_ready(c);
        content_set_done(c);
+
        return true;
 }
 


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to