mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Output: Add custom size conversion option to the GUI (it was only present on the command line before)
This commit is contained in:
parent
502575375b
commit
83aab34ec5
@ -25,31 +25,30 @@ class PDFOutput(OutputFormatPlugin):
|
|||||||
file_type = 'pdf'
|
file_type = 'pdf'
|
||||||
|
|
||||||
options = set([
|
options = set([
|
||||||
OptionRecommendation(name='unit', recommended_value='inch',
|
OptionRecommendation(name='unit', recommended_value='inch',
|
||||||
level=OptionRecommendation.LOW, short_switch='u', choices=UNITS.keys(),
|
level=OptionRecommendation.LOW, short_switch='u', choices=UNITS.keys(),
|
||||||
help=_('The unit of measure. Default is inch. Choices '
|
help=_('The unit of measure. Default is inch. Choices '
|
||||||
'are %s '
|
'are %s '
|
||||||
'Note: This does not override the unit for margins!') % UNITS.keys()),
|
'Note: This does not override the unit for margins!') % UNITS.keys()),
|
||||||
OptionRecommendation(name='paper_size', recommended_value='letter',
|
OptionRecommendation(name='paper_size', recommended_value='letter',
|
||||||
level=OptionRecommendation.LOW, choices=PAPER_SIZES.keys(),
|
level=OptionRecommendation.LOW, choices=PAPER_SIZES.keys(),
|
||||||
help=_('The size of the paper. This size will be overridden when an '
|
help=_('The size of the paper. This size will be overridden when a '
|
||||||
'output profile is used. Default is letter. Choices '
|
'non default output profile is used. Default is letter. Choices '
|
||||||
'are %s') % PAPER_SIZES.keys()),
|
'are %s') % PAPER_SIZES.keys()),
|
||||||
OptionRecommendation(name='custom_size', recommended_value=None,
|
OptionRecommendation(name='custom_size', recommended_value=None,
|
||||||
help=_('Custom size of the document. Use the form widthxheight '
|
help=_('Custom size of the document. Use the form widthxheight '
|
||||||
'EG. `123x321` to specify the width and height. '
|
'EG. `123x321` to specify the width and height. '
|
||||||
'This overrides any specified paper-size.')),
|
'This overrides any specified paper-size.')),
|
||||||
OptionRecommendation(name='orientation', recommended_value='portrait',
|
OptionRecommendation(name='orientation', recommended_value='portrait',
|
||||||
level=OptionRecommendation.LOW, choices=ORIENTATIONS.keys(),
|
level=OptionRecommendation.LOW, choices=ORIENTATIONS.keys(),
|
||||||
help=_('The orientation of the page. Default is portrait. Choices '
|
help=_('The orientation of the page. Default is portrait. Choices '
|
||||||
'are %s') % ORIENTATIONS.keys()),
|
'are %s') % ORIENTATIONS.keys()),
|
||||||
OptionRecommendation(name='preserve_cover_aspect_ratio',
|
OptionRecommendation(name='preserve_cover_aspect_ratio',
|
||||||
recommended_value=False,
|
recommended_value=False,
|
||||||
help=_('Preserve the aspect ratio of the cover, instead'
|
help=_('Preserve the aspect ratio of the cover, instead'
|
||||||
' of stretching it to fill the full first page of the'
|
' of stretching it to fill the full first page of the'
|
||||||
' generated pdf.')
|
' generated pdf.')),
|
||||||
),
|
])
|
||||||
])
|
|
||||||
|
|
||||||
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
||||||
self.oeb = oeb_book
|
self.oeb = oeb_book
|
||||||
|
@ -48,7 +48,7 @@ def get_pdf_printer(opts, for_comic=False):
|
|||||||
custom_size = get_custom_size(opts)
|
custom_size = get_custom_size(opts)
|
||||||
|
|
||||||
if opts.output_profile.short_name == 'default' or \
|
if opts.output_profile.short_name == 'default' or \
|
||||||
opts.output_profile.width > 10000:
|
opts.output_profile.width > 9999:
|
||||||
if custom_size is None:
|
if custom_size is None:
|
||||||
printer.setPaperSize(paper_size(opts.paper_size))
|
printer.setPaperSize(paper_size(opts.paper_size))
|
||||||
else:
|
else:
|
||||||
|
@ -77,7 +77,6 @@ class Widget(QWidget):
|
|||||||
self._options, only_existing=True)
|
self._options, only_existing=True)
|
||||||
defaults.update(specifics)
|
defaults.update(specifics)
|
||||||
|
|
||||||
|
|
||||||
self.apply_recommendations(defaults)
|
self.apply_recommendations(defaults)
|
||||||
self.setup_help(get_help)
|
self.setup_help(get_help)
|
||||||
|
|
||||||
|
@ -18,14 +18,14 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
ICON = I('mimetypes/pdf.png')
|
ICON = I('mimetypes/pdf.png')
|
||||||
|
|
||||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||||
Widget.__init__(self, parent, ['paper_size',
|
Widget.__init__(self, parent, ['paper_size', 'custom_size',
|
||||||
'orientation', 'preserve_cover_aspect_ratio'])
|
'orientation', 'preserve_cover_aspect_ratio'])
|
||||||
self.db, self.book_id = db, book_id
|
self.db, self.book_id = db, book_id
|
||||||
|
|
||||||
for x in get_option('paper_size').option.choices:
|
for x in get_option('paper_size').option.choices:
|
||||||
self.opt_paper_size.addItem(x)
|
self.opt_paper_size.addItem(x)
|
||||||
for x in get_option('orientation').option.choices:
|
for x in get_option('orientation').option.choices:
|
||||||
self.opt_orientation.addItem(x)
|
self.opt_orientation.addItem(x)
|
||||||
|
|
||||||
self.initialize_options(get_option, get_help, db, book_id)
|
self.initialize_options(get_option, get_help, db, book_id)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="opt_orientation"/>
|
<widget class="QComboBox" name="opt_orientation"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -53,13 +53,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="opt_preserve_cover_aspect_ratio">
|
<widget class="QCheckBox" name="opt_preserve_cover_aspect_ratio">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Preserve &aspect ratio of cover</string>
|
<string>Preserve &aspect ratio of cover</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Custom size:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>opt_custom_size</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="opt_custom_size"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -117,6 +117,6 @@ if __name__ == '__main__':
|
|||||||
from PyQt4.Qt import QApplication
|
from PyQt4.Qt import QApplication
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
#test_widget('Conversion', 'Input Options')
|
#test_widget('Conversion', 'Input Options')
|
||||||
test_widget('Conversion', 'Common Options')
|
#test_widget('Conversion', 'Common Options')
|
||||||
#test_widget('Conversion', 'Output Options')
|
test_widget('Conversion', 'Output Options')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user