diff --git a/.travis.yml b/.travis.yml index ceaba7314..158967db0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/3rdparty/poppler/git/CairoFontEngine.cc b/3rdparty/poppler/git/CairoFontEngine.cc index 229a86cf0..4571b7fba 100644 --- a/3rdparty/poppler/git/CairoFontEngine.cc +++ b/3rdparty/poppler/git/CairoFontEngine.cc @@ -59,7 +59,7 @@ #endif /* - * multi thread disabled by WangLu + * pdf2htmlEX: disabled multi thread #if MULTITHREADED # define fontEngineLocker() MutexLocker locker(&mutex) #else @@ -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)"); @@ -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 @@ -783,7 +784,7 @@ CairoFontEngine::~CairoFontEngine() { delete fontCache[i]; } /* - * multi thread disabled by WangLu + * pdf2htmlEX: disabled multi thread #if MULTITHREADED gDestroyMutex(&mutex); #endif diff --git a/3rdparty/poppler/git/CairoFontEngine.h b/3rdparty/poppler/git/CairoFontEngine.h index 432f10715..96cc4c15f 100644 --- a/3rdparty/poppler/git/CairoFontEngine.h +++ b/3rdparty/poppler/git/CairoFontEngine.h @@ -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 diff --git a/3rdparty/poppler/git/CairoOutputDev.h b/3rdparty/poppler/git/CairoOutputDev.h index 727c687b8..f345e3993 100644 --- a/3rdparty/poppler/git/CairoOutputDev.h +++ b/3rdparty/poppler/git/CairoOutputDev.h @@ -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); diff --git a/CMakeLists.txt b/CMakeLists.txt index 9db270a2b..3fdabb0d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 ) @@ -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 ) diff --git a/ChangeLog b/ChangeLog index 1bc2ec8fb..6f885c8ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/share/build_js.sh b/share/build_js.sh index c03eba35c..a6e7d6156 100755 --- a/share/build_js.sh +++ b/share/build_js.sh @@ -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" \ diff --git a/share/pdf2htmlEX.js.in b/share/pdf2htmlEX.js.in index 20d4c70de..37f100844 100644 --- a/share/pdf2htmlEX.js.in +++ b/share/pdf2htmlEX.js.in @@ -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' }; @@ -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' }; @@ -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]; @@ -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() { @@ -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); }, /** @@ -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(); }, @@ -883,7 +899,6 @@ Viewer.prototype = { this.rescale(zoom, false); - var self = this; /** * page should of type Page @@ -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); } }; diff --git a/src/BackgroundRenderer/CairoBackgroundRenderer.cc b/src/BackgroundRenderer/CairoBackgroundRenderer.cc index 64a265412..1ce6eacce 100644 --- a/src/BackgroundRenderer/CairoBackgroundRenderer.cc +++ b/src/BackgroundRenderer/CairoBackgroundRenderer.cc @@ -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); diff --git a/src/BackgroundRenderer/SplashBackgroundRenderer.cc b/src/BackgroundRenderer/SplashBackgroundRenderer.cc index b2d167efb..55b5322e1 100644 --- a/src/BackgroundRenderer/SplashBackgroundRenderer.cc +++ b/src/BackgroundRenderer/SplashBackgroundRenderer.cc @@ -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) diff --git a/src/HTMLRenderer/font.cc b/src/HTMLRenderer/font.cc index 2ca9fa31a..10ff21565 100644 --- a/src/HTMLRenderer/font.cc +++ b/src/HTMLRenderer/font.cc @@ -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; diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 8f7edb49a..b56e8e9f7 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -1,6 +1,6 @@ // pdf2htmlEX.cc // -// Copyright (C) 2012-2014 Lu Wang +// Copyright (C) 2012-2015 Lu Wang #include #include @@ -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 and other contributors" << endl; + cerr << "Copyright 2012-2015 Lu Wang and other contributors" << endl; cerr << "Libraries: " << endl; cerr << " poppler " << POPPLER_VERSION << endl; cerr << " libfontforge " << ffw_get_version() << endl; @@ -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); } @@ -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 { @@ -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()) diff --git a/src/util/ffw.c b/src/util/ffw.c index ee24a2aed..b88efce23 100644 --- a/src/util/ffw.c +++ b/src/util/ffw.c @@ -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) @@ -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); } diff --git a/src/util/mingw.h b/src/util/mingw.h index f7a3b52a6..89abf8a33 100644 --- a/src/util/mingw.h +++ b/src/util/mingw.h @@ -14,6 +14,7 @@ char *mkdtemp(char *temp); +#include #define mkdir(A, B) _mkdir(A) #define stat _stat diff --git a/test/browser_tests.py b/test/browser_tests.py index 278cbd870..08931c5e6 100644 --- a/test/browser_tests.py +++ b/test/browser_tests.py @@ -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]) diff --git a/test/browser_tests/fontfile3_opentype.pdf b/test/browser_tests/fontfile3_opentype.pdf new file mode 100644 index 000000000..8e66228c8 Binary files /dev/null and b/test/browser_tests/fontfile3_opentype.pdf differ diff --git a/test/browser_tests/fontfile3_opentype/bg1.png b/test/browser_tests/fontfile3_opentype/bg1.png new file mode 100644 index 000000000..76492401b Binary files /dev/null and b/test/browser_tests/fontfile3_opentype/bg1.png differ diff --git a/test/browser_tests/fontfile3_opentype/f1.woff b/test/browser_tests/fontfile3_opentype/f1.woff new file mode 100644 index 000000000..4f98c86f6 Binary files /dev/null and b/test/browser_tests/fontfile3_opentype/f1.woff differ diff --git a/test/browser_tests/fontfile3_opentype/f2.woff b/test/browser_tests/fontfile3_opentype/f2.woff new file mode 100644 index 000000000..b1a8ba266 Binary files /dev/null and b/test/browser_tests/fontfile3_opentype/f2.woff differ diff --git a/test/browser_tests/fontfile3_opentype/f3.woff b/test/browser_tests/fontfile3_opentype/f3.woff new file mode 100644 index 000000000..b9eda88ab Binary files /dev/null and b/test/browser_tests/fontfile3_opentype/f3.woff differ diff --git a/test/browser_tests/fontfile3_opentype/fontfile3_opentype.html b/test/browser_tests/fontfile3_opentype/fontfile3_opentype.html new file mode 100644 index 000000000..fda94e2b5 --- /dev/null +++ b/test/browser_tests/fontfile3_opentype/fontfile3_opentype.html @@ -0,0 +1,156 @@ + + + + + + + + + + + + + +
+
PDFClown
Generated by PDF Clown on Sat Mar 05 20:06:01 CET 2011
For more info, visit http://www.pdfclown.org
Welcome
This is a sample document
that merely demonstrates
some basic graphics
features supported by
PDF Clown.
Enjoy!
PS: As promised, since version 0.0.3 PDF Clown has supported embedded latin
OpenFont/TrueType and non-embedded Type 1 fonts along with paragraph construction facilities
through the BlockComposer class.
Since version 0.0.4 the content stream stack has been completed, providing fully object-oriented
access to the graphics objects that describe the contents on a page. It's a great step towards
a whole bunch of possibilities, such as text extraction/replacement, that next releases will
progressively exploit.
Since version 0.0.6 it has supported Unicode for OpenFont/TrueType fonts.
This page was crafted with the nice
LazyDog font
(by Paul Neave, www.neave.com)
Source: http://www.wikipedia.org/
+
+ + diff --git a/test/browser_tests/invalid_unicode_issue477.pdf b/test/browser_tests/invalid_unicode_issue477.pdf new file mode 100644 index 000000000..ba5bbaf36 Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477.pdf differ diff --git a/test/browser_tests/invalid_unicode_issue477/bg1.png b/test/browser_tests/invalid_unicode_issue477/bg1.png new file mode 100644 index 000000000..6c8ed5bd5 Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477/bg1.png differ diff --git a/test/browser_tests/invalid_unicode_issue477/f1.woff b/test/browser_tests/invalid_unicode_issue477/f1.woff new file mode 100644 index 000000000..f57ef07b2 Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477/f1.woff differ diff --git a/test/browser_tests/invalid_unicode_issue477/f2.woff b/test/browser_tests/invalid_unicode_issue477/f2.woff new file mode 100644 index 000000000..cf106ef5e Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477/f2.woff differ diff --git a/test/browser_tests/invalid_unicode_issue477/f3.woff b/test/browser_tests/invalid_unicode_issue477/f3.woff new file mode 100644 index 000000000..547085cc3 Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477/f3.woff differ diff --git a/test/browser_tests/invalid_unicode_issue477/f4.woff b/test/browser_tests/invalid_unicode_issue477/f4.woff new file mode 100644 index 000000000..e9a5a7325 Binary files /dev/null and b/test/browser_tests/invalid_unicode_issue477/f4.woff differ diff --git a/test/browser_tests/invalid_unicode_issue477/invalid_unicode_issue477.html b/test/browser_tests/invalid_unicode_issue477/invalid_unicode_issue477.html new file mode 100644 index 000000000..10b7929cc --- /dev/null +++ b/test/browser_tests/invalid_unicode_issue477/invalid_unicode_issue477.html @@ -0,0 +1,158 @@ + + + + + + + + + + + + + +
+
CourseDescription
Asthecoursetitlesuggests,thisclassismeanttoacquaintyouwiththeliteraryandrhetoricaltraditionoftheessay,a
genrewhichhasbeendescribedbyonescholaras"themeetinggroundbetweenartandphilosophy,"andbyanother
as"theplacewheretheselffindsapatternintheworld,andtheworldfindsapatternintheself".Thoughtheessayis
partofatraditionofprosewhichstretchesbacktoantiquity,itisalsoathoroughlymodernandpopularformof
writing,foundinprintmediaandontheweb.Thisclasswillemphasizeaspecificrangeoftheessay'sfunctions:
Theessayascommentaryonthewritingofothersandontextual/numericaldata.
Theessayasthediscoveryofmeaninginpersonalexperiencethroughthenarrationofexperience.
Theessayasavehicleconveyingspecializedknowledgetoageneralaudience.
Bytheendofthesemester,youwillbefamiliarwitheachofthesemodesintheclassreadingandinyourownwriting.
CourseRequirements
Assignedreading(seeschedulebelow)
5essays(57pageseach),roughand
finaldrafts
2oralreports(510minuteslong)
Participationinclassdiscussion
Inclasspeerreview(seebelow)
Peerreviewrelatedphotocopying
Inclassandoutofclasswritingexercises(12pp)
Maintenanceofaportfolio(seebelow)
Regularattendance(seebelow)
NOTE:Itisnotpossibletopassthecourseifyouhavefailedoneoftheessays,ifyouhavefailedtoparticipatein
peerreview,orifyouhavemorethan5absences.Failuretoparticipateinclassdiscussionwillresultinadeduction
ofonehalforonegradepointfromthefinalgrade,dependingontheseverityoftheproblem.
AttendancePolicy
Becausethiscourseisalaboratoryforcompositionandinterpretation,youmustbepresentateveryclassandarrive
inatimelyfashion.Only5unexcusedabsencesarepermitted.
Anabsenceonapeerreviewdaywillcountasaregularabsenceand
resultinthedeductionoftwogradestepsfrom
thefinaldraft(e.g.BreducedtoC+).2latenesses=1absence.YouarelateifyouarriveatclassafterItake
attendance.
Incaseofpersonalemergency,seriousillness,orinjury
,donotcometoclass,butinformmeofthereasonforyour
absenceassoonaspossible.[Adean'snotewillbenecessarytobeexcusedfromclassunderthesecircumstances.]
Absenceforreligiousobservanceisautomaticallyexcused;nonetheless,pleaseinformmebeforethefact.
+
+ + diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402.pdf b/test/browser_tests/svg_background_with_page_rotation_issue402.pdf new file mode 100644 index 000000000..a7047d74d Binary files /dev/null and b/test/browser_tests/svg_background_with_page_rotation_issue402.pdf differ diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402/bg1.svg b/test/browser_tests/svg_background_with_page_rotation_issue402/bg1.svg new file mode 100644 index 000000000..942836d3b --- /dev/null +++ b/test/browser_tests/svg_background_with_page_rotation_issue402/bg1.svg @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402/f1.woff b/test/browser_tests/svg_background_with_page_rotation_issue402/f1.woff new file mode 100644 index 000000000..27d072256 Binary files /dev/null and b/test/browser_tests/svg_background_with_page_rotation_issue402/f1.woff differ diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402/f2.woff b/test/browser_tests/svg_background_with_page_rotation_issue402/f2.woff new file mode 100644 index 000000000..bab82a1a4 Binary files /dev/null and b/test/browser_tests/svg_background_with_page_rotation_issue402/f2.woff differ diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402/f3.woff b/test/browser_tests/svg_background_with_page_rotation_issue402/f3.woff new file mode 100644 index 000000000..9558d4bd8 Binary files /dev/null and b/test/browser_tests/svg_background_with_page_rotation_issue402/f3.woff differ diff --git a/test/browser_tests/svg_background_with_page_rotation_issue402/svg_background_with_page_rotation_issue402.html b/test/browser_tests/svg_background_with_page_rotation_issue402/svg_background_with_page_rotation_issue402.html new file mode 100644 index 000000000..352ca53ff --- /dev/null +++ b/test/browser_tests/svg_background_with_page_rotation_issue402/svg_background_with_page_rotation_issue402.html @@ -0,0 +1,641 @@ + + + + + + + + + + + + + +
+
Airports & AAL -
A
irport Authorization List
Airway Manual
Airport Authorization List
R = Regular F = Fueling A = Alternate AO = Off-Line Alternate (T) = ETOPS Alternate
[
SA
Q]
= S
p
ecial Air
p
ort
Q
ualification
[
T
Q]
= Theater
Q
ualification ~ or blank = Emer
g
enc
y
Air
p
ort
ICAO Location
IATA
Longest Rwy
24 Hrs
Precision App
A319
A320
A330-200
A330-300
B717
B737-700
B737-800
B737-900
B747
B757
B757-200ER
B757-300ER
B767-300
B767-300ER
B767-300ET
B767-400
B777-200ER
B777-200LR
MD88
MD90
ENCN KRISTIANSAND, NO KRS 6.6 N Y (T) (T)
ENGMOSLO, NO OSL11.8YY~~AOAO~~~~~AOAOAO(T)AO~AOAOAO~~
ENSB SVALBARD, NO [SAQ] LYR 8.1 Y Y (T) (T) (T)
ENVATRONDHEIM, NO TRD 9.0YY~~(T)(T)~~~~~~AO~(T)AO~(T)AOAO~~
ENZV STAVANGER, NO SVG 8.3 Y Y (T) (T) (T) (T) (T)
EPWA
WARSAW PL
WAW
12 1
Y
Y
AO
AO
AO
AO
EPWA
WARSAW
,
PL
WAW
12
.
1
Y
Y
~~
AO
AO
~~~~~~~~~
AO
~
AO
~~~~
ESGGGOTEBORG, SE GOT10.8YN~~~~~~~~~~AO~~AO~AO~~~~
ESMSMALMO, SE MMX9.1YY~~AOAO~~~~~~AO~~AO~AO~~~~
ESOW VAESTERAAS, STOCKHOLM, SE VST 8.4 N N ~~~~~~~~~~AO~~AO~AO~~~~
ESSA ARLANDA, STOCKHOLM, SE [TQ] ARN 10.8 Y Y ~ ~ F F ~~~~~~R~~R~~~~~~
ESSD BORLANGE, SE BLE 7.5 N Y
ETAR RAMSTEIN, DE RMS 10.4 Y Y
EVRA RIGA, LV RIX 10.4 Y Y
FABLBLOEMFONTEIN, ZA BFN 8.3NN~~~~~~~~~~~~~AO~AOAOAO~~
FACT CAPE TOWN, ZA CPT 10.5 Y Y ~~~~~~~~~~~~~AO~AOAOAO~~
FALEDURBAN, ZA DUR12.1YY~~~~~~~~ ~~~~AO~AOAOAO~~
FAOR JOHANNESBURG, ZA [TQ] JNB 14.4 Y Y ~~~~~~~~~~~~~A~ARR~~
FBSKGABORONE, BW GBE13.1NY~~~~~~~~~~~~~AO~AOAOAO~~
FCBB BRAZZAVILLE, CG BZV 10.8 Y Y
FCPP POINTE NOIRE, CG PNR 8.5 Y Y
FGSL MALABO, GQ SSG 9.6 Y Y
FHAW ASCENSION, SH ASI 10.0 Y N (T) (T) (T) (T) (T) (T)
FKKD DOUALA, CM DLA 9.3 Y Y
FKYS YAOUNDE, CM NSI 11.1 Y N
FNLU LUANDA, AO LAD 12.1 Y N (T) (T) (T) (T) (T) (T) (T)
March 28, 2014 OPS-6TA.AD&AAL.2.11
Copyright © Delta Air Lines, Inc. See title page for details.
+
+ + diff --git a/test/test.py b/test/test.py index 253abaae0..3d4ee8c1a 100755 --- a/test/test.py +++ b/test/test.py @@ -100,14 +100,13 @@ def run_pdf2htmlEX(self, args): test_names = [] for name in sys.argv[1:]: - if name.find('.') != -1: - test_names.append(name) - else: + test_names.append(name) + if name.find('.') == -1: for m in all_classes: test_names.append(m + '.' + name) for module in all_modules: - if len(test_names) > 0: + if len(test_names) > 0 and module.__name__ not in test_names: for n in test_names: try: suites.append(loader.loadTestsFromName(n, module)) diff --git a/test/test_output.py b/test/test_output.py index e7e30a3dc..0f5e2d2ce 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -# Test output files +# Check pdf2htmlEX does not crash, and produces correct files. +# Do not check the content of the files import unittest import os @@ -9,78 +10,81 @@ @unittest.skipIf(Common.GENERATING_MODE, 'Skipping test_output in generating mode') class test_output(Common, unittest.TestCase): - def run_test_case(self, input_file, expected_output_files, args=[]): + def run_test_case(self, input_file, args=[], expected_output_files=None): args = list(args) args.insert(0, os.path.join(self.TEST_DIR, 'test_output', input_file)) - self.assertItemsEqual(self.run_pdf2htmlEX(args)['output_files'], expected_output_files) + result = self.run_pdf2htmlEX(args) + if expected_output_files: + self.assertItemsEqual(result['output_files'], expected_output_files) def test_generate_single_html_default_name_single_page_pdf(self): - self.run_test_case('1-page.pdf', ['1-page.html']) + self.run_test_case('1-page.pdf', expected_output_files = ['1-page.html']) def test_generate_single_html_default_name_multiple_page_pdf(self): - self.run_test_case('2-pages.pdf', ['2-pages.html']) + self.run_test_case('2-pages.pdf', expected_output_files = ['2-pages.html']) def test_generate_single_html_specify_name_single_page_pdf(self): - self.run_test_case('1-page.pdf', ['foo.html'], ['foo.html']) + self.run_test_case('1-page.pdf', ['foo.html'], expected_output_files = ['foo.html']) def test_generate_single_html_specify_name_multiple_page_pdf(self): - self.run_test_case('2-pages.pdf', ['foo.html'], ['foo.html']) + self.run_test_case('2-pages.pdf', ['foo.html'], expected_output_files = ['foo.html']) def test_generate_split_pages_default_name_single_page(self): - self.run_test_case('1-page.pdf', ['1-page.html', '1-page1.page'], ['--split-pages', 1]) + self.run_test_case('1-page.pdf', ['--split-pages', 1], expected_output_files = ['1-page.html', '1-page1.page']) def test_generate_split_pages_default_name_multiple_pages(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', '3-pages1.page', '3-pages2.page', '3-pages3.page'], ['--split-pages', 1]) + self.run_test_case('3-pages.pdf', ['--split-pages', 1], expected_output_files = ['3-pages.html', '3-pages1.page', '3-pages2.page', '3-pages3.page']) def test_generate_split_pages_specify_name_single_page(self): - self.run_test_case('1-page.pdf', ['1-page.html', 'foo1.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz']) + self.run_test_case('1-page.pdf', ['--split-pages', 1, '--page-filename', 'foo.xyz'], expected_output_files = ['1-page.html', 'foo1.xyz']) def test_generate_split_pages_specify_name_multiple_pages(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'foo1.xyz', 'foo2.xyz', 'foo3.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'foo.xyz'], expected_output_files = ['3-pages.html', 'foo1.xyz', 'foo2.xyz', 'foo3.xyz']) def test_generate_split_pages_specify_name_formatter_multiple_pages(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o.xyz', 'fo2o.xyz', 'fo3o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%do.xyz'], expected_output_files = ['3-pages.html', 'fo1o.xyz', 'fo2o.xyz', 'fo3o.xyz']) def test_generate_split_pages_specify_name_formatter_with_padded_zeros_multiple_pages(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo001o.xyz', 'fo002o.xyz', 'fo003o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%03do.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%03do.xyz'], expected_output_files = ['3-pages.html', 'fo001o.xyz', 'fo002o.xyz', 'fo003o.xyz']) def test_generate_split_pages_specify_name_only_first_formatter_gets_taken(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f1o%do.xyz', 'f2o%do.xyz', 'f3o%do.xyz'], ['--split-pages', 1, '--page-filename', 'f%do%do.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%do%do.xyz'], expected_output_files = ['3-pages.html', 'f1o%do.xyz', 'f2o%do.xyz', 'f3o%do.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_s(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%soo1.xyz', 'f%soo2.xyz', 'f%soo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%soo.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%soo.xyz'], expected_output_files = ['3-pages.html', 'f%soo1.xyz', 'f%soo2.xyz', 'f%soo3.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_p(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%poo1.xyz', 'f%poo2.xyz', 'f%poo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%poo.xyz']) - + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%poo.xyz'], expected_output_files = ['3-pages.html', 'f%poo1.xyz', 'f%poo2.xyz', 'f%poo3.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_n(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%noo1.xyz', 'f%noo2.xyz', 'f%noo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%noo.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%noo.xyz'], expected_output_files = ['3-pages.html', 'f%noo1.xyz', 'f%noo2.xyz', 'f%noo3.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%oo1.xyz', 'f%%oo2.xyz', 'f%%oo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%%oo.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%%oo.xyz'], expected_output_files = ['3-pages.html', 'f%%oo1.xyz', 'f%%oo2.xyz', 'f%%oo3.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%o1o.xyz', 'f%%o2o.xyz', 'f%%o3o.xyz'], ['--split-pages', 1, '--page-filename', 'f%%o%do.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%%o%do.xyz'], expected_output_files = ['3-pages.html', 'f%%o1o.xyz', 'f%%o2o.xyz', 'f%%o3o.xyz']) def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o%%.xyz', 'fo2o%%.xyz', 'fo3o%%.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do%%.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%do%%.xyz'], expected_output_files = ['3-pages.html', 'fo1o%%.xyz', 'fo2o%%.xyz', 'fo3o%%.xyz']) def test_generate_split_pages_specify_name_only_formatter_starts_part_way_through_invalid_formatter(self): - self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%021oo.xyz', 'f%022oo.xyz', 'f%023oo.xyz'], ['--split-pages', 1, '--page-filename', 'f%02%doo.xyz']) + self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%02%doo.xyz'], expected_output_files = ['3-pages.html', 'f%021oo.xyz', 'f%022oo.xyz', 'f%023oo.xyz']) def test_generate_split_pages_specify_output_filename_no_formatter_no_extension(self): - self.run_test_case('1-page.pdf', ['1-page.html', 'foo1'], ['--split-pages', 1, '--page-filename', 'foo']) + self.run_test_case('1-page.pdf', ['--split-pages', 1, '--page-filename', 'foo'], expected_output_files = ['1-page.html', 'foo1']) def test_generate_single_html_name_specified_format_characters_percent_d(self): - self.run_test_case('2-pages.pdf', ['foo%d.html'], ['foo%d.html']) + self.run_test_case('2-pages.pdf', ['foo%d.html'], expected_output_files = ['foo%d.html']) def test_generate_single_html_name_specified_format_characters_percent_p(self): - self.run_test_case('2-pages.pdf', ['foo%p.html'], ['foo%p.html']) + self.run_test_case('2-pages.pdf', ['foo%p.html'], expected_output_files = ['foo%p.html']) def test_generate_single_html_name_specified_format_characters_percent_n(self): - self.run_test_case('2-pages.pdf', ['foo%n.html'], ['foo%n.html']) + self.run_test_case('2-pages.pdf', ['foo%n.html'], expected_output_files = ['foo%n.html']) def test_generate_single_html_name_specified_format_characters_percent_percent(self): - self.run_test_case('2-pages.pdf', ['foo%%.html'], ['foo%%.html']) + self.run_test_case('2-pages.pdf', ['foo%%.html'], expected_output_files = ['foo%%.html']) + def test_issue501(self): + self.run_test_case('issue501', ['--split-pages', 1, '--embed-css', 0]); diff --git a/test/test_output/issue501 b/test/test_output/issue501 new file mode 100644 index 000000000..5971ccfd1 Binary files /dev/null and b/test/test_output/issue501 differ