Home > Mobile >  QwebEngineView run javascript, using pdfobject according to PDF
QwebEngineView run javascript, using pdfobject according to PDF

Time:09-29

Using the setUrl method of Load without a little reaction, shows the local HTML HTML with js folder at the same level, inside is PDFObject. Main. Js display PDF
Use sethtml debug output, according to the last card on PDFObject undefined issue, not solve, web page can normal open it with chrome rendering PDF

 



<meta charset="utf-8" & gt;
Online browsing PDF


<body>

<script>
PDFObject. Embed (" D:/visual3D/WorkstationMultiuser/Builder/Debug/report/Data/1.2.840.113704.1.111.5488.1521071043.1 _15 2019-10-11-45. PDF ");
</script>



PDF absolute path, relative paths are tried
The calling code
 
The UI - & gt; WebEngineView - & gt; Settings () - & gt; The setAttribute (QWebEngineSettings: : PluginsEnabled, true);
QString path="D:/visual3D WorkstationMultiuser/Builder/Debug/report/Data/view HTML";
//UI - & gt; WebEngineView - & gt; Load (QUrl (path));
//return;

QFile file (path);
Bool isok=file. Open (QIODevice: : Text | QIODevice: : ReadOnly);
QByteArray htmldata=(https://bbs.csdn.net/topics/file.readAll);
File. The close ();
QString ans=QString (htmldata). ToUtf8 ();
The UI - & gt; WebEngineView - & gt; SetHtml (ans);



Error message
Js: Uncaught ReferenceError: PDFObject is not defined in the
[112320-83780:1021/182104.568: INFO: the CONSOLE (12)] "Uncaught ReferenceError: PDFObject is not defined", the source: data: text/HTML. Charset=utf-8, 21 20 HTML doctype % % % 3 c % % 0 3 e a % 3 CHTML % 3 e % % % 0 a % 20% C2 A0 20% A0%3 chead C2 % % 3 e % % 0 a % 20% C2 A0%2

Use sethtml exe as the current directory

CodePudding user response:

Have to upload PDF and HTML and js, as long as you can open the HTML and display in Qt is ok
https://pan.baidu.com/s/1nSVcZM-wZF9SUiG9IzmVQQ
Mainly by hand in the browser open normally, Qt open js may have a problem
  •  Tags:  
  • Qt
  • Related