def _toPrinterAdaptorByIntegralMMSize(self, pageLayout, printerAdaptor): ''' Set my values on printerAdaptor (and whatever printer it is adapting) by setting size. Take integral size, convert to float. ''' # Even a Custom paper has a size, even if it is defaulted. newPaperSizeMM = QSizeF(pageLayout.paper.integralOrientedSizeMM(pageLayout.orientation)) assert newPaperSizeMM.isValid() # use overload QPrinter.setPaperSize(QPagedPaintDevice.PageSize, Units) printerAdaptor.setPaperSize(newPaperSizeMM, QPageLayout.Millimeter)
def _toPrinterAdaptorByFloatInchSize(self, pageLayout, printerAdaptor): ''' Set my values on printerAdaptor (and whatever printer it is adapting) by setting size. Floating inch size. ''' # TODO oriented, other inch unit sizes if pageLayout.paper.value == QPageLayout.Legal: newPaperSizeInch = QSizeF(8.5, 14) elif pageLayout.paper.value == QPageLayout.Letter: newPaperSizeInch = QSizeF(8.5, 11) else: return assert newPaperSizeInch.isValid() # use overload QPrinter.setPaperSize(QPagedPaintDevice.PageSize, Units) #print("setPaperSize(Inch)", newPaperSizeInch) printerAdaptor.setPaperSize(newPaperSizeInch, QPageLayout.Inch)