这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Sep 15, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88fba4e
0.14.0
coolwanglu May 1, 2015
fa13386
fix #501
coolwanglu May 1, 2015
68f0977
0.14.1
coolwanglu May 1, 2015
394354f
fixes #513; 0.14.2
coolwanglu May 1, 2015
ae0adbd
fixes #511
coolwanglu May 1, 2015
1a90525
wipe out font names; fixes #486
coolwanglu May 2, 2015
0da946b
it's been 2015
coolwanglu May 3, 2015
be3311a
use configured css class name for input_radio
coolwanglu May 3, 2015
7163d4d
use simple optimization to retain api in js
coolwanglu May 3, 2015
d48b3cc
fixes #506; fixes fit_width/height() in JS
coolwanglu May 3, 2015
571145a
test case for #477
coolwanglu May 3, 2015
8b7318f
0.14.3
coolwanglu May 3, 2015
c48f9af
fixes #335
coolwanglu May 3, 2015
a9ed44c
should verbose infor in ctest in .travis.yml; otherwise travis would …
coolwanglu May 3, 2015
c0a53b0
test case for #402
coolwanglu May 3, 2015
47f1410
0.14.4
coolwanglu May 3, 2015
2a5ce90
handle subtype OpenType for FontFile3, in pdf 1.6
coolwanglu May 3, 2015
cb825f3
test case for #460
coolwanglu May 3, 2015
4da3a78
do not abort when attempting to flatten a non-CID font
coolwanglu May 3, 2015
debf55b
0.14.5
coolwanglu May 3, 2015
9d97ed7
fix issue when compile windows version
witwall Jun 23, 2015
984c118
Merge pull request #541 from witwall/witwall-patch-1
coolwanglu Jun 23, 2015
ace5b9a
Merge branch 'master' into incoming
coolwanglu Jun 30, 2015
8628ce1
js: get hash for current view
coolwanglu Jul 10, 2015
fa01e02
JS: view_history_handler
coolwanglu Jul 10, 2015
2aaa2ff
marked changes for pdf2htmlEX
coolwanglu Jul 22, 2015
f30520c
fix old CairoFontEngine.cc for new interface
coolwanglu Jul 22, 2015
d134e83
update tests
coolwanglu Jul 22, 2015
a296d3b
0.14.6
coolwanglu Jul 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ before_script:
- cmake -DENABLE_SVG=ON .
script:
- make
- P2H_TEST_REMOTE=1 ctest --output-on-failure
- P2H_TEST_REMOTE=1 ctest --output-on-failure --verbose
- sudo make install
- /usr/local/bin/pdf2htmlEX -v
branches:
Expand Down
9 changes: 5 additions & 4 deletions 3rdparty/poppler/git/CairoFontEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#endif

