1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-05 01:28:39 +00:00
This commit is contained in:
Lu Wang 2013-02-28 02:52:00 +08:00
parent c6630561e6
commit 80fc92defe
6 changed files with 49 additions and 13 deletions

View File

@ -15,7 +15,7 @@ var pdf2htmlEX = (function(){
page_decoration : '@CSS_PAGE_DECORATION_CN@',
page_content_box : '@CSS_PAGE_CONTENT_BOX_CN@',
page_data : '@CSS_PAGE_DATA_CN@',
link : '@CSS_LINE_CN@',
link : '@CSS_LINK_CN@',
__dummy__ : 'no comma'
};
@ -146,7 +146,7 @@ var pdf2htmlEX = (function(){
//this.zoom_fixer();
// used by outline/annot_link etc
$([this.container, this.outline]).on('click', '.'+CSS_CLASS_NAMES['link'], this, this.link_handler);
this.container.add(this.outline).on('click', '.'+CSS_CLASS_NAMES['link'], this, this.link_handler);
this.render();
},
@ -248,6 +248,7 @@ var pdf2htmlEX = (function(){
},
link_handler : function (e) {
console.log('here');
var _ = e.data;
var t = $(e.currentTarget);

View File

@ -26,6 +26,7 @@
#include "util/ffw.h"
#include "util/path.h"
#include "util/unicode.h"
#include "util/css_const.h"
namespace pdf2htmlEX {
@ -726,7 +727,7 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & suff
}
f_css.fs << "@font-face{"
<< "font-family:f" << info.id << ";"
<< "font-family:" << CSS::FONT_NAME_CN << info.id << ";"
<< "src:url(";
{
@ -748,13 +749,13 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & suff
f_css.fs << ")"
<< "format(\"" << format << "\");"
<< "}" // end of @font-face
<< ".f" << info.id << "{"
<< "font-family:f" << info.id << ";"
<< "." << CSS::FONT_NAME_CN << info.id << "{"
<< "font-family:" << CSS::FONT_NAME_CN << info.id << ";"
<< "line-height:" << round(info.ascent - info.descent) << ";"
<< "font-style:normal;"
<< "font-weight:normal;"
<< "visibility:visible;"
<< "}" // end of .f
<< "}"
<< endl;
}
@ -771,12 +772,12 @@ static string general_font_family(GfxFont * font)
// TODO: this function is called when some font is unable to process, may use the name there as a hint
void HTMLRenderer::export_remote_default_font(long long fn_id)
{
f_css.fs << ".f" << fn_id << "{font-family:sans-serif;visibility:hidden;}" << endl;
f_css.fs << "." << CSS::FONT_NAME_CN << fn_id << "{font-family:sans-serif;visibility:hidden;}" << endl;
}
void HTMLRenderer::export_local_font(const FontInfo & info, GfxFont * font, const string & original_font_name, const string & cssfont)
{
f_css.fs << ".f" << info.id << "{";
f_css.fs << "." << CSS::FONT_NAME_CN << info.id << "{";
f_css.fs << "font-family:" << ((cssfont == "") ? (original_font_name + "," + general_font_family(font)) : cssfont) << ";";
string fn = original_font_name;
@ -802,4 +803,4 @@ void HTMLRenderer::export_local_font(const FontInfo & info, GfxFont * font, cons
f_css.fs << "}" << endl;
}
} //namespace pdf2hmlEX
} //namespace pdf2htmlEX

View File

@ -170,7 +170,8 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref)
<< " " << CSS::HEIGHT_CN << height_manager.get_id()
<< "\">"
<< "<div id=\"" << CSS::PAGE_FRAME_CN << pageNum
<< "\" data-page-no=\"" << pageNum << "\" class=\"p\">"
<< "\" class=\"" << CSS::PAGE_FRAME_CN
<< "\" data-page-no=\"" << pageNum << "\">"
<< "<div class=\"" << CSS::PAGE_CONTENT_BOX_CN << "\" style=\"";
if(param->process_nontext)

View File

@ -18,6 +18,7 @@
#include "util/math.h"
#include "util/misc.h"
#include "util/encoding.h"
#include "util/css_const.h"
namespace pdf2htmlEX {
@ -151,7 +152,7 @@ string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail)
detail = get_linkdest_detail_str(dest, cur_catalog, pageno);
if(pageno > 0)
{
dest_str = (char*)str_fmt("#p%x", pageno);
dest_str = (char*)str_fmt("#%s%x", CSS::PAGE_FRAME_CN, pageno);
}
delete dest;
}

View File

@ -0,0 +1,32 @@
# CSS class names
# Note
# don't use: (otherwise conflicted with others when there is an ID suffix)
# p f
set(CSS_INVALID_ID "_")
set(CSS_LINE_CN "tl") # text line
set(CSS_TRANSFORM_MATRIX_CN "tm") # transform matrix
set(CSS_PAGE_DECORATION_CN "pd") # page decoration
set(CSS_PAGE_FRAME_CN "pf") # page frame
set(CSS_PAGE_CONTENT_BOX_CN "pc") # page content
set(CSS_PAGE_DATA_CN "pi") # page info
set(CSS_FONT_NAME_CN "fn") # font name
set(CSS_FONT_SIZE_CN "fs") # font size
set(CSS_FILL_COLOR_CN "fc") # fill color
set(CSS_STROKE_COLOR_CN "sc") # stroke color
set(CSS_LETTER_SPACE_CN "ls") # letter space
set(CSS_WORD_SPACE_CN "ws") # word space
set(CSS_RISE_CN "r") # rise
set(CSS_WHITESPACE_CN "_") # whitespace
set(CSS_LEFT_CN "x") # x
set(CSS_HEIGHT_CN "h") # height
set(CSS_WIDTH_CN "w") # width
set(CSS_BOTTTOM_CN "y") # y
set(CSS_CSS_DRAW_CN "d") # draw
set(CSS_LINK_CN "l") # link

View File

@ -21,7 +21,7 @@ const char * const PRINT_ONLY = "@media print";
// usually the class name is XXX_CN or XXX_CN<hex id>
// sometimes we need a special one, e.g. transparent color, where the id is -1
const char * const INVALID_ID = "@CSS_INVALID_ID";
const char * const INVALID_ID = "@CSS_INVALID_ID@";
const char * const LINE_CN = "@CSS_LINE_CN@";
const char * const TRANSFORM_MATRIX_CN = "@CSS_TRANSFORM_MATRIX_CN@";
@ -49,7 +49,7 @@ const char * const WIDTH_CN = "@CSS_WIDTH_CN@";
const char * const BOTTOM_CN = "@CSS_BOTTTOM_CN@";
const char * const CSS_DRAW_CN = "@CSS_CSS_DRAW_CN@";
const char * const LINK_CN = "@CSS_LINE_CN@";
const char * const LINK_CN = "@CSS_LINK_CN@";
}
}