Skip to content

Commit cd997e5

Browse files
committed
Merge pull request coolwanglu#2 from coolwanglu/master
update to 0.14.6
2 parents 175e199 + a296d3b commit cd997e5

37 files changed

Lines changed: 1277 additions & 62 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ before_script:
1818
- cmake -DENABLE_SVG=ON .
1919
script:
2020
- make
21-
- P2H_TEST_REMOTE=1 ctest --output-on-failure
21+
- P2H_TEST_REMOTE=1 ctest --output-on-failure --verbose
2222
- sudo make install
2323
- /usr/local/bin/pdf2htmlEX -v
2424
branches:

3rdparty/poppler/git/CairoFontEngine.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#endif
6060

6161
/*
62-
* multi thread disabled by WangLu
62+
* pdf2htmlEX: disabled multi thread
6363
#if MULTITHREADED
6464
# define fontEngineLocker() MutexLocker locker(&mutex)
6565
#else
@@ -421,7 +421,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
421421
ref = *gfxFont->getID();
422422
fontType = gfxFont->getType();
423423

424-
if (!(fontLoc = gfxFont->locateFont(xref, gFalse))) {
424+
// pdf2htmlEX: changed gFlase to nullptr
425+
if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
425426
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
426427
gfxFont->getName() ? gfxFont->getName()->getCString()
427428
: "(unnamed)");
@@ -768,7 +769,7 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
768769
useCIDs = major > 2 ||
769770
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
770771
/*
771-
* multi thread disabled by WangLu
772+
* pdf2htmlEX: disabled multi thread
772773
#if MULTITHREADED
773774
gInitMutex(&mutex);
774775
#endif
@@ -783,7 +784,7 @@ CairoFontEngine::~CairoFontEngine() {
783784
delete fontCache[i];
784785
}
785786
/*
786-
* multi thread disabled by WangLu
787+
* pdf2htmlEX: disabled multi thread
787788
#if MULTITHREADED
788789
gDestroyMutex(&mutex);
789790
#endif

3rdparty/poppler/git/CairoFontEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class CairoFontEngine {
122122
FT_Library lib;
123123
GBool useCIDs;
124124
/*
125-
* multi thread disabled by WangLu
125+
* pdf2htmlEX: disabled multi thread
126126
#if MULTITHREADED
127127
GooMutex mutex;
128128
#endif

3rdparty/poppler/git/CairoOutputDev.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ class CairoOutputDev: public OutputDev {
272272
cairo_filter_t getFilterForSurface(cairo_surface_t *image,
273273
GBool interpolate);
274274
GBool getStreamData (Stream *str, char **buffer, int *length);
275-
virtual void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
275+
// pdf2htmlEX: make setMimeData virtual, we need to override it
276+
virtual
277+
void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
276278
void fillToStrokePathClip(GfxState *state);
277279
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
278280

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ option(ENABLE_SVG "Enable SVG support, for generating SVG background images and
99

1010
include_directories(${CMAKE_SOURCE_DIR}/src)
1111

12-
set(PDF2HTMLEX_VERSION "0.13.6")
12+
set(PDF2HTMLEX_VERSION "0.14.6")
1313
set(ARCHIVE_NAME pdf2htmlex-${PDF2HTMLEX_VERSION})
1414
add_custom_target(dist
1515
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
@@ -183,6 +183,7 @@ add_custom_target(pdf2htmlEX_resources ALL DEPENDS
183183
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.min.js
184184
COMMAND ${CMAKE_SOURCE_DIR}/share/build_js.sh
185185
DEPENDS
186+
${CMAKE_SOURCE_DIR}/share/build_js.sh
186187
${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.js
187188
)
188189

@@ -191,6 +192,7 @@ add_custom_command(OUTPUT
191192
${CMAKE_SOURCE_DIR}/share/fancy.min.css
192193
COMMAND ${CMAKE_SOURCE_DIR}/share/build_css.sh
193194
DEPENDS
195+
${CMAKE_SOURCE_DIR}/share/build_css.sh
194196
${CMAKE_SOURCE_DIR}/share/base.css
195197
${CMAKE_SOURCE_DIR}/share/fancy.css
196198
)

ChangeLog

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
Developing
1+
v0.14.6
2+
2015.07.22
3+
4+
* Fixed Windows build
5+
* Fixed crash when flattening non-CID fonts
6+
* Handle OpenType subtype for FontFile3
7+
* New option for the JS viewer: `view_history_handler`
8+
29

310
v0.13.6
411
2015.04.29

share/build_js.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OUTPUT="$BASEDIR/$OUTPUT_FN"
1515

1616
(echo "Building $OUTPUT_FN with closure-compiler..." && \
1717
java -jar "$CLOSURE_COMPILER_JAR" \
18-
--compilation_level ADVANCED_OPTIMIZATIONS \
18+
--compilation_level SIMPLE_OPTIMIZATIONS \
1919
--warning_level VERBOSE \
2020
--output_wrapper "(function(){%output%})();" \
2121
--js "$INPUT" \

share/pdf2htmlEX.js.in

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var CSS_CLASS_NAMES = {
3838
page_data : '@CSS_PAGE_DATA_CN@',
3939
background_image : '@CSS_BACKGROUND_IMAGE_CN@',
4040
link : '@CSS_LINK_CN@',
41+
input_radio : '@CSS_INPUT_RADIO_CN@',
4142
__dummy__ : 'no comma'
4243
};
4344

@@ -61,10 +62,12 @@ var DEFAULT_CONFIG = {
6162
'render_timeout' : 100,
6263
// zoom ratio step for each zoom in/out event
6364
'scale_step' : 0.9,
64-
// register global key handler
65+
// register global key handler, allowing navigation by keyboard
6566
'key_handler' : true,
66-
// register hashchange handler
67+
// register hashchange handler, navigate to the location specified by the hash
6768
'hashchange_handler' : true,
69+
// register view history handler, allowing going back to the previous location
70+
'view_history_handler' : true,
6871

6972
'__dummy__' : 'no comma'
7073
};
@@ -261,7 +264,7 @@ Viewer.prototype = {
261264
},
262265

263266
initialize_radio_button : function() {
264-
var elements = document.getElementsByClassName('ir');
267+
var elements = document.getElementsByClassName(CSS_CLASS_NAMES.input_radio);
265268

266269
for(var i = 0; i < elements.length; i++) {
267270
var r = elements[i];
@@ -312,6 +315,12 @@ Viewer.prototype = {
312315
}, false);
313316
}
314317

318+
if (this.config['view_history_handler']) {
319+
window.addEventListener('popstate', function(e) {
320+
if(e.state) self.navigate_to_dest(e.state);
321+
}, false);
322+
}
323+
315324
// register schedule rendering
316325
// renew old schedules since scroll() may be called frequently
317326
this.container.addEventListener('scroll', function() {
@@ -759,13 +768,13 @@ Viewer.prototype = {
759768

760769
fit_width : function () {
761770
var page_idx = this.cur_page_idx;
762-
this.rescale(this.container.clientWidth / this.pages[page_idx].width(), false);
771+
this.rescale(this.container.clientWidth / this.pages[page_idx].width(), true);
763772
this.scroll_to(page_idx);
764773
},
765774

766775
fit_height : function () {
767776
var page_idx = this.cur_page_idx;
768-
this.rescale(this.container.clientHeight / this.pages[page_idx].height(), false);
777+
this.rescale(this.container.clientHeight / this.pages[page_idx].height(), true);
769778
this.scroll_to(page_idx);
770779
},
771780
/**
@@ -797,6 +806,13 @@ Viewer.prototype = {
797806
var detail_str = /** @type{string} */ (target.getAttribute('data-dest-detail'));
798807
if (!detail_str) return;
799808

