Hi all,

Svetlana rised interest in an xpdf update.

I was able to tweak the build system decently, so the target builds and links! That's a first big step I was unable to achieve at my last attempt.

I committed the new sources to the GAP repository.

To actually build with them, you need to use the attached patch.

Some APIs changed. There are C++ Bridge classes between Objective-C and C++; I have updated them to the best of my knowledge: however the Font management is a major change I wasn't able to update.

Does someone has a clue on how to improve that? Stefan?

PDFKit will now sometimes display pages, with graphics but with no text: I guess that's caused by the font changes.

Cheers,

Riccardo

Index: PDFDocument.m
===================================================================
--- PDFDocument.m	(revision 3309)
+++ PDFDocument.m	(working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003  Stefan Kleine Stegemann
- *           (C) 2013  The GNUstep Application Team
+ *           (C) 2013-2016  The GNUstep Application Team
  *
  * Authors: Stefan Kleine Stegemann
  *          Riccardo Mottola
@@ -287,6 +287,7 @@
                            [aText cString],
                            pageNum,
                            maxPage,
+                           0,
                            &xMin,
                            &yMin,
                            &xMax,
Index: configure
===================================================================
--- configure	(revision 3309)
+++ configure	(working copy)
@@ -3102,7 +3102,7 @@
 
 
 
-ac_config_files="$ac_config_files GNUmakefile xpdf/GNUmakefile xpdf/bridge/GNUmakefile xpdf/xpdf-3.02/GNUmakefile"
+ac_config_files="$ac_config_files GNUmakefile xpdf/GNUmakefile xpdf/bridge/GNUmakefile xpdf/xpdf-3.04/GNUmakefile"
 
 
 cat >confcache <<\_ACEOF
Index: configure.ac
===================================================================
--- configure.ac	(revision 3309)
+++ configure.ac	(working copy)
@@ -107,7 +107,7 @@
 AC_SUBST(lib_freetype_includes)
 AC_SUBST(lib_freetype_add_includes)
 
-AC_CONFIG_FILES([GNUmakefile xpdf/GNUmakefile xpdf/bridge/GNUmakefile xpdf/xpdf-3.02/GNUmakefile])
+AC_CONFIG_FILES([GNUmakefile xpdf/GNUmakefile xpdf/bridge/GNUmakefile xpdf/xpdf-3.04/GNUmakefile])
 
 AC_OUTPUT
 
Index: xpdf/bridge/XPDFBridge.cc
===================================================================
--- xpdf/bridge/XPDFBridge.cc	(revision 3309)
+++ xpdf/bridge/XPDFBridge.cc	(working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003  Stefan Kleine Stegemann
- *               2012-2013 GNUstep Aplication Project
+ *               2012-2016 GNUstep Application Project
  *
  * Authors: Stefan Kleine Stegemann
  *          Riccardo Mottola
@@ -162,6 +162,7 @@
 
 SearchContext* PDFSearch_CreateSearchContext(XPDFObject pdfDoc)
 {
+  TextOutputControl *toControl;
    SearchContext* theContext = (SearchContext*)calloc(1, sizeof(SearchContext));
    if (!theContext)
    {
@@ -170,9 +171,11 @@
       return NULL;
    }
 
+   toControl = new TextOutputControl();
+   toControl->mode = textOutPhysLayout;
    theContext->pdfDoc = pdfDoc;
    theContext->currentPage = -1;
-   theContext->textOutputDevice = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
+   theContext->textOutputDevice = new TextOutputDev(NULL, toControl, gFalse);
 
    if (!static_cast<TextOutputDev*>(theContext->textOutputDevice)->isOk())
    {
@@ -181,7 +184,7 @@
       PDFSearch_DestroySearchContext(theContext);
       return NULL;
    }
-
+   delete toControl;
    return theContext;
 }
 
@@ -206,6 +209,7 @@
                        const char* text,
                        int* pageA,
                        int toPage,
+                       short wholeWord,
                        double *xMin,
                        double* yMin,
                        double* xMax,
@@ -226,7 +230,12 @@
    int found = 0;
    int startPage = *pageA;
    GBool top;
+   GBool wholeWordBool;
 
+   wholeWordBool = gFalse;
+   if (wholeWord)
+     wholeWordBool = gTrue;
+
    TextOutputDev* textOut = static_cast<TextOutputDev*>(aSearchContext->textOutputDevice);
    if (!textOut->isOk())
    {
@@ -271,12 +280,12 @@
       if (page == startPage)
       {
          found =
-            textOut->findText(u, len, top, gTrue, gFalse, gFalse, gFalse, gFalse, xMin, yMin, xMax, yMax);
+           textOut->findText(u, len, top, gTrue, gFalse, gFalse, gFalse, gFalse, wholeWordBool, xMin, yMin, xMax, yMax);
       }
       else
       {
          found =
-            textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, gFalse, gFalse, xMin, yMin, xMax, yMax);
+           textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, gFalse, gFalse, wholeWordBool, xMin, yMin, xMax, yMax);
       }
 
       if (found)
@@ -301,12 +310,12 @@
          if (page == startPage)
          {
             found =
-               textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, gFalse, gFalse, xMin, yMin, xMax, yMax);
+              textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse, gFalse, gFalse, wholeWordBool, xMin, yMin, xMax, yMax);
          }
          else
          {
             found =
-               textOut->findText(u, len, gTrue, gFalse, gFalse, gFalse, gFalse, gFalse, xMin, yMin, xMax, yMax);
+              textOut->findText(u, len, gTrue, gFalse, gFalse, gFalse, gFalse, gFalse, wholeWordBool, xMin, yMin, xMax, yMax);
          }
 
          if (found)