/*
* multi thread disabled by WangLu
* pdf2htmlEX: disabled multi thread
#if MULTITHREADED
# define fontEngineLocker() MutexLocker locker(&mutex)
#else
Expand Down Expand Up @@ -421,7 +421,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
ref = *gfxFont->getID();
fontType = gfxFont->getType();

if (!(fontLoc = gfxFont->locateFont(xref, gFalse))) {
// pdf2htmlEX: changed gFlase to nullptr
if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
Expand Down Expand Up @@ -768,7 +769,7 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
useCIDs = major > 2 ||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
/*
* multi thread disabled by WangLu
* pdf2htmlEX: disabled multi thread
#if MULTITHREADED
gInitMutex(&mutex);
#endif
Expand All @@ -783,7 +784,7 @@ CairoFontEngine::~CairoFontEngine() {
delete fontCache[i];
}
/*
* multi thread disabled by WangLu
* pdf2htmlEX: disabled multi thread
#if MULTITHREADED
gDestroyMutex(&mutex);
#endif
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/poppler/git/CairoFontEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CairoFontEngine {
FT_Library lib;
GBool useCIDs;
/*
* multi thread disabled by WangLu
* pdf2htmlEX: disabled multi thread
#if MULTITHREADED
GooMutex mutex;
#endif
Expand Down
4 changes: 3 additions & 1 deletion 3rdparty/poppler/git/CairoOutputDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class CairoOutputDev: public OutputDev {
cairo_filter_t getFilterForSurface(cairo_surface_t *image,
GBool interpolate);
GBool getStreamData (Stream *str, char **buffer, int *length);
virtual void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
// pdf2htmlEX: make setMimeData virtual, we need to override it
virtual
void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
void fillToStrokePathClip(GfxState *state);
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);

Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option(ENABLE_SVG "Enable SVG support, for generating SVG background images and

include_directories(${CMAKE_SOURCE_DIR}/src)

set(PDF2HTMLEX_VERSION "0.13.6")
set(PDF2HTMLEX_VERSION "0.14.6")
set(ARCHIVE_NAME pdf2htmlex-${PDF2HTMLEX_VERSION})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
Expand Down Expand Up @@ -183,6 +183,7 @@ add_custom_target(pdf2htmlEX_resources ALL DEPENDS
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.min.js
COMMAND ${CMAKE_SOURCE_DIR}/share/build_js.sh
DEPENDS
${CMAKE_SOURCE_DIR}/share/build_js.sh
${CMAKE_SOURCE_DIR}/share/pdf2htmlEX.js
)

Expand All @@ -191,6 +192,7 @@ add_custom_command(OUTPUT
${CMAKE_SOURCE_DIR}/share/fancy.min.css
COMMAND ${CMAKE_SOURCE_DIR}/share/build_css.sh
DEPENDS
${CMAKE_SOURCE_DIR}/share/build_css.sh
${CMAKE_SOURCE_DIR}/share/base.css
${CMAKE_SOURCE_DIR}/share/fancy.css
)
Expand Down
9 changes: 8 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Developing
v0.14.6
2015.07.22

* Fixed Windows build
* Fixed crash when flattening non-CID fonts
* Handle OpenType subtype for FontFile3
* New option for the JS viewer: `view_history_handler`


v0.13.6
2015.04.29
Expand Down
2 changes: 1 addition & 1 deletion share/build_js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ OUTPUT="$BASEDIR/$OUTPUT_FN"

(echo "Building $OUTPUT_FN with closure-compiler..." && \
java -jar "$CLOSURE_COMPILER_JAR" \
--compilation_level ADVANCED_OPTIMIZATIONS \
--compilation_level SIMPLE_OPTIMIZATIONS \
--warning_level VERBOSE \
--output_wrapper "(function(){%output%})();" \
--js "$INPUT" \
Expand Down
47 changes: 41 additions & 6 deletions share/pdf2htmlEX.js.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var CSS_CLASS_NAMES = {
page_data : '@CSS_PAGE_DATA_CN@',
background_image : '@CSS_BACKGROUND_IMAGE_CN@',
link : '@CSS_LINK_CN@',
input_radio : '@CSS_INPUT_RADIO_CN@',
__dummy__ : 'no comma'
};

Expand All @@ -61,10 +62,12 @@ var DEFAULT_CONFIG = {
'render_timeout' : 100,
// zoom ratio step for each zoom in/out event
'scale_step' : 0.9,
// register global key handler
// register global key handler, allowing navigation by keyboard
'key_handler' : true,
// register hashchange handler
// register hashchange handler, navigate to the location specified by the hash
'hashchange_handler' : true,
// register view history handler, allowing going back to the previous location
'view_history_handler' : true,

'__dummy__' : 'no comma'
};
Expand Down Expand Up @@ -261,7 +264,7 @@ Viewer.prototype = {
},

initialize_radio_button : function() {
var elements = document.getElementsByClassName('ir');
var elements = document.getElementsByClassName(CSS_CLASS_NAMES.input_radio);

for(var i = 0; i < elements.length; i++) {
var r = elements[i];
Expand Down Expand Up @@ -312,6 +315,12 @@ Viewer.prototype = {
}, false);
}

if (this.config['view_history_handler']) {
window.addEventListener('popstate', function(e) {
if(e.state) self.navigate_to_dest(e.state);
}, false);
}

// register schedule rendering
// renew old schedules since scroll() may be called frequently
this.container.addEventListener('scroll', function() {
Expand Down Expand Up @@ -759,13 +768,13 @@ Viewer.prototype = {

fit_width : function () {
var page_idx = this.cur_page_idx;
this.rescale(this.container.clientWidth / this.pages[page_idx].width(), false);
this.rescale(this.container.clientWidth / this.pages[page_idx].width(), true);
this.scroll_to(page_idx);
},

fit_height : function () {
var page_idx = this.cur_page_idx;
this.rescale(this.container.clientHeight / this.pages[page_idx].height(), false);
this.rescale(this.container.clientHeight / this.pages[page_idx].height(), true);
this.scroll_to(page_idx);
},
/**
Expand Down Expand Up @@ -797,6 +806,13 @@ Viewer.prototype = {
var detail_str = /** @type{string} */ (target.getAttribute('data-dest-detail'));
if (!detail_str) return;

