From 972092740c809f978861b379752878e2c1e1ea87 Mon Sep 17 00:00:00 2001 From: Leena Date: Wed, 1 Sep 2010 11:00:03 +0530 Subject: [PATCH] accesspdf(pdftohtml -s .pdf) This will help to make pdftohtml more accessible and usable. New option '-s' for pdftohtml is defined to generate complex html with a single -html.html including all pages. --- utils/HtmlFonts.cc | 10 +++++- utils/HtmlFonts.h | 5 ++- utils/HtmlOutputDev.cc | 70 ++++++++++++++++++++++++++++++----------------- utils/pdftohtml.1 | 3 ++ utils/pdftohtml.cc | 14 +++++++-- 5 files changed, 70 insertions(+), 32 deletions(-) diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index d2cbfd5..aff3626 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -288,12 +288,14 @@ int HtmlFontAccu::AddFont(const HtmlFont& font){ } // get CSS font name for font #i -GooString* HtmlFontAccu::getCSStyle(int i, GooString* content){ +GooString* HtmlFontAccu::getCSStyle(int i, GooString* content ,int j){ GooString *tmp; GooString *iStr=GooString::fromInt(i); + GooString *jStr=GooString::fromInt(j); if (!xml) { tmp = new GooString("append(jStr); tmp->append(iStr); tmp->append("\">"); tmp->append(content); @@ -303,14 +305,16 @@ GooString* HtmlFontAccu::getCSStyle(int i, GooString* content){ tmp->append(content); } + delete jStr; delete iStr; return tmp; } // get CSS font definition for font #i -GooString* HtmlFontAccu::CSStyle(int i){ +GooString* HtmlFontAccu::CSStyle(int i, int j){ GooString *tmp=new GooString(); GooString *iStr=GooString::fromInt(i); + GooString *jStr=GooString::fromInt(j); GooVector::iterator g=accu->begin(); g+=i; @@ -322,6 +326,7 @@ GooString* HtmlFontAccu::CSStyle(int i){ if(!xml){ tmp->append(".ft"); + tmp->append(jStr); tmp->append(iStr); tmp->append("{font-size:"); tmp->append(Size); @@ -352,6 +357,7 @@ GooString* HtmlFontAccu::CSStyle(int i){ delete fontName; delete colorStr; + delete jStr; delete iStr; delete Size; return tmp; diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index df2b570..ceb47ef 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -89,8 +89,9 @@ public: g+=i; return g; } - GooString* getCSStyle (int i, GooString* content); - GooString* CSStyle(int i); + //One more parameter(int j) is added in the getCSStyle and CSStyle function by CDAC developer Team + GooString* getCSStyle (int i,GooString* content, int j=0); + GooString* CSStyle(int i,int j=0); int size() const {return accu->size();} }; diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index dbf677f..89285cc 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -65,6 +65,7 @@ GooList *HtmlOutputDev::imgList=new GooList(); extern double scale; extern GBool complexMode; +extern GBool singleHtml; extern GBool ignore; extern GBool printCommands; extern GBool printHtml; @@ -670,23 +671,34 @@ void HtmlPage::dumpComplex(FILE *file, int page){ { GooString* pgNum=GooString::fromInt(page); tmp = new GooString(DocName); - tmp->append('-')->append(pgNum)->append(".html"); + if (!singleHtml){ + tmp->append('-')->append(pgNum)->append(".html"); + pageFile = fopen(tmp->getCString(), "w"); + } + else { + tmp->append("-html")->append(".html");////////////// + pageFile = fopen(tmp->getCString(), "a"); + } delete pgNum; - - if (!(pageFile = fopen(tmp->getCString(), "w"))) { + if (!pageFile) { error(-1, "Couldn't open html file '%s'", tmp->getCString()); delete tmp; return; } + delete tmp; - fprintf(pageFile,"%s\n\n\nPage %d\n\n", - DOCTYPE, page); + if (!singleHtml) + fprintf(pageFile,"%s\n\n\nPage %d\n\n", DOCTYPE, page); + else + fprintf(pageFile,"%s\n\n\n %s\n\n", DOCTYPE, tmp->getCString());////file name htmlEncoding = HtmlOutputDev::mapEncodingToHtml (globalParams->getTextEncodingName()); - fprintf(pageFile, "\n", htmlEncoding); - } + if (!singleHtml) + fprintf(pageFile, "\n", htmlEncoding); + else + fprintf(pageFile, "\n
\n", htmlEncoding); } else { pageFile = file; @@ -701,7 +713,11 @@ void HtmlPage::dumpComplex(FILE *file, int page){ fputs("