@@ -377,11 +386,15 @@
 {
   PDFDoc *doc = TO_PDFDoc(pdfDoc);
   TextOutputDev *textOut;
+  TextOutputControl *toControl;
   int got = 1;
+
+  toControl = new TextOutputControl();
+  toControl->mode = textOutPhysLayout;
   
   XPDF_AcquireLock();
 
-  textOut = new TextOutputDev((TextOutputFunc)func, (void *)1, gFalse, gFalse);
+  textOut = new TextOutputDev((TextOutputFunc)func, (void *)1, toControl);
 
   if (textOut->isOk()) {
     doc->displayPages(textOut, 1, doc->getNumPages(), 72, 72, 0,
@@ -390,7 +403,8 @@
     got = 0;
   }
   
-  delete textOut; 
+  delete textOut;
+  delete toControl;
   XPDF_ReleaseLock();
   
   return got;  
@@ -405,11 +419,14 @@
                      char** textA,
                      int* length)
 {
+   TextOutputControl *toControl;
    XPDF_AcquireLock();
 
    PDFDoc* doc = TO_PDFDoc(pdfDoc);
+   toControl = new TextOutputControl();
+   toControl->mode = textOutPhysLayout;
 
-   TextOutputDev* textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
+   TextOutputDev* textOut = new TextOutputDev(NULL, toControl, gFalse);
    if (!textOut->isOk())
    {
       delete textOut;
@@ -436,6 +453,7 @@
    }
 
    delete textOut;
+   delete toControl;
 
    XPDF_ReleaseLock();
 }
@@ -616,6 +634,7 @@
                             const char* fontFile,
                             DisplayFontType type)
 {
+  /* FIXME how to replace this ?
    DisplayFontParam* dfp;
 
    dfp = new DisplayFontParam(new GString(fontName),
@@ -641,6 +660,7 @@
    }
 
    globalParams->addDisplayFont(dfp);
+  */
 }
 
 
@@ -648,6 +668,7 @@
                             const char** fontFile,
                             DisplayFontType* type)
 {
+  /* FIXME how to replace this ?
    DisplayFontParam* dfp;
 
    *fontFile = NULL;
@@ -671,6 +692,7 @@
          }
       }
    }
+  */
 }
 
 
@@ -775,7 +797,7 @@
 #define TO_PSOutputDev(object) (static_cast<PSOutputDev*>(object))
 
 
-void OutputPS(void* stream, char* data, int len)
+void OutputPS(void* stream, const char* data, int len)
 {
    char* buffer = (char*)malloc((len + 1) * sizeof(char));
    memcpy(buffer, data, len);
@@ -791,8 +813,7 @@
 {
    PSOutputDev* psDev = new PSOutputDev(OutputPS,
                                         NULL,
-                                        TO_PDFDoc(pdfDoc)->getXRef(),
-                                        TO_PDFDoc(pdfDoc)->getCatalog(),
+                                        TO_PDFDoc(pdfDoc),
                                         firstPage,
                                         lastPage,
                                         psModePS);
Index: xpdf/bridge/XPDFBridge.h
===================================================================
--- xpdf/bridge/XPDFBridge.h	(revision 3309)
+++ xpdf/bridge/XPDFBridge.h	(working copy)
@@ -1,6 +1,10 @@
 /*
  * Copyright (C) 2003  Stefan Kleine Stegemann
+ *               2016 GNUstep Application Project
  *
+ * Authors: Stefan Kleine Stegemann
+ *          Riccardo Mottola
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -128,6 +132,7 @@
                        const char* text,
                        int* pageA,
                        int toPage,
+                       short wholeWord,
                        double *xMin,
                        double* yMin,
                        double* xMax,
Index: xpdf-src
===================================================================
--- xpdf-src	(revision 3309)
+++ xpdf-src	(working copy)
@@ -1,2 +1,2 @@
 # which xpdf sources should be used?
-XPDF_SRC=xpdf-3.02
+XPDF_SRC=xpdf-3.04
_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to