mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Pull from driver-dev
This commit is contained in:
commit
c4dd95aaa9
@ -42,7 +42,9 @@ def line_length(raw, percent):
|
|||||||
'''
|
'''
|
||||||
raw is the raw text to find the line length to use for wrapping.
|
raw is the raw text to find the line length to use for wrapping.
|
||||||
percentage is a decimal number, 0 - 1 which is used to determine
|
percentage is a decimal number, 0 - 1 which is used to determine
|
||||||
how far in the list of line lengths to use.
|
how far in the list of line lengths to use. The list of line lengths is
|
||||||
|
ordered smallest to larged and does not include duplicates. 0.5 is the
|
||||||
|
median value.
|
||||||
'''
|
'''
|
||||||
raw = raw.replace(' ', ' ')
|
raw = raw.replace(' ', ' ')
|
||||||
linere = re.compile('(?<=<br>).*?(?=<br>)', re.DOTALL)
|
linere = re.compile('(?<=<br>).*?(?=<br>)', re.DOTALL)
|
||||||
|
@ -21,7 +21,9 @@ class PDFInput(InputFormatPlugin):
|
|||||||
OptionRecommendation(name='no_images', recommended_value=False,
|
OptionRecommendation(name='no_images', recommended_value=False,
|
||||||
help=_('Do not extract images from the document')),
|
help=_('Do not extract images from the document')),
|
||||||
OptionRecommendation(name='pdf_line_length', recommended_value=0.5,
|
OptionRecommendation(name='pdf_line_length', recommended_value=0.5,
|
||||||
help=_('Average line length for line breaking')),
|
help=_('Scale used to determine the length at which a line should '
|
||||||
|
'be unwrapped. Valid values are a decimal between 0 and 1. The '
|
||||||
|
'default is 0.5, this is the median line length.')),
|
||||||
])
|
])
|
||||||
|
|
||||||
def convert(self, stream, options, file_ext, log,
|
def convert(self, stream, options, file_ext, log,
|
||||||
@ -41,7 +43,7 @@ class PDFInput(InputFormatPlugin):
|
|||||||
images.remove('index.html')
|
images.remove('index.html')
|
||||||
for i in images:
|
for i in images:
|
||||||
# Remove the - from the file name because it causes problems.
|
# Remove the - from the file name because it causes problems.
|
||||||
# The referenec to the image with the - will be changed to not
|
# The reference to the image with the - will be changed to not
|
||||||
# include it later in the conversion process.
|
# include it later in the conversion process.
|
||||||
new_i = i.replace('-', '')
|
new_i = i.replace('-', '')
|
||||||
os.rename(i, new_i)
|
os.rename(i, new_i)
|
||||||
|
@ -30,5 +30,6 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
self.opt_format.setModel(self.format_model)
|
self.opt_format.setModel(self.format_model)
|
||||||
|
|
||||||
default_index = self.opt_format.findText(default)
|
default_index = self.opt_format.findText(default)
|
||||||
self.opt_format.setCurrentIndex(default_index if default_index != -1 else 0)
|
format_index = self.opt_format.findText('doc')
|
||||||
|
self.opt_format.setCurrentIndex(default_index if default_index != -1 else format_index if format_index != -1 else 0)
|
||||||
|
|
||||||
|
19
src/calibre/gui2/convert/pdf_input.py
Normal file
19
src/calibre/gui2/convert/pdf_input.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
__license__ = 'GPL 3'
|
||||||
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
from calibre.gui2.convert.pdf_input_ui import Ui_Form
|
||||||
|
from calibre.gui2.convert import Widget
|
||||||
|
|
||||||
|
class PluginWidget(Widget, Ui_Form):
|
||||||
|
|
||||||
|
TITLE = _('PDF Input')
|
||||||
|
HELP = _('Options specific to')+' PDF '+_('input')
|
||||||
|
|
||||||
|
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||||
|
Widget.__init__(self, parent, 'pdf_input',
|
||||||
|
['no_images', 'pdf_line_length'])
|
||||||
|
self.db, self.book_id = db, book_id
|
||||||
|
self.initialize_options(get_option, get_help, db, book_id)
|
61
src/calibre/gui2/convert/pdf_input.ui
Normal file
61
src/calibre/gui2/convert/pdf_input.ui
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Line Un-Wrapping Factor:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>213</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="opt_pdf_line_length">
|
||||||
|
<property name="maximum">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.010000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.500000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="opt_no_images">
|
||||||
|
<property name="text">
|
||||||
|
<string>No Images</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -31,8 +31,9 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
self.paper_size_model = paper_size_model
|
self.paper_size_model = paper_size_model
|
||||||
self.opt_paper_size.setModel(self.paper_size_model)
|
self.opt_paper_size.setModel(self.paper_size_model)
|
||||||
|
|
||||||
default_index = self.opt_paper_size.findText(default_paper_size)
|
default_paper_size_index = self.opt_paper_size.findText(default_paper_size)
|
||||||
self.opt_paper_size.setCurrentIndex(default_index if default_index != -1 else 0)
|
letter_index = self.opt_paper_size.findText('letter')
|
||||||
|
self.opt_paper_size.setCurrentIndex(default_paper_size_index if default_paper_size_index != -1 else letter_index if letter_index != -1 else 0)
|
||||||
|
|
||||||
global orientation_model
|
global orientation_model
|
||||||
if orientation_model is None:
|
if orientation_model is None:
|
||||||
@ -40,6 +41,7 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
self.orientation_model = orientation_model
|
self.orientation_model = orientation_model
|
||||||
self.opt_orientation.setModel(self.orientation_model)
|
self.opt_orientation.setModel(self.orientation_model)
|
||||||
|
|
||||||
default_index = self.opt_orientation.findText(default_orientation)
|
default_orientation_index = self.opt_orientation.findText(default_orientation)
|
||||||
self.opt_orientation.setCurrentIndex(default_index if default_index != -1 else 0)
|
orientation_index = self.opt_orientation.findText('portrait')
|
||||||
|
self.opt_orientation.setCurrentIndex(default_orientation_index if default_orientation_index != -1 else orientation_index if orientation_index != -1 else 0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user