PDF Output: Add an option to discard the book cover instead of inserting it as the first page of the PDF. Fixes #2025942 [Add no-cover option to PDF output, like DOCX output](https://bugs.launchpad.net/calibre/+bug/2025942)

This commit is contained in:
Kovid Goyal 2023-07-13 20:09:45 +05:30
parent 724848e364
commit f77c451716
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 40 additions and 26 deletions

View File

@ -305,7 +305,7 @@ OPTIONS = {
'pdf_default_font_size', 'pdf_mono_font_size', 'pdf_page_numbers',
'pdf_footer_template', 'pdf_header_template', 'pdf_add_toc',
'toc_title', 'pdf_page_margin_left', 'pdf_page_margin_top',
'pdf_page_margin_right', 'pdf_page_margin_bottom',
'pdf_page_margin_right', 'pdf_page_margin_bottom', 'pdf_no_cover',
'pdf_use_document_margins', 'pdf_page_number_map', 'pdf_odd_even_offset'),
'pml': ('inline_toc', 'full_image_depth', 'pml_output_encoding'),

View File

@ -139,6 +139,11 @@ class PDFOutput(OutputFormatPlugin):
' the PDF CropBox, not all software respects the CropBox.'
)
),
OptionRecommendation(name='pdf_no_cover',
recommended_value=False,
help=_('Do not insert the book cover as an image at the start of the document.'
' If you use this option, the book cover will be discarded.')
),
}
@ -229,7 +234,8 @@ class PDFOutput(OutputFormatPlugin):
def convert_text(self, oeb_book):
import json
from calibre.ebooks.pdf.html_writer import convert
self.get_cover_data()
if not self.opts.pdf_no_cover:
self.get_cover_data()
self.process_fonts()
if self.opts.pdf_use_document_margins and self.stored_page_margins:

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>638</width>
<height>665</height>
<height>731</height>
</rect>
</property>
<property name="windowTitle">
@ -87,21 +87,21 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="opt_pdf_page_numbers">
<property name="text">
<string>Add page &amp;numbers to the bottom of every page</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="opt_pdf_add_toc">
<property name="text">
<string>Add a printable &amp;Table of Contents at the end</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>&amp;Title for ToC:</string>
@ -111,14 +111,14 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLineEdit" name="opt_toc_title">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Serif famil&amp;y:</string>
@ -128,10 +128,10 @@
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QFontComboBox" name="opt_pdf_serif_family"/>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Sans fami&amp;ly:</string>
@ -141,10 +141,10 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QFontComboBox" name="opt_pdf_sans_family"/>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Monospace family:</string>
@ -154,10 +154,10 @@
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QFontComboBox" name="opt_pdf_mono_family"/>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>S&amp;tandard font:</string>
@ -167,10 +167,10 @@
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QComboBox" name="opt_pdf_standard_font"/>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Default font si&amp;ze:</string>
@ -180,14 +180,14 @@
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QSpinBox" name="opt_pdf_default_font_size">
<property name="suffix">
<string> px</string>
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Monospace &amp;font size:</string>
@ -197,14 +197,14 @@
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QSpinBox" name="opt_pdf_mono_font_size">
<property name="suffix">
<string> px</string>
</property>
</widget>
</item>
<item row="16" column="0">
<item row="17" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Page &amp;number map:</string>
@ -214,21 +214,21 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QLineEdit" name="opt_pdf_page_number_map">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="18" column="0" colspan="2">
<item row="19" column="0" colspan="2">
<widget class="QGroupBox" name="page_margins_box">
<property name="title">
<string>Page margins</string>
</property>
</widget>
</item>
<item row="19" column="0" colspan="2">
<item row="20" column="0" colspan="2">
<widget class="QGroupBox" name="template_box">
<property name="title">
<string>Page headers and footers</string>
@ -284,14 +284,14 @@
</layout>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="opt_pdf_hyphenate">
<property name="text">
<string>&amp;Break long words at the end of lines</string>
</property>
</widget>
</item>
<item row="17" column="0">
<item row="18" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Odd/even &amp;offset:</string>
@ -301,7 +301,7 @@
</property>
</widget>
</item>
<item row="17" column="1">
<item row="18" column="1">
<widget class="QDoubleSpinBox" name="opt_pdf_odd_even_offset">
<property name="suffix">
<string> pt</string>
@ -317,6 +317,13 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="opt_pdf_no_cover">
<property name="text">
<string>Discard book &amp;cover</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -648,6 +648,7 @@ def pdf_output(container):
g.appendChild(choices('paper_size', indent + _('&Paper size:'), ui_data.paper_sizes))
g.appendChild(lineedit('custom_size', indent + _('&Custom size:')))
g.appendChild(choices('unit', indent + _('Custom size unit:'), ui_data.units))
g.appendChild(checkbox('pdf_no_cover', _('Discard book &cover')))
g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve &aspect ratio of cover')))
g.appendChild(checkbox('pdf_page_numbers', _('Add page &numbers to the bottom of every page')))
g.appendChild(checkbox('pdf_hyphenate', _('&Break long words at the end of lines')))