Easier navigation of generated document
Status: Beta
Brought to you by:
meshko
Some browsers, most notably Opera, can interpret link
tags in the header of a document to provide easiy
navigation to the next and previous documents.
It would help users to navigate large documents
produced in complex mode if these tags were added.
For instance:
<link rel="home" href="http://www.opera.com/"
title="Opera front page"/>
Opera will put a button above the window with the label
Home.
It can do the same for next and previous, etc. See: 12.
1.2 Other link relationships <http://www.w3.
org/TR/REC-html40/struct/links.html#h-12.1.2
>
for the W3C recommendations.
Anyway, apart from always wanting more, I'm really
pleased with pdftohtml. It is already saving a lot of time
and effort.
Logged In: YES
user_id=1157335
Hi Kevin!
I'm also very pleased with 'pdftohtml', but really missed an
easy way to navigate in the multi page HTML documents. To
remedy this I made a fast hack which adds "Prev" and "Next"
links at the top and bottom of each page generated with
"pdftohtml -c", i.e. with the frame enabled.
The patch against pdftohtml-0.36 is included below!
Regards,
Henrik
---------------8<------------------
diff -r -u -p ../pdftohtml-0.36/src/HtmlOutputDev.cc
./src/HtmlOutputDev.cc
--- ../pdftohtml-0.36/src/HtmlOutputDev.cc 2003-06-25
00:41:27.000000000 +0200
+++ ./src/HtmlOutputDev.cc 2004-11-11 17:16:56.000000000 +0100
@@ -630,8 +630,9 @@ void HtmlPage::dumpComplex(FILE *file, i
fprintf(pageFile,"<a name=\"%d\"></a>\n", page);
}
- fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
- pageWidth, pageHeight);
+ // henrik:2004-11-11: Moved this below "Prev" and "Next"
links
+// fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
+// pageWidth, pageHeight);
tmp=basename(DocName);
@@ -647,8 +648,31 @@ void HtmlPage::dumpComplex(FILE *file, i
if( !noframes )
{
fputs("</HEAD>\n<BODY bgcolor=\"#A0A0A0\"
vlink=\"blue\" link=\"blue\">\n",pageFile);
+
+ // henrik:2004-11-11: Added "Prev" and "Next" links
+ GString* pgNum;
+ GString* tmp;
+ pgNum=GString::fromInt(page - 1);
+ tmp = new GString(DocName);
+ tmp->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ if ( page > 1 )
+ fprintf(pageFile, "<a href=\"%s\">Prev</a>\n",
tmp->getCString());
+ else
+ fprintf(pageFile, "Prev\n");
+ delete tmp;
+ pgNum=GString::fromInt(page + 1);
+ tmp = new GString(DocName);
+ tmp->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ fprintf(pageFile, "<a href=\"%s\">Next</a>\n",
tmp->getCString());
+ delete tmp;
}
+ // henrik:2004-11-11: Moved here from above
+ fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
+ pageWidth, pageHeight);
+
if( !ignore )
{
fprintf(pageFile,
@@ -684,6 +708,25 @@ void HtmlPage::dumpComplex(FILE *file, i
if( !noframes )
{
+ // henrik:2004-11-11: Added "Prev" and "Next" links
+ GString* pgNum;
+ GString* tmp;
+ pgNum=GString::fromInt(page - 1);
+ tmp = new GString(DocName);
+ tmp->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ if ( page > 1 )
+ fprintf(pageFile, "<a href=\"%s\">Prev</a>\n",
tmp->getCString());
+ else
+ fprintf(pageFile, "Prev\n");
+ delete tmp;
+ pgNum=GString::fromInt(page + 1);
+ tmp = new GString(DocName);
+ tmp->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ fprintf(pageFile, "<a href=\"%s\">Next</a>\n",
tmp->getCString());
+ delete tmp;
+
fputs("</BODY>\n</HTML>\n",pageFile);
fclose(pageFile);
}
---------------8<------------------
Logged In: YES
user_id=1157335
As so often with fast hacks, the first try isn't that good.
The first version I posted below does not handle conversions
of documents in subdirectories properly.
The patch included below solves this problem by using the
basename() function.
Regards,
Henrik
---------------8<------------------
diff -r -u -p ../pdftohtml-0.36/src/HtmlOutputDev.cc
./src/HtmlOutputDev.cc
--- ../pdftohtml-0.36/src/HtmlOutputDev.cc 2003-06-25
00:41:27.000000000 +0200
+++ ./src/HtmlOutputDev.cc 2004-11-11 18:13:32.283842295 +0100
@@ -630,8 +630,9 @@ void HtmlPage::dumpComplex(FILE *file, i
fprintf(pageFile,"<a name=\"%d\"></a>\n", page);
}
- fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
- pageWidth, pageHeight);
+ // henrik:2004-11-11: Moved this below "Prev" and "Next"
links
+// fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
+// pageWidth, pageHeight);
tmp=basename(DocName);
@@ -647,8 +648,31 @@ void HtmlPage::dumpComplex(FILE *file, i
if( !noframes )
{
fputs("</HEAD>\n<BODY bgcolor=\"#A0A0A0\"
vlink=\"blue\" link=\"blue\">\n",pageFile);
+
+ // henrik:2004-11-11: Added "Prev" and "Next" links
+ GString* pgNum;
+ GString* tmp2;
+ pgNum=GString::fromInt(page - 1);
+ tmp2 = basename(DocName);
+ tmp2->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ if ( page > 1 )
+ fprintf(pageFile, "<a href=\"%s\">Prev</a>\n",
tmp2->getCString());
+ else
+ fprintf(pageFile, "Prev\n");
+ delete tmp2;
+ pgNum=GString::fromInt(page + 1);
+ tmp2 = basename(DocName);
+ tmp2->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ fprintf(pageFile, "<a href=\"%s\">Next</a>\n",
tmp2->getCString());
+ delete tmp2;
}
+ // henrik:2004-11-11: Moved here from above
+ fprintf(pageFile,"<DIV
style=\"position:relative;width:%d;height:%d;\">\n",
+ pageWidth, pageHeight);
+
if( !ignore )
{
fprintf(pageFile,
@@ -658,7 +682,7 @@ void HtmlPage::dumpComplex(FILE *file, i
}
delete tmp;
-
+
GString *str, *str1;
for(HtmlString *tmp1=yxStrings;tmp1;tmp1=tmp1->yxNext){
if (tmp1->htext){
@@ -684,6 +708,25 @@ void HtmlPage::dumpComplex(FILE *file, i
if( !noframes )
{
+ // henrik:2004-11-11: Added "Prev" and "Next" links
+ GString* pgNum;
+ GString* tmp2;
+ pgNum=GString::fromInt(page - 1);
+ tmp2 = basename(DocName);
+ tmp2->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ if ( page > 1 )
+ fprintf(pageFile, "<a href=\"%s\">Prev</a>\n",
tmp2->getCString());
+ else
+ fprintf(pageFile, "Prev\n");
+ delete tmp2;
+ pgNum=GString::fromInt(page + 1);
+ tmp2 = basename(DocName);
+ tmp2->append('-')->append(pgNum)->append(".html");
+ delete pgNum;
+ fprintf(pageFile, "<a href=\"%s\">Next</a>\n",
tmp2->getCString());
+ delete tmp2;
+
fputs("</BODY>\n</HTML>\n",pageFile);
fclose(pageFile);
}
---------------8<------------------