809+
if (this.config['view_history_handler']) {
810+
try {
811+
var cur_hash = this.get_current_view_hash();
812+
window.history.replaceState(cur_hash, '', '#' + cur_hash);
813+
window.history.pushState(detail_str, '', '#' + detail_str);
814+
} catch(ex) { }
815+
}
800816
this.navigate_to_dest(detail_str, this.get_containing_page(target));
801817
e.preventDefault();
802818
},
@@ -883,7 +899,6 @@ Viewer.prototype = {
883899

884900
this.rescale(zoom, false);
885901

886-
887902
var self = this;
888903
/**
889904
* page should of type Page
@@ -926,6 +941,26 @@ Viewer.prototype = {
926941
var container = this.container;
927942
container.scrollLeft += pos[0] - cur_target_pos[0];
928943
container.scrollTop += pos[1] - cur_target_pos[1];
944+
},
945+
946+
/**
947+
* generate the hash for the current view
948+
*/
949+
get_current_view_hash : function() {
950+
var detail = [];
951+
var cur_page = this.pages[this.cur_page_idx];
952+
953+
detail.push(cur_page.num);
954+
detail.push('XYZ');
955+
956+
var cur_pos = cur_page.view_position();
957+
cur_pos = transform(cur_page.ictm, [cur_pos[0], cur_page.height()-cur_pos[1]]);
958+
detail.push(cur_pos[0] / this.scale);
959+
detail.push(cur_pos[1] / this.scale);
960+
961+
detail.push(this.scale);
962+
963+
return JSON.stringify(detail);
929964
}
930965
};
931966

src/BackgroundRenderer/CairoBackgroundRenderer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
127127
page_height = doc->getPageMediaHeight(pageno);
128128
}
129129

130+
if (doc->getPageRotate(pageno) == 90 || doc->getPageRotate(pageno) == 270)
131+
std::swap(page_height, page_width);
132+
130133
string fn = (char*)html_renderer->str_fmt("%s/bg%x.svg", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno);
131134
if(param.embed_image)
132135
html_renderer->tmp_files.add(fn);

src/BackgroundRenderer/SplashBackgroundRenderer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using std::unique_ptr;
2929
const SplashColor SplashBackgroundRenderer::white = {255,255,255};
3030

3131
SplashBackgroundRenderer::SplashBackgroundRenderer(const string & imgFormat, HTMLRenderer * html_renderer, const Param & param)
32-
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white), gTrue)
32+
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white))
3333
, html_renderer(html_renderer)
3434
, param(param)
3535
, format(imgFormat)

0 commit comments

Comments
 (0)