1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-21 20:50:07 +00:00

UI tweaking; --remove-unused-glyph is off by default

This commit is contained in:
Lu Wang 2013-05-01 20:01:24 +08:00
parent d4d85eac15
commit ca69f28a4f
7 changed files with 58 additions and 36 deletions

5
TODO
View File

@ -1,3 +1,8 @@
pc1.pdf
jyb.pdf
cjkmix2*.pdf
Sample4.pdf
- don't dump image when it is empty
== Future: ==

View File

@ -149,10 +149,10 @@ Specify the suffix of fonts extracted from the PDF file.
Decompose ligatures. For example 'fi' -> 'f''i'.
.TP
.B --remove-unused-glyph <0|1> (Default: 1)
.B --remove-unused-glyph <0|1> (Default: 0)
If set to 1, remove unused glyphs in embedded fonts in order to reduce the file size.
Try turning it off if you encounter segmentation fault or debris-like fonts.
Currently this option is experimental, turning it on may cause segmentation fault or debris-like fonts.
.TP
.B --auto-hint <0|1> (Default: 0)

View File

@ -2,7 +2,7 @@
/* Demo CSS for pdf2htmlEX */
/* Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> */
/* Part 1: Web Page Layout: Free to modify, except for a few of them which are required by pdf2htmlEX.js, see the comments */
#pdf-outline { /* PDF Outline */
#sidebar { /* Sidebar */
position:absolute;
top:0;
left:0;
@ -11,10 +11,12 @@
padding:0px;
margin:0px;
overflow:auto;
display:none;
}
#pdf-main { /* PDF container */
#outline {
}
#page-container { /* PDF container */
position:absolute;
top:0;
left:0px;
@ -24,9 +26,8 @@
}
@media screen {
/* for sidebar */
#pdf-outline.opened { display:block; }
#pdf-outline.opened + #pdf-main { left:250px; }
#pdf-main {
#sidebar.opened + #page-container { left:250px; }
#page-container {
/* `bottom' and `right' are required for lazy page loading in pdf2htmlEX.js (page visibility test)
* alternatively you may set width and height
*/
@ -42,7 +43,7 @@
margin:0;
-webkit-print-color-adjust:exact; /* enable printing background images for WebKit */
}
#pdf-main {
#page-container {
width:auto;
height:auto;
overflow:visible;
@ -54,7 +55,7 @@
}
/* Part 2: Page Elements: Modify with caution
* The followings are base classes, which are meant to be override by PDF specific classes
* So do not increase the specificity (e.g. ".classname" -> "#pdf-main .classname")
* So do not increase the specificity (e.g. ".classname" -> "#page-container .classname")
*/
.@CSS_PAGE_DECORATION_CN@ { /* page decoration */
position:relative;

View File

@ -2,30 +2,30 @@
/* Fancy styles */
/* Copyright 2013 Lu Wang <coolwanglu@gmail.com> */
@media screen {
#pdf-outline {
#sidebar {
background-color:#2f3236;
/* modified from http://philbit.com/svgpatterns/#crossstripes */
background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjNDAzYzNmIj48L3JlY3Q+CjxwYXRoIGQ9Ik0wIDBMNCA0Wk00IDBMMCA0WiIgc3Ryb2tlLXdpZHRoPSIxIiBzdHJva2U9IiMxZTI5MmQiPjwvcGF0aD4KPC9zdmc+");
font-family: Georgia, serif;
font-size:13px;
width:243px;
padding:0 0 0 7px;
}
#pdf-outline ul {
margin:0 0.5em;
#outline {
font-family:Georgia,Times,"Times New Roman",serif;
font-size:13px;
margin:2em 1em;
}
#outline ul {
padding:0;
}
#pdf-outline li {
#outline li {
list-style-type:none;
margin:1em 0;
}
#pdf-outline li > ul {
#outline li > ul {
margin-left: 1em;
}
#pdf-outline a,
#pdf-outline a:visited,
#pdf-outline a:hover,
#pdf-outline a:active {
#outline a,
#outline a:visited,
#outline a:hover,
#outline a:active {
line-height:1.2;
color:#e8e8e8;
text-overflow:ellipsis;
@ -33,14 +33,19 @@
text-decoration:none;
display:block;
overflow:hidden;
outline:0;
}
#pdf-outline a:hover {
#outline a:hover {
color:rgb(0,204,255);
}
#pdf-main {
#page-container {
background-color:#9e9e9e;
/* http://philbit.com/svgpatterns/#thinstripes */
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1IiBoZWlnaHQ9IjUiPgo8cmVjdCB3aWR0aD0iNSIgaGVpZ2h0PSI1IiBmaWxsPSIjOWU5ZTllIj48L3JlY3Q+CjxwYXRoIGQ9Ik0wIDVMNSAwWk02IDRMNCA2Wk0tMSAxTDEgLTFaIiBzdHJva2U9IiM4ODgiIHN0cm9rZS13aWR0aD0iMSI+PC9wYXRoPgo8L3N2Zz4=");
-moz-transition:left 0.5s;
-webkit-transition:left 0.5s;
-o-transition:left 0.5s;
transition:left 0.5s:
}
.@CSS_PAGE_DECORATION_CN@ {
margin: 13px auto;
@ -50,10 +55,10 @@
@-moz-keyframes fadein { from { opacity:0;} to { opacity:1;} }
@-webkit-keyframes fadein { from { opacity:0;} to { opacity:1;} }
@-o-keyframes fadein { from { opacity:0;} to { opacity: 1;} }
.@CSS_PAGE_CONTENT_BOX_CN@.opened { /* used by pdf2htmlEX.js, to show/hide pages */
-moz-animation: fadein 100ms;
-webkit-animation: fadein 100ms;
-o-animation: fadein 100ms;
animation: fadein 100ms;
}
}