if (this.config['view_history_handler']) {
try {
var cur_hash = this.get_current_view_hash();
window.history.replaceState(cur_hash, '', '#' + cur_hash);
window.history.pushState(detail_str, '', '#' + detail_str);
} catch(ex) { }
}
this.navigate_to_dest(detail_str, this.get_containing_page(target));
e.preventDefault();
},
Expand Down Expand Up @@ -883,7 +899,6 @@ Viewer.prototype = {

this.rescale(zoom, false);


var self = this;
/**
* page should of type Page
Expand Down Expand Up @@ -926,6 +941,26 @@ Viewer.prototype = {
var container = this.container;
container.scrollLeft += pos[0] - cur_target_pos[0];
container.scrollTop += pos[1] - cur_target_pos[1];
},

/**
* generate the hash for the current view
*/
get_current_view_hash : function() {
var detail = [];
var cur_page = this.pages[this.cur_page_idx];

detail.push(cur_page.num);
detail.push('XYZ');

var cur_pos = cur_page.view_position();
cur_pos = transform(cur_page.ictm, [cur_pos[0], cur_page.height()-cur_pos[1]]);
detail.push(cur_pos[0] / this.scale);
detail.push(cur_pos[1] / this.scale);

detail.push(this.scale);

return JSON.stringify(detail);
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/BackgroundRenderer/CairoBackgroundRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)
page_height = doc->getPageMediaHeight(pageno);
}

if (doc->getPageRotate(pageno) == 90 || doc->getPageRotate(pageno) == 270)
std::swap(page_height, page_width);

string fn = (char*)html_renderer->str_fmt("%s/bg%x.svg", (param.embed_image ? param.tmp_dir : param.dest_dir).c_str(), pageno);
if(param.embed_image)
html_renderer->tmp_files.add(fn);
Expand Down
2 changes: 1 addition & 1 deletion src/BackgroundRenderer/SplashBackgroundRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using std::unique_ptr;
const SplashColor SplashBackgroundRenderer::white = {255,255,255};

