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. How can I convert html file to pdf

How can I convert html file to pdf

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 299 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
    Bhavith C
    wrote on 15 Mar 2023, 10:20 last edited by
    #1

    I am trying to convert html file saved on my drive to pdf file, I have followed this link https://doc.qt.io/qt-6/qtwebengine-webenginewidgets-html2pdf-example.html
    But here they have used url but I need a html file to pdf convertor. I tried loading from the file, But the pdf seems empty.

    Can anybody help me here to solve the issue. I am new to Qt I am totally getting lost.

    J 1 Reply Last reply 15 Mar 2023, 14:56
    0
    • B Bhavith C
      15 Mar 2023, 10:20

      I am trying to convert html file saved on my drive to pdf file, I have followed this link https://doc.qt.io/qt-6/qtwebengine-webenginewidgets-html2pdf-example.html
      But here they have used url but I need a html file to pdf convertor. I tried loading from the file, But the pdf seems empty.

      Can anybody help me here to solve the issue. I am new to Qt I am totally getting lost.

      J Offline
      J Offline
      JonB
      wrote on 15 Mar 2023, 14:56 last edited by JonB
      #2

      @Bhavith-C
      There are several ways you might do this. But if you are happy with that example code you can use it to read the HTML from a local file via a suitable URL. Where that code goes

      m_view->load(QUrl::fromUserInput(m_inputPath));
      

      you should be able to change it to use QUrl QUrl::fromLocalFile(const QString &localFile) on, say, the full path to a specified local file.

      1 Reply Last reply
      0

      2/2

      15 Mar 2023, 14:56

      • Login

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