作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Qt 应用程序中,我正在进行一些网络测试。我必须根据测试输出创建报告。所以我需要以pdf格式创建报告。
有人可以让我知道如何将我的测试结果放在 pdf 文件中吗?我的结果包含使用 Qwt 库的图形。
最佳答案
此代码从 html 输出 pdf:
QTextDocument doc;
doc.setHtml("<h1>hello, I'm an head</h1>");
QPrinter printer;
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
doc.print(&printer);
printer.newPage();
QPrinter printer;
QPainter painter(&printer);
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
painter.drawImage(QRect(0,0,100,100), <QImage loaded from your file>);
printer.newPage();
关于pdf - 如何从 Qt 应用程序创建 pdf 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5134837/
我是一名优秀的程序员,十分优秀!