问题
I have following code
QString filePath("x.pdf");
QPrinter printer(QPrinter::HighResolution);
printer.setCreator(PRODUCT_NAME);
printer.setOutputFileName(filePath;
printer.setOutputFormat(QPrinter::PdfFormat);
QPainter painter(&printer);
render(&painter);
how can I save this above PDF file x.pdf into a png file using QT code?
回答1:
Qt has no built-in methods that allow to convert PDF files to images. You should use some other libraries or call from your program some external converter. Maybe try with Poppler:
QImage image = pdfPage->renderToImage(xres, yres, x, y, width, height);
image.save("convertedDocument.png");
来源:https://stackoverflow.com/questions/45736885/how-to-convert-pdf-file-into-png-image-file-in-qt