Exemple #1
0
def job_for_name(container, name, margins, page_layout):
    index_file = container.name_to_abspath(name)
    if margins:
        page_layout = QPageLayout(page_layout)
        page_layout.setUnits(QPageLayout.Point)
        new_margins = QMarginsF(*resolve_margins(margins, page_layout))
        page_layout.setMargins(new_margins)
    return index_file, page_layout, name
Exemple #2
0
def get_page_layout(opts, for_comic=False):
    page_size = get_page_size(opts, for_comic)

    def m(which):
        return max(0, getattr(opts, 'pdf_page_margin_' + which) or getattr(opts, 'margin_' + which))

    margins = QMarginsF(m('left'), m('top'), m('right'), m('bottom'))
    ans = QPageLayout(page_size, QPageLayout.Portrait, margins)
    ans.setMode(QPageLayout.FullPageMode)
    return ans
Exemple #3
0
 def print_page(self, path=None):
     if not path:
         path = os.path.join(get_download_dir(), self.title())
     if not path.lower().endswith('.pdf'):
         path += '.pdf'
     size = QPageSize(getattr(QPageSize, misc_config('paper_size', 'A4')))
     layout = QPageLayout(
         size, QPageLayout.Portrait,
         QMarginsF(float(misc_config('margin_left', 36)),
                   float(misc_config('margin_top', 36)),
                   float(misc_config('margin_right', 36)),
                   float(misc_config('margin_bottom', 36))))
     self._page.printToPdf(partial(self.print_done, path), layout)
Exemple #4
0
 def start_print(self, data):
     margins = QMarginsF(0, 0, 0, 0)
     page_size = QPageSize(QPageSize.A4)
     if isinstance(data, dict):
         try:
             if 'margins' in data:
                 margins = QMarginsF(*data['margins'])
             if 'size' in data:
                 sz = data['size']
                 if type(getattr(QPageSize, sz, None)) is type(
                         QPageSize.A4):  # noqa
                     page_size = QPageSize(getattr(QPageSize, sz))
                 else:
                     from calibre.ebooks.pdf.image_writer import parse_pdf_page_size
                     ps = parse_pdf_page_size(sz, data.get('unit', 'inch'))
                     if ps is not None:
                         page_size = ps
         except Exception:
             pass
     page_layout = QPageLayout(page_size, QPageLayout.Portrait, margins)
     self.printToPdf('rendered.pdf', page_layout)
     self.printing_started = True
     self.start_time = monotonic()
Exemple #5
0
    def __init__(self, id, graphicsGraphView):
        self.id = id
        self.graphicsGraphView = graphicsGraphView

        # Init graphics text node
        self.graphicsTextNode = GraphicsTextNode()
        (self.graphicsTextNode.boundingRect().
         marginsAdded(QMarginsF(10, 10, 10, 10)))

        self.semiEdge = None

        self.contextMenu = QMenu()

        # Edit label
        editLabelAction = self.contextMenu.addAction("Edit label")
        editLabelAction.triggered.connect(self.onEditLabel)
Exemple #6
0
 def do_print(self, ok):
     p = QPageLayout(QPageSize(QPageSize(QPageSize.A4)),
                     QPageLayout.Portrait, QMarginsF(72, 0, 72, 0))
     self.printToPdf(self.print_finished, p)
Exemple #7
0
 def centerTextInShape(self):
     '''Center the text in the ellipse.'''
     self.setRect(self.graphicsTextNode.boundingRect().
                  marginsAdded(QMarginsF(10, 10, 10, 10)))
Exemple #8
0
 def start_print(self):
     margins = QMarginsF(0, 0, 0, 0)
     page_layout = QPageLayout(QPageSize(QPageSize.A4), QPageLayout.Portrait, margins)
     self.printToPdf('rendered.pdf', page_layout)
     self.printing_started = True
     self.start_time = monotonic()