View File

@ -35,7 +35,11 @@ $css
# entry point of pdf2htmlEX
"""
<script type="text/javascript">
new pdf2htmlEX.Viewer('pdf-main', 'pdf-outline');
new pdf2htmlEX.Viewer({
container_id : 'page-container',
sidebar_id : 'sidebar',
outline_id : 'outline'
});
</script>
"""
@ -45,23 +49,28 @@ new pdf2htmlEX.Viewer('pdf-main', 'pdf-outline');
<body>
"""
# The container of outline
# The sidbar
# By default this is hidden, pdf2htmlEX.js will add the 'opened' class if it is not empty
# You can add a class 'opened' here if you want it always opened or you don't use pdf2htmlEX.js
# e.g.
# <div id="pdf-outline" class="opened">
# <div id="sidebar" class="opened">
"""
<div id="pdf-outline">
<div id="sidebar">
"""
# container of outlines
"""
<div id="outline">
"""
$outline
"""
</div>
</div>
"""
# The container of PDF pages
# check base.css for an example and requirements of its CSS styles
"""
<div id="pdf-main">
<div id="page-container">
"""
$pages
"""

View File

@ -103,9 +103,10 @@ var pdf2htmlEX = (function(){
}
});
pdf2htmlEX.Viewer = function(container_id, outline_id) {
this.container_id = container_id;
this.outline_id = outline_id;
pdf2htmlEX.Viewer = function(config) {
this.container_id = config['container_id'];
this.sidebar_id = config['sidebar_id'];
this.outline_id = config['outline_id'];
this.init_before_loading_content();
var _ = this;
@ -123,12 +124,13 @@ var pdf2htmlEX = (function(){
},
init_after_loading_content : function() {
this.sidebar = $('#'+this.sidebar_id);
this.outline = $('#'+this.outline_id);
this.container = $('#'+this.container_id);
// Open the outline if nonempty
if(this.outline.children().length > 0) {
this.outline.addClass('opened');
this.sidebar.addClass('opened');
}
// collect pages

View File

@ -85,7 +85,7 @@ void parse_options (int argc, char **argv)
.add("embed-external-font", &param.embed_external_font, 1, "embed local match for external fonts")
.add("font-suffix", &param.font_suffix, ".ttf", "suffix for embedded font files (.ttf,.otf,.woff,.svg)")
.add("decompose-ligature", &param.decompose_ligature, 0, "decompose ligatures, such as \uFB01 -> fi")
.add("remove-unused-glyph", &param.remove_unused_glyph, 1, "remove unused glyphs in embedded fonts")
.add("remove-unused-glyph", &param.remove_unused_glyph, 0, "remove unused glyphs in embedded fonts")
.add("auto-hint", &param.auto_hint, 0, "use fontforge autohint on fonts without hints")
.add("external-hint-tool", &param.external_hint_tool, "", "external tool for hinting fonts (overrides --auto-hint)")
.add("stretch-narrow-glyph", &param.stretch_narrow_glyph, 0, "stretch narrow glyphs instead of padding them")