diff --git a/share/pdf2htmlEX.js.in b/share/pdf2htmlEX.js.in index 1d43555..283dd99 100644 --- a/share/pdf2htmlEX.js.in +++ b/share/pdf2htmlEX.js.in @@ -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); diff --git a/src/HTMLRenderer/font.cc b/src/HTMLRenderer/font.cc index b128626..62fd9d1 100644 --- a/src/HTMLRenderer/font.cc +++ b/src/HTMLRenderer/font.cc @@ -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 diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc index 4da7f4a..cda2d5d 100644 --- a/src/HTMLRenderer/general.cc +++ b/src/HTMLRenderer/general.cc @@ -170,7 +170,8 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref) << " " << CSS::HEIGHT_CN << height_manager.get_id() << "\">" << "
" + << "\" class=\"" << CSS::PAGE_FRAME_CN + << "\" data-page-no=\"" << pageNum << "\">" << "
process_nontext) diff --git a/src/HTMLRenderer/link.cc b/src/HTMLRenderer/link.cc index 377f41c..92d2b99 100644 --- a/src/HTMLRenderer/link.cc +++ b/src/HTMLRenderer/link.cc @@ -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; } diff --git a/src/css_class_names.cmakelists.txt b/src/css_class_names.cmakelists.txt new file mode 100644 index 0000000..c48dbd7 --- /dev/null +++ b/src/css_class_names.cmakelists.txt @@ -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 diff --git a/src/util/css_const.h.in b/src/util/css_const.h.in index 0e14e2c..ff585e1 100644 --- a/src/util/css_const.h.in +++ b/src/util/css_const.h.in @@ -21,7 +21,7 @@ const char * const PRINT_ONLY = "@media print"; // usually the class name is XXX_CN or XXX_CN // 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@"; } }