Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to open a pdf loaded in resource file?

How to open a pdf loaded in resource file?

Scheduled Pinned Locked Moved Solved Qt for Python
qt for python
8 Posts 4 Posters 2.0k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    Selvajothi
    wrote on last edited by
    #1

    I want to show the help file for my application when the user clicks on the link.
    I have created a resource file and then I have changed resource file .qrc to .py file.
    Now I don't know how to get that pdf file and show it from .py file. In .py file the pdf file is written as binary code.

    jsulmJ 1 Reply Last reply
    0
    • S Selvajothi

      I want to show the help file for my application when the user clicks on the link.
      I have created a resource file and then I have changed resource file .qrc to .py file.
      Now I don't know how to get that pdf file and show it from .py file. In .py file the pdf file is written as binary code.

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

      @Selvajothi You can store the PDF content as temp file and show that temp file then.

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

      1 Reply Last reply
      2
      • S Offline
        S Offline
        Selvajothi
        wrote on last edited by
        #3

        I tried this but it is not working

        destinationTemp = QDir.fromNativeSeparators(path)#path is a local directory
        fileName = "manual"
        QFile.copy("qrc:/newPrefix/text.pdf", destinationTemp + fileName + ".pdf")
        QDesktopServices.openUrl(QUrl.fromLocalFile(destinationTemp + fileName + ".pdf"))

        J.HilkJ Pablo J. RoginaP 2 Replies Last reply
        0
        • S Selvajothi

          I tried this but it is not working

          destinationTemp = QDir.fromNativeSeparators(path)#path is a local directory
          fileName = "manual"
          QFile.copy("qrc:/newPrefix/text.pdf", destinationTemp + fileName + ".pdf")
          QDesktopServices.openUrl(QUrl.fromLocalFile(destinationTemp + fileName + ".pdf"))

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Selvajothi
          try it with

          ":/newPrefix/text.pdf"
          

          not qrc:...


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          S 1 Reply Last reply
          1
          • S Selvajothi

            I tried this but it is not working

            destinationTemp = QDir.fromNativeSeparators(path)#path is a local directory
            fileName = "manual"
            QFile.copy("qrc:/newPrefix/text.pdf", destinationTemp + fileName + ".pdf")
            QDesktopServices.openUrl(QUrl.fromLocalFile(destinationTemp + fileName + ".pdf"))

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by Pablo J. Rogina
            #5

            @Selvajothi said in How to open a pdf loaded in resource file?:

            it is not working

            what is not working? please describe...

            Are you able to see the temp file being created on disk?
            If so, are you able to open such file with an external PDF viewer?
            If so, what happens if you double click/select such file from the OS? is any default application launching? I mean, are you sure the PDF extension has a default app linked to it in your OS?

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @Selvajothi
              try it with

              ":/newPrefix/text.pdf"
              

              not qrc:...

              S Offline
              S Offline
              Selvajothi
              wrote on last edited by
              #6

              @J-Hilk Thank you . It is working now

              Pablo J. RoginaP 1 Reply Last reply
              1
              • S Selvajothi

                @J-Hilk Thank you . It is working now

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @Selvajothi said in How to open a pdf loaded in resource file?:

                It is working now

                It would be great if you could explain what way you solved the issue.

                In addition, please don't forget to mark your post as solved then!

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Selvajothi
                  wrote on last edited by
                  #8

                  I have changed ":/newPrefix/text.pdf" from "qrc:/newPrefix/text.pdf"

                  1 Reply Last reply
                  1

                  • Login

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