diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index 17541a2..c24692b 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -774,6 +774,42 @@ void HtmlPage::dumpAsXML(FILE* f,int page){ fputs("\n",f); } +static void printCSS(FILE *f) +{ + // Image flip/flop CSS + // Source: + // http://stackoverflow.com/questions/1309055/cross-browser-way-to-flip-html-image-via-javascript-css + // tested in Chrome, Fx (Linux) and IE9 (W7) + static const char css[] = + "" "\n"; + + fwrite( css, sizeof(css)-1, 1, f ); +} + int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& pageFile, int page) { GooString* tmp; @@ -902,20 +938,27 @@ void HtmlPage::dump(FILE *f, int pageNum) int listlen=imgList->getLength(); for (int i = 0; i < listlen; i++) { HtmlImage *img = (HtmlImage*)imgList->del(0); - fprintf(f,"
\n",img->fName->getCString()); + + // see printCSS() for class names + const char *styles[4] = { "", " class=\"xflip\"", " class=\"yflip\"", " class=\"xyflip\"" }; + int style_index=0; + if (img->xMin > img->xMax) style_index += 1; // xFlip + if (img->yMin > img->yMax) style_index += 2; // yFlip + + fprintf(f,"
\n",styles[style_index],img->fName->getCString()); delete img; } GooString* str; for(HtmlString *tmp=yxStrings;tmp;tmp=tmp->yxNext){ if (tmp->htext){ - str=new GooString(tmp->htext); - fputs(str->getCString(),f); - delete str; - fputs("
\n",f); + str=new GooString(tmp->htext); + fputs(str->getCString(),f); + delete str; + fputs("
\n",f); } } - fputs("
\n",f); + fputs("
\n",f); } } @@ -1108,20 +1151,22 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, delete str; } } - if (!complexMode) - { /* not in complex mode */ - + if (!complexMode) + { /* not in complex mode */ + GooString* right=new GooString(fileName); right->append("s.html"); if (!(page=fopen(right->getCString(),"w"))){ error(errIO, -1, "Couldn't open html file '{0:t}'", right); delete right; - return; + return; } delete right; fputs(DOCTYPE, page); - fputs("\n\n\n\n\n",page); + fputs("\n\n\n",page); + printCSS(page); + fputs("\n\n",page); } } @@ -1153,6 +1198,7 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, fprintf(page, "\n", htmlEncoding->getCString()); dumpMetaVars(page); + printCSS(page); fprintf(page,"\n"); fprintf(page,"\n"); }