Add to web open pdf and txt files
-
Hi all.
I need advice, I'm trying to find a way to add opening pdf files to the WebEngine. Found that there are modules such as Poppler and QPDF. Is there no built-in tools for such work in WebEngine? Should I use these modules?
It requires not only opening the file, but also minimal work with it.
I use 6.4.2 ver.
Thx. -
Hi all.
I need advice, I'm trying to find a way to add opening pdf files to the WebEngine. Found that there are modules such as Poppler and QPDF. Is there no built-in tools for such work in WebEngine? Should I use these modules?
It requires not only opening the file, but also minimal work with it.
I use 6.4.2 ver.
Thx.@BlinCt
Qt WebEngine is Chromium. Does that not display PDF files like Chrome does? If you put a link on a page to a PDF file and click it does that open it as PDF?I don't know what "minimal work with it" means. Neither Chrome/ium nor Qt provides a PDF editor.
-
@BlinCt
Qt WebEngine is Chromium. Does that not display PDF files like Chrome does? If you put a link on a page to a PDF file and click it does that open it as PDF?I don't know what "minimal work with it" means. Neither Chrome/ium nor Qt provides a PDF editor.
-
@JonB
When I oppend txt file it's ok, work. But when I try open pdf or docx nothing happens.
Open file through FileDialog and send url to WebEngineView.@BlinCt
Example at https://stackoverflow.com/a/60561827/489865 shows code:m_View(new QWebEngineView(this)); QUrl url = QUrl::fromLocalFile(pdf_path); m_View->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); m_View->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); m_View->settings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, true); m_View->load(url);
Maybe you need that
PdfViewerEnabled
setting?Or code at https://gist.github.com/eyllanesc/7566bab2f8a91593c460015ee2151717 seems to only require
settings.setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
.Also see https://doc.qt.io/qt-6/qtwebengine-features.html#pdf-file-viewing .
-
@BlinCt
Example at https://stackoverflow.com/a/60561827/489865 shows code:m_View(new QWebEngineView(this)); QUrl url = QUrl::fromLocalFile(pdf_path); m_View->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); m_View->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); m_View->settings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, true); m_View->load(url);
Maybe you need that
PdfViewerEnabled
setting?Or code at https://gist.github.com/eyllanesc/7566bab2f8a91593c460015ee2151717 seems to only require
settings.setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
.Also see https://doc.qt.io/qt-6/qtwebengine-features.html#pdf-file-viewing .
-
@JonB
Yes, these are exactly the settings I was looking for. But as I understand it, there are no settings for docx files?@BlinCt said in Add to web open pdf and txt files:
there are no settings for docx files?
Most probably not. I don't think any existing browser can show Microsoft Office files without plug-ins (maybe Microsofts own browsers can).