diff --git a/src/calibre/devices/prs500/driver.py b/src/calibre/devices/prs500/driver.py
index cca71376d4..2f1caaee9d 100755
--- a/src/calibre/devices/prs500/driver.py
+++ b/src/calibre/devices/prs500/driver.py
@@ -96,7 +96,7 @@ class PRS500(Device):
# Location of cache.xml on storage card in device
CACHE_XML = "/Sony Reader/database/cache.xml"
# Ordered list of supported formats
- FORMATS = ["lrf", "rtf", "pdf", "txt"]
+ FORMATS = ["lrf", "lrx", "rtf", "pdf", "txt"]
# Height for thumbnails of books/images on the device
THUMBNAIL_HEIGHT = 68
# Directory on card to which books are copied
diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py
index 8d505683aa..9308af2c5a 100644
--- a/src/calibre/devices/prs505/driver.py
+++ b/src/calibre/devices/prs505/driver.py
@@ -27,12 +27,12 @@ class File(object):
class PRS505(Device):
- VENDOR_ID = 0x054c #: SONY Vendor Id
- PRODUCT_ID = 0x031e #: Product Id for the PRS-505
+ VENDOR_ID = 0x054c #: SONY Vendor Id
+ PRODUCT_ID = 0x031e #: Product Id for the PRS-505
BCD = [0x229] #: Needed to disambiguate 505 and 700 on linux
PRODUCT_NAME = 'PRS-505'
VENDOR_NAME = 'SONY'
- FORMATS = ['lrf', 'epub', "rtf", "pdf", "txt"]
+ FORMATS = ['lrf', 'epub', 'lrx', 'rtf', 'pdf', 'txt']
MEDIA_XML = 'database/cache/media.xml'
CACHE_XML = 'Sony Reader/database/cache.xml'
diff --git a/src/calibre/ebooks/epub/__init__.py b/src/calibre/ebooks/epub/__init__.py
index 863f2f8db0..aa17024d50 100644
--- a/src/calibre/ebooks/epub/__init__.py
+++ b/src/calibre/ebooks/epub/__init__.py
@@ -153,6 +153,14 @@ help on using this feature.
'slow and if your source file contains a very large '
'number of page breaks, you should turn off splitting '
'on page breaks.'))
+ structure('page', ['--page'], default=None,
+ help=_('XPath expression to detect page boundaries for building '
+ 'a custom pagination map, as used by AdobeDE. Default is '
+ 'not to build an explicit pagination map.'))
+ structure('page_names', ['--page-names'], default=None,
+ help=_('XPath expression to find the name of each page in the '
+ 'pagination map relative to its boundary element. '
+ 'Default is to number all pages staring with 1.'))
toc = c.add_group('toc',
_('''\
Control the automatic generation of a Table of Contents. If an OPF file is detected
@@ -230,4 +238,4 @@ to auto-generate a Table of Contents.
c.add_opt('extract_to', ['--extract-to'], group='debug', default=None,
help=_('Extract the contents of the produced EPUB file to the '
'specified directory.'))
- return c
\ No newline at end of file
+ return c
diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py
index ca50fe7a5d..bd9b59cfbd 100644
--- a/src/calibre/ebooks/epub/from_html.py
+++ b/src/calibre/ebooks/epub/from_html.py
@@ -46,6 +46,7 @@ from calibre.ebooks.metadata.toc import TOC
from calibre.ebooks.metadata.opf2 import OPF
from calibre.ebooks.epub import initialize_container, PROFILES
from calibre.ebooks.epub.split import split
+from calibre.ebooks.epub.pages import add_page_map
from calibre.ebooks.epub.fonts import Rationalizer
from calibre.constants import preferred_encoding
from calibre.customize.ui import run_plugins_on_postprocess
@@ -438,6 +439,9 @@ def convert(htmlfile, opts, notification=None, create_epub=True,
if opts.show_ncx:
print toc
split(opf_path, opts, stylesheet_map)
+ if opts.page:
+ logger.info('\tBuilding page map...')
+ add_page_map(opf_path, opts)
check_links(opf_path, opts.pretty_print)
opf = OPF(opf_path, tdir)
diff --git a/src/calibre/ebooks/epub/pages.py b/src/calibre/ebooks/epub/pages.py
new file mode 100644
index 0000000000..1ab5edde86
--- /dev/null
+++ b/src/calibre/ebooks/epub/pages.py
@@ -0,0 +1,59 @@
+'''
+Add page mapping information to an EPUB book.
+'''
+
+from __future__ import with_statement
+
+__license__ = 'GPL v3'
+__copyright__ = '2008, Marshall T. Vandegrift