ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

20 June 2021
2021-06-20×
20 June 2021
R
Has anyone here ever worked with QPrinter or QPdfWriter? I'm totally confused with all this QPainter stuff. All I want to do is to convert an SVG to PDF. I'm using SvgRenderer, which creates a Painter. But I don't know where to go from there. My small piece of code: def convert(self): file = "/home/ricardo/Imagens/desenho.svg" svg = QSvgRenderer() out = svg.load(file) printer = QPrinter(out) # Am I mad? I suppose "out" is a QPainter. printer.setOutputFormat(QPrinter.PdfFormat) printer.setOutputFileName("/home/ricardo/Imagens/file.pdf") # I don't know what to do from here
I have tried that before, it breaks the application.
I will try that tomorrow
R
Hi, fellas! Now I can generate the PDF from the SVG, but the texts are missing. I'm able to use the same SVG and generate a PDF from Firefox. 🤔
R
actually, the texts are rendered, but just completely out of position.
I think Qt SVG is mostly unmaintained, and only supports a small SVG subset
https://doc.qt.io/qt-5/svgrendering.html - "The Mobile SVG Profiles (SVG Basic and SVG Tiny) are aimed at resource-limited devices and are part of the 3GPP platform for third generation mobile phones." [...] "Qt supports the static features of SVG 1.2 Tiny. ECMA scripts and DOM manipulation are currently not supported."
F
If you need this to work for any SVG files (not just files you wrote yourself), I'd probably either use QtWebEngine, or spawn Inkscape in a subprocess (it can do headless SVG -> PDF conversion)
It is an SVG created on Inkscape, as a matter of fact. I'm trying not to attach dependencies from external programs. I tired to code something quick with the WebEngine, but I got lost.
R
My shift is starting in a half-hour, so I will try WebEngine another day. Thanks for the info about being unmaintained.
Calendar: June 2021
Archive by month
Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog