Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Add to web open pdf and txt files

Add to web open pdf and txt files

Scheduled Pinned Locked Moved Unsolved QtWebEngine
6 Posts 3 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlinCt
    wrote on last edited by BlinCt
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • B BlinCt

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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.

      B 1 Reply Last reply
      0
      • JonBJ JonB

        @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.

        B Offline
        B Offline
        BlinCt
        wrote on last edited by
        #3

        @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.

        JonBJ 1 Reply Last reply
        0
        • B BlinCt

          @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.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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 .

          B 1 Reply Last reply
          1
          • JonBJ JonB

            @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 .

            B Offline
            B Offline
            BlinCt
            wrote on last edited by
            #5

            @JonB
            Yes, these are exactly the settings I was looking for. But as I understand it, there are no settings for docx files?

            jsulmJ 1 Reply Last reply
            0
            • B BlinCt

              @JonB
              Yes, these are exactly the settings I was looking for. But as I understand it, there are no settings for docx files?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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).

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved