1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-07 18:30:34 +00:00

working on printing

This commit is contained in:
Lu Wang 2013-02-06 01:05:58 +08:00
parent 3e7e5c5662
commit 46c1161b50
2 changed files with 37 additions and 15 deletions

View File

@ -1,5 +1,7 @@
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* Base CSS */ /* Base CSS */
/* Copyright 2012 Lu Wang <coolwanglu@gmail.com> */ /* Copyright 2012,2013 Lu Wang <coolwanglu@gmail.com> */
#pdf-outline { /* PDF Outline */ #pdf-outline { /* PDF Outline */
position:absolute; position:absolute;
top:0; top:0;
@ -12,9 +14,6 @@
background-color:#707070; background-color:#707070;
display:none; display:none;
} }
#pdf-outline.opened {
display:block;
}
#pdf-outline ul { #pdf-outline ul {
margin-left:13px; margin-left:13px;
margin-right:3px; margin-right:3px;
@ -41,19 +40,32 @@
position:absolute; position:absolute;
top:0; top:0;
left:0px; left:0px;
bottom:0;
right:0;
overflow:auto;
background-color:#808080;
/* margin & border-width have to be 0, /* margin & border-width have to be 0,
* otherwise pdf2htmlEX may not calculate the coordinates correctly * otherwise pdf2htmlEX may not calculate the coordinates correctly
*/ */
margin:0; margin:0;
border-width:0; border-width:0;
} }
#pdf-outline.opened + #pdf-main { @media screen {
left:200px; #pdf-outline.opened { display:block; }
#pdf-outline.opened + #pdf-main { left:200px; }
#pdf-main {
bottom:0;
right:0;
overflow:auto;
background-color:#808080;
}
} }
@media print {
@page { margin:0; }
body { margin:0; }
#pdf-main {
width:auto;
height:auto;
background-color:transparent;
}
}
/* /*
* The followings are base classes, which are meant to be override by PDF specific classes * The followings are base classes, which are meant to be override by PDF specific classes
* So do not increase the specificity * So do not increase the specificity
@ -94,6 +106,9 @@
-webkit-transform-origin:0% 0%; -webkit-transform-origin:0% 0%;
-o-transform-origin:0% 0%; -o-transform-origin:0% 0%;
} }
.b.opened { /* used by pdf2htmlEX.js, to show/hide pages */
display:block;
}
.l { /* text line */ .l { /* text line */
position:absolute; position:absolute;
white-space:pre; white-space:pre;
@ -134,4 +149,12 @@ span {
-webkit-transform-origin:0% 100%; -webkit-transform-origin:0% 100%;
-o-transform-origin:0% 100%; -o-transform-origin:0% 100%;
} }
@media print {
.d {
margin:0;
box-shadow:none;
page-break-after:always;
page-break-inside:avoid;
}
}
/* Base CSS END */ /* Base CSS END */

View File

@ -1,6 +1,5 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* vim modeline copied from pdf.js */ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* /*
* pdf2htmlEX.js * pdf2htmlEX.js
@ -53,14 +52,14 @@ var pdf2htmlEX = (function(){
}; };
$.extend(Page.prototype, { $.extend(Page.prototype, {
hide : function(){ hide : function(){
this.b.hide(); this.b.removeClass('opened');
}, },
show : function(){ show : function(){
if(Math.abs(this.set_r - this.cur_r) > EPS) { if(Math.abs(this.set_r - this.cur_r) > EPS) {
this.cur_r = this.set_r; this.cur_r = this.set_r;
this.b.css('transform', 'scale('+this.cur_r.toFixed(3)+')'); this.b.css('transform', 'scale('+this.cur_r.toFixed(3)+')');
} }
this.b.show(); this.b.addClass('opened');
}, },
rescale : function(ratio, is_relative) { rescale : function(ratio, is_relative) {
if(ratio == 0) { if(ratio == 0) {
@ -147,7 +146,7 @@ var pdf2htmlEX = (function(){
pre_hide_pages : function() { pre_hide_pages : function() {
/* pages might have not been loaded yet, so add a CSS rule */ /* pages might have not been loaded yet, so add a CSS rule */
var s = '.b{display:none;}'; var s = '@media screen{.b{display:none;}}';
var n = document.createElement('style'); var n = document.createElement('style');
n.type = 'text/css'; n.type = 'text/css';
if (n.styleSheet) { if (n.styleSheet) {