1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-05 17:48:38 +00:00
This commit is contained in:
Lu Wang 2012-09-19 02:13:26 +08:00
parent 6d694cd195
commit c55fee198e
5 changed files with 47 additions and 34 deletions

View File

@ -11,13 +11,16 @@
/* for Chrome & Safari */ /* for Chrome & Safari */
-webkit-text-stroke-width:0.13px; -webkit-text-stroke-width:0.13px;
} }
.b { .p {
position:relative;
background-color:white; background-color:white;
margin: 13px auto; margin: 13px auto;
overflow: hidden; overflow: hidden;
} }
.p { .b {
position:relative; position:absolute;
top:0;
left:0;
background-color:white; background-color:white;
overflow:hidden; overflow:hidden;
display:block; display:block;

View File

@ -1,6 +1,6 @@
/* hide all pages */ /* hide all pages */
(function(){ (function(){
var s = '.p{display:none;}'; var s = '.b{display:none;}';
var n = document.createElement("style"); var n = document.createElement("style");
n.type = "text/css"; n.type = "text/css";
if (n.styleSheet) { if (n.styleSheet) {

View File

@ -6,29 +6,28 @@
* modifiedy by Lu WANG * modifiedy by Lu WANG
*/ */
$(function() { $(function() {
var $pages = $(".p"), var $pages = $(".p");
$pageWrappers = $(".b"), var $page_boxes= $(".b");
$main = $("#pdf-main"), var $main = $("#pdf-main");
l = $pages.length; var l = $pages.length;
function isPageVisible(i, H) { function isPageVisible(i, H) {
var $pw = $($pageWrappers[i]), var $p = $($pages[i]);
t = $pw.offset().top, var t = $p.offset().top;
b = t + $pw.height() ; var b = t + $p.height();
return ( ! ( b < 0 || t >= H ) ); return ( ! ( b < 0 || t >= H ) );
} }
function setVisibilities(from, to, visible) { function setVisibilities(from, to, visible) {
for(var i = from; i <= to; ++i) { for(var i = from; i <= to; ++i) {
var $p = $($pages[i]); var $pb = $($page_boxes[i]);
if(visible) $p.show(); else $p.hide(); if(visible) $pb.show(); else $pb.hide();
} }
} }
// Selectively rendering of pages that are visible or will be visible // Selectively rendering of pages that are visible or will be visible
function selectiveRender() { function selectiveRender() {
var first = 0, last = l - 1, var first = 0, last = l - 1, H = $main.height();
H = $main.height();
// Find the first visible page // Find the first visible page
while(first < l && !isPageVisible(first, H)) while(first < l && !isPageVisible(first, H))

View File

@ -163,9 +163,8 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state)
assert((!line_opened) && "Open line in startPage detected!"); assert((!line_opened) && "Open line in startPage detected!");
html_fout html_fout
<< "<a name=\"a" << pageNum << "\">" << "<div id=\"p" << pageNum << "\" class=\"p\" style=\"width:" << pageWidth << "px;height:" << pageHeight << "px;\">"
<< "<div class=\"b\" style=\"width:" << pageWidth << "px;height:" << pageHeight << "px;\">" << "<div id=\"b" << pageNum << "\" class=\"b\" style=\"width:" << pageWidth << "px;height:" << pageHeight << "px;";
<< "<div id=\"p" << pageNum << "\" class=\"p\" style=\"width:" << pageWidth << "px;height:" << pageHeight << "px;";
if(param->process_nontext) if(param->process_nontext)
{ {
@ -224,7 +223,7 @@ void HTMLRenderer::endPage() {
cur_doc->processLinks(this, pageNum); cur_doc->processLinks(this, pageNum);
// close page // close page
html_fout << "</div></div></a>" << endl; html_fout << "</div></div>" << endl;
} }
/* /*
@ -264,7 +263,7 @@ void HTMLRenderer::processLink(AnnotLink * al)
delete dest; delete dest;
if(pageno > 0) if(pageno > 0)
dest_str = (char*)str_fmt("#a%x", pageno); dest_str = (char*)str_fmt("#p%x", pageno);
} }
} }
break; break;
@ -372,6 +371,7 @@ void HTMLRenderer::processLink(AnnotLink * al)
<< "width:" << _round(x2-x1-width) << "px;" << "width:" << _round(x2-x1-width) << "px;"
<< "height:" << _round(y2-y1-width) << "px;"; << "height:" << _round(y2-y1-width) << "px;";
html_fout << "background-color:rgb(0,0,0,0);";
html_fout << "\"></div>"; html_fout << "\"></div>";

View File

@ -216,22 +216,33 @@ void ffw_close(void)
void ffw_metric(int * ascent, int * descent) void ffw_metric(int * ascent, int * descent)
{ {
*ascent = cur_fv->sf->ascent; DBounds bb;
*descent = cur_fv->sf->descent; SplineFont * sf = cur_fv->sf;
SplineFontFindBounds(sf, &bb);
struct pfminfo * info = &sf->pfminfo;
cur_fv->sf->pfminfo.os2_winascent = 0; //debug
cur_fv->sf->pfminfo.os2_typoascent = 0; printf("%d %d\n", *ascent, *descent);
cur_fv->sf->pfminfo.hhead_ascent = 0;
cur_fv->sf->pfminfo.winascent_add = 0;
cur_fv->sf->pfminfo.typoascent_add = 0;
cur_fv->sf->pfminfo.hheadascent_add = 0;
cur_fv->sf->pfminfo.os2_windescent = 0; *ascent = sf->ascent;
cur_fv->sf->pfminfo.os2_typodescent = 0; *descent = sf->descent;
cur_fv->sf->pfminfo.hhead_descent = 0;
cur_fv->sf->pfminfo.windescent_add = 0; //debug
cur_fv->sf->pfminfo.typodescent_add = 0; printf("%d %d\n", *ascent, *descent);
cur_fv->sf->pfminfo.hheaddescent_add = 0;
info->os2_winascent = 0;
info->os2_typoascent = 0;
info->hhead_ascent = 0;
info->winascent_add = 0;
info->typoascent_add = 0;
info->hheadascent_add = 0;
info->os2_windescent = 0;
info->os2_typodescent = 0;
info->hhead_descent = 0;
info->windescent_add = 0;
info->typodescent_add = 0;
info->hheaddescent_add = 0;
} }
int ffw_get_em_size(void) int ffw_get_em_size(void)