diff --git a/prs-500.e4p b/prs-500.e4p
deleted file mode 100644
index 201a4e2ab6..0000000000
--- a/prs-500.e4p
+++ /dev/null
@@ -1,248 +0,0 @@
-
-
-
-
-
-
- Python
- Qt4
- Library to communicate with the Sony Reader PRS-500 via USB
-
- Kovid Goyal
- kovid@kovidgoyal.net
-
-
- libprs500
- communicate.py
-
-
- libprs500
- prstypes.py
-
-
- libprs500
- errors.py
-
-
- libprs500
- __init__.py
-
-
- setup.py
-
-
- libprs500
- cli
- terminfo.py
-
-
- libprs500
- cli
- main.py
-
-
- libprs500
- cli
- __init__.py
-
-
- libprs500
- gui
- main.py
-
-
- libprs500
- gui
- __init__.py
-
-
- libprs500
- lrf
- meta.py
-
-
- libprs500
- lrf
- __init__.py
-
-
- libprs500
- gui
- database.py
-
-
- libprs500
- gui
- editbook.py
-
-
- libprs500
- books.py
-
-
- libprs500
- gui
- widgets.py
-
-
- libprs500
- lrf
- makelrf.py
-
-
- libprs500
- ptempfile.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- epydoc.conf
-
-
- epydoc-pdf.conf
-
-
-
- libprs500
- gui
- main.py
-
-
- Subversion
-
-
-
- status
-
-
-
-
-
-
-
- log
-
-
-
-
-
-
-
- global
-
-
-
-
-
-
-
- update
-
-
-
-
-
-
-
- remove
-
-
-
-
-
-
-
- add
-
-
-
-
-
-
-
- tag
-
-
-
-
-
-
-
- export
-
-
-
-
-
-
-
- commit
-
-
-
-
-
-
-
- diff
-
-
-
-
-
-
-
- checkout
-
-
-
-
-
-
-
- history
-
-
-
-
-
-
-
-
-
-
-
- standardLayout
-
-
- True
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/setup.py b/setup.py
index 27f6c80ced..38301d2098 100644
--- a/setup.py
+++ b/setup.py
@@ -38,7 +38,7 @@ if sys.argv[1] == 'py2exe':
windows = [{'script' : 'src/libprs500/gui/main.py', 'dest_base':'prs500-gui',
'icon_resources':[(1,'icons/library.ico')]}]
excludes = ["Tkconstants", "Tkinter", "tcl", "_imagingtk",
- "ImageTk", "FixTk"]
+ "ImageTk", "FixTk", 'pydoc']
options = { 'py2exe' : {'includes' : ['sip', 'pkg_resources'],
'dist_dir' : py2exe_dir,
'packages' : ['PIL'],
@@ -87,7 +87,6 @@ Var MUI_TEMP
!define PY2EXE_DIR "C:\libprs500"
!define LIBUSB_DIR "C:\libusb-prs500"
!define LIBUNRAR_DIR "C:\Program Files\UnrarDLL"
-!define QT_DIR "C:\Qt\4.2.3\bin"
;------------------------------------------------------------------------------------------------------
;General
@@ -155,9 +154,7 @@ Section "libprs500" Seclibprs500
;ADD YOUR OWN FILES HERE...
File /r "${PY2EXE_DIR}\*"
- ; The next line can be commented out once py2exe starts including QtSvg.dll
- File "${QT_DIR}\QtSvg4.dll"
-
+
SetOutPath "$INSTDIR\driver"
File "${LIBUSB_DIR}\*.dll"
File "${LIBUSB_DIR}\*.sys"
diff --git a/src/libprs500/__init__.py b/src/libprs500/__init__.py
index 7680e1f161..96a417cbfc 100644
--- a/src/libprs500/__init__.py
+++ b/src/libprs500/__init__.py
@@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' E-book management software'''
-__version__ = "0.3.45"
+__version__ = "0.3.46"
__docformat__ = "epytext"
__author__ = "Kovid Goyal "
diff --git a/src/libprs500/ebooks/lrf/__init__.py b/src/libprs500/ebooks/lrf/__init__.py
index 8e8e041581..449d911b1c 100644
--- a/src/libprs500/ebooks/lrf/__init__.py
+++ b/src/libprs500/ebooks/lrf/__init__.py
@@ -29,11 +29,10 @@ __author__ = "Kovid Goyal "
class PRS500_PROFILE(object):
screen_width = 600
- screen_height = 800
- page_width = 575
- page_height = 747
+ screen_height = 775
dpi = 166
+
def profile_from_string(option, opt_str, value, parser):
if value == 'prs500':
setattr(parser.values, option.dest, PRS500_PROFILE)
@@ -66,11 +65,21 @@ def option_parser(usage):
profiles=['prs500']
parser.add_option('-o', '--output', action='store', default=None, \
help='Output file name. Default is derived from input filename')
- parser.add_option('-p', '--profile', default=PRS500_PROFILE, dest='profile', type='choice',
+ page = parser.add_option_group('PAGE OPTIONS')
+ page.add_option('-p', '--profile', default=PRS500_PROFILE, dest='profile', type='choice',
choices=profiles, action='callback', callback=profile_from_string,
help='''Profile of the target device for which this LRF is '''
'''being generated. Default: ''' + profiles[0] + \
''' Supported profiles: '''+', '.join(profiles))
+ page.add_option('--left-margin', default=20, dest='left_margin', type='int',
+ help='''Left margin of page. Default is %default px.''')
+ page.add_option('--right-margin', default=5, dest='right_margin', type='int',
+ help='''Right margin of page. Default is %default px.''')
+ page.add_option('--top-margin', default=10, dest='top_margin', type='int',
+ help='''Top margin of page. Default is %default px.''')
+ page.add_option('--bottom-margin', default=10, dest='bottom_margin', type='int',
+ help='''Bottom margin of page. Default is %default px.''')
+
debug = parser.add_option_group('DEBUG OPTIONS')
debug.add_option('--verbose', dest='verbose', action='store_true', default=False,
help='''Be verbose while processing''')
@@ -78,9 +87,14 @@ def option_parser(usage):
help='Convert to LRS', default=False)
return parser
-def Book(font_delta=0, header=None, profile=PRS500_PROFILE, **settings):
- ps = dict(textwidth=profile.page_width,
- textheight=profile.page_height)
+def Book(options, font_delta=0, header=None,
+ profile=PRS500_PROFILE, **settings):
+ ps = {}
+ ps['topmargin'] = options.top_margin
+ ps['evensidemargin'] = options.left_margin
+ ps['oddsidemargin'] = options.left_margin
+ ps['textwidth'] = profile.screen_width - (options.left_margin + options.right_margin)
+ ps['textheight'] = profile.screen_height - (options.top_margin + options.bottom_margin)
if header:
hdr = Header()
hb = TextBlock(textStyle=TextStyle(align='foot', fontsize=60))
@@ -89,6 +103,8 @@ def Book(font_delta=0, header=None, profile=PRS500_PROFILE, **settings):
ps['headheight'] = 30
ps['header'] = hdr
ps['topmargin'] = 10
+ if ps['textheight'] + ps['topmargin'] > profile.screen_height:
+ ps['textheight'] = profile.screen_height - ps['topmargin']
baselineskip = (12 + 2*font_delta)*10
return _Book(textstyledefault=dict(fontsize=100+font_delta*20,
parindent=80, linespace=12,
diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py
index c8fc81164b..f0801e8bbc 100644
--- a/src/libprs500/ebooks/lrf/html/convert_from.py
+++ b/src/libprs500/ebooks/lrf/html/convert_from.py
@@ -740,7 +740,10 @@ class HTMLConverter(object):
self.scaled_images[path] = pt
return pt.name
- if not self.disable_autorotation and width > self.profile.page_width and width > height:
+ pheight = int(self.current_page.pageStyle.attrs['textheight'])
+ pwidth = int(self.current_page.pageStyle.attrs['textwidth'])
+
+ if not self.disable_autorotation and width > pwidth and width > height:
pt = PersistentTemporaryFile(suffix='.jpeg')
im = im.rotate(90)
im.convert('RGB').save(pt, 'JPEG')
@@ -749,19 +752,20 @@ class HTMLConverter(object):
self.rotated_images[path] = pt
width, height = im.size
- if height > self.profile.page_height:
- corrf = self.profile.page_height/(1.*height)
- width, height = floor(corrf*width), self.profile.page_height-1
- if width > self.profile.page_width:
- corrf = (self.profile.page_width)/(1.*width)
- width, height = self.profile.page_width-1, floor(corrf*height)
+
+ if height > pheight:
+ corrf = pheight/(1.*height)
+ width, height = floor(corrf*width), pheight-1
+ if width > pwidth:
+ corrf = (pwidth)/(1.*width)
+ width, height = pwidth-1, floor(corrf*height)
path = scale_image(width, height)
- if width > self.profile.page_width:
- corrf = self.profile.page_width/(1.*width)
- width, height = self.profile.page_width-1, floor(corrf*height)
- if height > self.profile.page_height:
- corrf = (self.profile.page_height)/(1.*height)
- width, height = floor(corrf*width), self.profile.page_height-1
+ if width > pwidth:
+ corrf = pwidth/(1.*width)
+ width, height = pwidth-1, floor(corrf*height)
+ if height > pheight:
+ corrf = (pheight)/(1.*height)
+ width, height = floor(corrf*width), pheight-1
path = scale_image(width, height)
width, height = int(width), int(height)
@@ -774,11 +778,10 @@ class HTMLConverter(object):
self.process_alignment(tag_css)
- if max(width, height) <= min(self.profile.page_width,
- self.profile.page_height)/5.:
+ if max(width, height) <= min(pwidth, pheight)/5.:
self.current_para.append(Plot(im, xsize=ceil(width*factor),
ysize=ceil(height*factor)))
- elif height <= int(floor((2/3.)*self.profile.page_height)):
+ elif height <= int(floor((2/3.)*pheight)):
pb = self.current_block
self.end_current_para()
self.process_alignment(tag_css)
@@ -792,11 +795,14 @@ class HTMLConverter(object):
self.current_para = Paragraph()
else:
self.end_page()
- self.current_page.append(Canvas(width=self.profile.page_width,
+ self.current_page.append(Canvas(width=pwidth,
height=height))
- left = int(floor((self.profile.page_width - width)/2.))
- self.current_page.contents[-1].put_object(ImageBlock(self.images[path]),
- left, 0)
+ left = int(floor((pwidth - width)/2.))
+ self.current_page.contents[-1].put_object(
+ ImageBlock(self.images[path], xsize=pwidth,
+ ysize=pheight, x1=pwidth, y1=pheight,
+ blockwidth=pwidth, blockheight=pheight),
+ left, 0)
def parse_tag(self, tag, parent_css):
try:
@@ -1039,7 +1045,7 @@ class HTMLConverter(object):
self.end_current_para()
self.current_block.append(CR())
self.end_current_block()
- self.current_page.RuledLine(linelength=self.profile.page_width)
+ self.current_page.RuledLine(linelength=int(self.current_page.pageStyle.attrs['textwidth']))
elif tagname == 'td': # Needed for nested tables
self.current_para.append(" ")
self.process_children(tag, tag_css)
@@ -1056,9 +1062,9 @@ class HTMLConverter(object):
colpad = 10
table = Table(self, tag, tag_css, rowpad=10, colpad=10)
canvases = []
- for block, xpos, ypos, delta in table.blocks(self.profile.page_width):
+ for block, xpos, ypos, delta in table.blocks(int(self.current_page.pageStyle.attrs['textwidth'])):
if not block:
- canvases.append(Canvas(self.profile.page_width, ypos+colpad,
+ canvases.append(Canvas(int(self.current_page.pageStyle.attrs['textwidth']), ypos+colpad,
blockrule='block-fixed'))
else:
canvases[-1].put_object(block, xpos + int(delta/2.), 0)
@@ -1133,7 +1139,7 @@ def process_file(path, options):
header.append(Bold(options.title))
header.append(' by ')
header.append(Italic(options.author+" "))
- book = Book(header=header, **args)
+ book = Book(options, header=header, **args)
le = re.compile(options.link_exclude) if options.link_exclude else \
re.compile('$')
pb = re.compile(options.page_break, re.IGNORECASE) if options.page_break else \
diff --git a/src/libprs500/ebooks/lrf/txt/convert_from.py b/src/libprs500/ebooks/lrf/txt/convert_from.py
index 2e8406b10d..19a3dcce47 100644
--- a/src/libprs500/ebooks/lrf/txt/convert_from.py
+++ b/src/libprs500/ebooks/lrf/txt/convert_from.py
@@ -73,7 +73,7 @@ def convert_txt(path, options):
header.append(Italic(options.author))
title = (options.title, options.title_sort)
author = (options.author, options.author_sort)
- book = Book(header=header, title=title, author=author, \
+ book = Book(options, header=header, title=title, author=author, \
publisher=options.publisher,
sourceencoding=options.encoding, freetext=options.freetext, \
category=options.category, booksetting=BookSetting