Add a note about using page margins from the input document

This commit is contained in:
Kovid Goyal 2019-07-11 21:42:47 +05:30
parent 974070ef93
commit 9f87cd7f99
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 25 additions and 7 deletions

View File

@ -898,3 +898,28 @@ changes you like.
.calibre-pdf-toc .level-1 td:first-of-type { padding-left: 1.4em } .calibre-pdf-toc .level-1 td:first-of-type { padding-left: 1.4em }
.calibre-pdf-toc .level-2 td:first-of-type { padding-left: 2.8em } .calibre-pdf-toc .level-2 td:first-of-type { padding-left: 2.8em }
Custom page margins for individual HTML files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you are converting an EPUB of AZW3 file with multiple individual HTML files
inside it and you want to change the page margins for a particular HTML file
you can add the following style block to the HTML file using the calibre
editor:
.. code-block:: html
<style>
@page {
margin-left: 10pt;
margin-right: 10pt;
margin-top: 10pt;
margin-bottom: 10pt;
}
</style>
Then, in the PDF output section of the conversion dialog, turn on the
option to :guilabel:`Use page margins from the document being converted`.
Now all pages generated from this HTML file will have ``10pt`` margins.

View File

@ -43,7 +43,6 @@ class PluginWidget(Widget, Ui_Form):
self.initialize_options(get_option, get_help, db, book_id) self.initialize_options(get_option, get_help, db, book_id)
self.layout().setFieldGrowthPolicy(self.layout().ExpandingFieldsGrow) self.layout().setFieldGrowthPolicy(self.layout().ExpandingFieldsGrow)
self.template_box.layout().setFieldGrowthPolicy(self.layout().AllNonFixedFieldsGrow) self.template_box.layout().setFieldGrowthPolicy(self.layout().AllNonFixedFieldsGrow)
self.toggle_margins()
self.profile_size_toggled() self.profile_size_toggled()
def profile_size_toggled(self): def profile_size_toggled(self):
@ -52,17 +51,11 @@ class PluginWidget(Widget, Ui_Form):
self.opt_custom_size.setEnabled(enabled) self.opt_custom_size.setEnabled(enabled)
self.opt_unit.setEnabled(enabled) self.opt_unit.setEnabled(enabled)
def toggle_margins(self):
enabled = not self.opt_pdf_use_document_margins.isChecked()
for which in 'left top right bottom'.split():
getattr(self, 'opt_pdf_page_margin_' + which).setEnabled(enabled)
def setupUi(self, *a): def setupUi(self, *a):
Ui_Form.setupUi(self, *a) Ui_Form.setupUi(self, *a)
v = self.page_margins_box.v = QVBoxLayout(self.page_margins_box) v = self.page_margins_box.v = QVBoxLayout(self.page_margins_box)
self.opt_pdf_use_document_margins = c = QCheckBox(_('Use page margins from the &document being converted')) self.opt_pdf_use_document_margins = c = QCheckBox(_('Use page margins from the &document being converted'))
v.addWidget(c) v.addWidget(c)
c.stateChanged.connect(self.toggle_margins)
h = self.page_margins_box.h = QHBoxLayout() h = self.page_margins_box.h = QHBoxLayout()
l = self.page_margins_box.l = QFormLayout() l = self.page_margins_box.l = QFormLayout()
r = self.page_margins_box.r = QFormLayout() r = self.page_margins_box.r = QFormLayout()