scene.render
- так как он кривой весь. def export_to_pdf(self, filename):
printer = QPrinter(QPrinter.PrinterMode.ScreenResolution)
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat)
printer.setOutputFileName(filename)
printer.setPageOrientation(QPageLayout.Orientation.Landscape)
painter = QPainter(printer)
# Get the width and height of the scene
scene_width = self.scene.width()
scene_height = self.scene.height()
# Get the width and height of the printer's page
page_width = printer.pageLayout().fullRect(QPageLayout.Unit.Point).width()
page_height = printer.pageLayout().fullRect(QPageLayout.Unit.Point).height()
# Calculate the scale factor
scale_factor = max(page_width / scene_width, page_height / scene_height)
# Calculate the translation to center the scene
x_translation = (page_width - scene_width * scale_factor) / 2
y_translation = (page_height - scene_height * scale_factor) / 2
# Apply the scaling and translation
painter.translate(x_translation, y_translation)
#painter.scale(scale_factor, scale_factor)
# Render the scene
self.scene.render(painter)
painter.end()
print(f"Exported to {filename}")