QString html = QString ("<html>\n" "<head>\n" " <script type=\"text/javascript\">\n" " <!--\n" " function setWidth (width) {\n" " document.getElementById (\"PdfReader\").style.width=width;\n" " }\n" " function setHeight (height) {\n" " document.getElementById (\"PdfReader\").style.height=height;\n" " }\n" " //-->\n" " </script>\n" "</head>" "<body>\n" " <object id=\"PdfReader\" name=\"PdfReader\" width=\"%1\" height=\"%2\"><embed src=\"file:///%3\" type=\"application/x-pdf\"/>\n" "</object>\n" "</body>\n" "</html>") .arg (width () - 20) .arg (height () - 20) .arg (m_tmpFileName);
QString html = QString ("<html>\n" "<head>\n" " <script type=\"text/javascript\">\n" " <!--\n" " function setWidth (width) {\n" " document.getElementById (\"PdfReader\").style.width=width;\n" " }\n" " function setHeight (height) {\n" " document.getElementById (\"PdfReader\").style.height=height;\n" " }\n" " //-->\n" " </script>\n" "</head>" "<body>\n" " <object id=\"PdfReader\" name=\"PdfReader\" width=\"%1\" height=\"%2\"><embed src=\"file:///d:/24.pdf\" type=\"application/x-pdf\"/>\n" "</object>\n" "</body>\n" "</html>") .arg (width () - 20) .arg (height () - 20); webViewContent->load(html);
<html><body> <object id="PDFWrapper" data="test.pdf" type="application/pdf" width="100%" height="100%"> </object></body></html>
#include <QtGui/QApplication>#include <QWebView>//#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); QWebView view; QString html = QString ("<html>\n" "<head>\n" " <script type=\"text/javascript\">\n" " <!--\n" " function setWidth (width) {\n" " document.getElementById (\"PdfReader\").style.width=width;\n" " }\n" " function setHeight (height) {\n" " document.getElementById (\"PdfReader\").style.height=height;\n" " }\n" " //-->\n" " </script>\n" "</head>" "<body>\n" " <object id=\"PdfReader\" name=\"PdfReader\" > " "<embed src=\"file:///d:/test.pdf\" type=\"application/x-pdf\"/>\n" "</object>\n" "</body>\n" "</html>"); view.load(html); view.show();// MainWindow w;// w.show(); return a.exec();}