diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index 22acbd7..947b5c5 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -63,6 +63,10 @@
 int HtmlPage::pgNum=0;
 int HtmlOutputDev::imgNum=1;
 GooList *HtmlOutputDev::imgList=new GooList();
+GooList *HtmlOutputDev::imgTopList=new GooList();
+GooList *HtmlOutputDev::imgLeftList=new GooList();
+GooList *HtmlOutputDev::imgWidthList=new GooList();
+GooList *HtmlOutputDev::imgHeightList=new GooList();
 
 extern double scale;
 extern GBool complexMode;
@@ -646,8 +650,18 @@ void HtmlPage::dumpAsXML(FILE* f,int page){
   int listlen=HtmlOutputDev::imgList->getLength();
   for (int i = 0; i < listlen; i++) {
     GooString *fName= (GooString *)HtmlOutputDev::imgList->del(0);
-    fprintf(f,"<image>%s</image>\n",fName->getCString());
+    int *top = (int*)HtmlOutputDev::imgTopList->del(0);
+    int *left = (int*)HtmlOutputDev::imgLeftList->del(0);
+    int *width = (int*)HtmlOutputDev::imgWidthList->del(0);
+    int *height = (int*)HtmlOutputDev::imgHeightList->del(0);
+    fprintf(f,"<image top=\"%d\" left=\"%d\" width=\"%d\" height=\"%d\">%s</image>\n",
+            *top, *left, *width, *height,
+            fName->getCString());
     delete fName;
+    delete top;
+    delete left;
+    delete width;
+    delete height;
   }
   HtmlOutputDev::imgNum=1;
 
@@ -1232,7 +1246,17 @@ void HtmlOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
 
     fclose(f1);
    
-  if (fName) imgList->append(fName);
+    if (fName){
+      int* x0p = new int[1]; *x0p = x0;
+      int* y0p = new int[1]; *y0p = y0;
+      int* w1p = new int[1]; *w1p = w1;
+      int* h1p = new int[1]; *h1p = h1;
+      imgList->append(fName);
+      imgTopList->append(y0p);
+      imgLeftList->append(x0p);
+      imgWidthList->append(w1p);
+      imgHeightList->append(h1p);
+    }
   }
   else {
     OutputDev::drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg);
@@ -1321,7 +1345,17 @@ void HtmlOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
     
     fclose(f1);
   
-    if (fName) imgList->append(fName);
+    if (fName) {
+      int* x0p = new int[1]; *x0p = x0;
+      int* y0p = new int[1]; *y0p = y0;
+      int* w1p = new int[1]; *w1p = w1;
+      int* h1p = new int[1]; *h1p = h1;
+      imgList->append(fName);
+      imgTopList->append(y0p);
+      imgLeftList->append(x0p);
+      imgWidthList->append(w1p);
+      imgHeightList->append(h1p);
+    }
   }
   else {
 #ifdef ENABLE_LIBPNG
@@ -1387,7 +1421,15 @@ void HtmlOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
     fclose(f1);
 
     free(row);
+    int* x0p = new int[1]; *x0p = x0;
+    int* y0p = new int[1]; *y0p = y0;
+    int* w1p = new int[1]; *w1p = w1;
+    int* h1p = new int[1]; *h1p = h1;
     imgList->append(fName);
+    imgTopList->append(y0p);
+    imgLeftList->append(x0p);
+    imgWidthList->append(w1p);
+    imgHeightList->append(h1p);
     ++imgNum;
     imgStr->close();
     delete imgStr;
diff --git a/utils/HtmlOutputDev.h b/utils/HtmlOutputDev.h
index 24ccfd1..c6b11e0 100644
--- a/utils/HtmlOutputDev.h
+++ b/utils/HtmlOutputDev.h
@@ -319,6 +319,10 @@ private:
   int maxPageHeight;
   static int imgNum;
   static GooList *imgList;
+  static GooList *imgTopList;
+  static GooList *imgLeftList;
+  static GooList *imgWidthList;
+  static GooList *imgHeightList;
   GooString *Docname;
   GooString *docTitle;
   GooList *glMetaVars;
diff --git a/utils/pdf2xml.dtd b/utils/pdf2xml.dtd
index 2a5ed22..dc594b8 100644
--- a/utils/pdf2xml.dtd
+++ b/utils/pdf2xml.dtd
@@ -27,3 +27,9 @@
 <!ELEMENT b (#PCDATA)>
 <!ELEMENT i (#PCDATA)>
 <!ELEMENT image (#PCDATA)*>
+<!ATTLIST image
+	top CDATA #REQUIRED
+	left CDATA #REQUIRED
+	width CDATA #REQUIRED
+	height CDATA #REQUIRED
+>