SplashBackgroundRenderer::SplashBackgroundRenderer(const string & imgFormat, HTMLRenderer * html_renderer, const Param & param)
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white), gTrue)
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white))
, html_renderer(html_renderer)
, param(param)
, format(imgFormat)
Expand Down
4 changes: 4 additions & 0 deletions src/HTMLRenderer/font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, FontInfo & info)
{
suffix = ".cid";
}
else if (subtype == "OpenType")
{
suffix = ".otf";
}
else
{
cerr << "Unknown subtype: " << subtype << endl;
Expand Down
15 changes: 3 additions & 12 deletions src/pdf2htmlEX.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// pdf2htmlEX.cc
//
// Copyright (C) 2012-2014 Lu Wang <coolwanglu@gmail.com>
// Copyright (C) 2012-2015 Lu Wang <coolwanglu@gmail.com>

#include <cstdio>
#include <cstdlib>
Expand Down Expand Up @@ -56,7 +56,7 @@ void show_usage_and_exit(const char * dummy = nullptr)
void show_version_and_exit(const char * dummy = nullptr)
{
cerr << "pdf2htmlEX version " << PDF2HTMLEX_VERSION << endl;
cerr << "Copyright 2012-2014 Lu Wang <coolwanglu@gmail.com> and other contributors" << endl;
cerr << "Copyright 2012-2015 Lu Wang <coolwanglu@gmail.com> and other contributors" << endl;
cerr << "Libraries: " << endl;
cerr << " poppler " << POPPLER_VERSION << endl;
cerr << " libfontforge " << ffw_get_version() << endl;
Expand All @@ -76,13 +76,6 @@ void show_version_and_exit(const char * dummy = nullptr)
#endif
cerr << endl;

// TODO: define constants
if(ffw_get_version() < 20130101LL)
{
cerr << endl
<< "Warning: pdf2htmlEX has been built with a too old version of Fontforge, which is not supported." << endl;
}

cerr << endl;
exit(EXIT_SUCCESS);
}
Expand Down Expand Up @@ -255,7 +248,6 @@ void check_param()
if(get_suffix(param.input_filename) == ".pdf")
{
param.output_filename = s.substr(0, s.size() - 4) + ".html";

}
else
{
Expand Down Expand Up @@ -298,8 +290,7 @@ void check_param()
}
else
{
if(!param.split_pages)
param.css_filename = s + ".css";
param.css_filename = s + ".css";
}
}
if(param.outline_filename.empty())
Expand Down
14 changes: 12 additions & 2 deletions src/util/ffw.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ void ffw_prepare_font(void)
}
}
}

/*
* Wipe out font name
* browsers may rejects fonts with malformed font names
*/
free(sf->fontname);
sf->fontname = strcopy("");
}

void ffw_save(const char * filename)
Expand Down Expand Up @@ -276,8 +283,11 @@ void ffw_reencode_raw2(char ** mapping, int mapping_len, int force)

void ffw_cidflatten(void)
{
if(!cur_fv->sf->cidmaster)
err("Cannot flatten a non-CID font");
if(!cur_fv->sf->cidmaster)
{
fprintf(stderr, "Cannot flatten a non-CID font\n");
return;
}
SFFlatten(cur_fv->sf->cidmaster);
}

Expand Down
1 change: 1 addition & 0 deletions src/util/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

char *mkdtemp(char *temp);

#include <direct.h>
#define mkdir(A, B) _mkdir(A)
#define stat _stat

Expand Down
8 changes: 8 additions & 0 deletions test/browser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ def test_text_visibility(self):
def test_process_form(self):
self.run_test_case('with_form.pdf', ['--process-form', 1])

def test_invalid_unicode_issue477(self):
self.run_test_case('invalid_unicode_issue477.pdf')

def test_svg_background_with_page_rotation_issue402(self):
self.run_test_case('svg_background_with_page_rotation_issue402.pdf', ['--bg-format', 'svg'])

def test_fontfile3_opentype(self):
self.run_test_case('fontfile3_opentype.pdf', ['-l', 1])
Binary file added test/browser_tests/fontfile3_opentype.pdf
Binary file not shown.
Binary file added test/browser_tests/fontfile3_opentype/bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/browser_tests/fontfile3_opentype/f1.woff
Binary file not shown.
Binary file added test/browser_tests/fontfile3_opentype/f2.woff
Binary file not shown.
Binary file added test/browser_tests/fontfile3_opentype/f3.woff
Binary file not shown.
Loading