Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using existing pdf file?
Forum Updated to NodeBB v4.3 + New Features

Using existing pdf file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 6 Posters 2.9k Views 4 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.
  • MucipM Offline
    MucipM Offline
    Mucip
    wrote on last edited by
    #1

    Hi,
    Is it possible to use existinf pdf document?
    For example, I want to create empty invoice template table first. Then I will use this pdf file and fill the lines and save as new pdf invoice number name?

    Regards,
    Mucip:)

    beeckscheB 1 Reply Last reply
    0
    • MucipM Mucip

      Hi,
      Is it possible to use existinf pdf document?
      For example, I want to create empty invoice template table first. Then I will use this pdf file and fill the lines and save as new pdf invoice number name?

      Regards,
      Mucip:)

      beeckscheB Offline
      beeckscheB Offline
      beecksche
      wrote on last edited by beecksche
      #2

      @Mucip

      Why do need the template? Print the invoce at once.

      With the QTextDocument class you can write your invoice and save it as PDF with print and QPdfWriter.

      MucipM 1 Reply Last reply
      2
      • beeckscheB beecksche

        @Mucip

        Why do need the template? Print the invoce at once.

        With the QTextDocument class you can write your invoice and save it as PDF with print and QPdfWriter.

        MucipM Offline
        MucipM Offline
        Mucip
        wrote on last edited by
        #3

        Hi @beecksche,
        I know. But I hate to adjust grids, horizontal/vertical lines and put company image on pdf file! This is really TORTURE for me...

        I want to skip all this layout (grid, line, picture) works and jump to write values on the appropriate location on the template invoice...

        Regards,
        Mucip:)

        beeckscheB 1 Reply Last reply
        0
        • MucipM Mucip

          Hi @beecksche,
          I know. But I hate to adjust grids, horizontal/vertical lines and put company image on pdf file! This is really TORTURE for me...

          I want to skip all this layout (grid, line, picture) works and jump to write values on the appropriate location on the template invoice...

          Regards,
          Mucip:)

          beeckscheB Offline
          beeckscheB Offline
          beecksche
          wrote on last edited by
          #4

          @Mucip
          AFAIK that's not possible with Qt. Maybe you need a third party library.

          Maybe you can read/import the PDF template and use it as image and paint the text at specific positions. But I think that the output won't be of high quality (and you need also a lot of work to adjust the positions of the text).

          I would create the PDF at once, here you need to create your class only once with the wished style. And the output should look better.

          MucipM 1 Reply Last reply
          0
          • beeckscheB beecksche

            @Mucip
            AFAIK that's not possible with Qt. Maybe you need a third party library.

            Maybe you can read/import the PDF template and use it as image and paint the text at specific positions. But I think that the output won't be of high quality (and you need also a lot of work to adjust the positions of the text).

            I would create the PDF at once, here you need to create your class only once with the wished style. And the output should look better.

            MucipM Offline
            MucipM Offline
            Mucip
            wrote on last edited by
            #5

            @beecksche
            Any advice about third party library which is opensource and platform independent?...

            Regards,
            Mucip:)

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              If you have Acrobat Pro (i.e. the paid version) you can create the base PDF and add form fields on it. Then you can use QXmlStreamWriter to create an XFDF file with the values that will fill the form

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              MucipM 1 Reply Last reply
              2
              • VRoninV VRonin

                If you have Acrobat Pro (i.e. the paid version) you can create the base PDF and add form fields on it. Then you can use QXmlStreamWriter to create an XFDF file with the values that will fill the form

                MucipM Offline
                MucipM Offline
                Mucip
                wrote on last edited by
                #7

                @VRonin ,
                Unfortunatelly no... :(
                Any other?
                What about poopler?... Is there anyone who use it?

                Regards,
                Mucip:)

                mrjjM 1 Reply Last reply
                0
                • MucipM Mucip

                  @VRonin ,
                  Unfortunatelly no... :(
                  Any other?
                  What about poopler?... Is there anyone who use it?

                  Regards,
                  Mucip:)

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Mucip
                  Hi
                  Just as a note.
                  you can cheat and use
                  command line tool that can merge 2 pdfs.
                  https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

                  so you print your data to one pdf and use pdftk to merge with the
                  template form pdf into a new pdf.

                  MucipM 1 Reply Last reply
                  2
                  • mrjjM mrjj

                    @Mucip
                    Hi
                    Just as a note.
                    you can cheat and use
                    command line tool that can merge 2 pdfs.
                    https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

                    so you print your data to one pdf and use pdftk to merge with the
                    template form pdf into a new pdf.

                    MucipM Offline
                    MucipM Offline
                    Mucip
                    wrote on last edited by
                    #9

                    Hi @mrjj ,
                    I think using extra command line is not clean way to solve this... :(

                    Regards,
                    Mucip:)

                    mrjjM 1 Reply Last reply
                    0
                    • MucipM Mucip

                      Hi @mrjj ,
                      I think using extra command line is not clean way to solve this... :(

                      Regards,
                      Mucip:)

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Mucip
                      Hi
                      Well it worked pretty flawless for years for me.
                      pdftk is really high quality.
                      But yes, it's not as smooth as having
                      the feature directly in the app.
                      It was just a suggestion as editing a pdf is
                      hard to archive for free.

                      Have you considered just use an SVG file as the template ?

                      MucipM 1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @Mucip
                        Hi
                        Well it worked pretty flawless for years for me.
                        pdftk is really high quality.
                        But yes, it's not as smooth as having
                        the feature directly in the app.
                        It was just a suggestion as editing a pdf is
                        hard to archive for free.

                        Have you considered just use an SVG file as the template ?

                        MucipM Offline
                        MucipM Offline
                        Mucip
                        wrote on last edited by
                        #11

                        Hi @mrjj ,
                        Ofcourse. Why not? I may prepare some template with Inkscape. No problem...
                        Well, How???..

                        Regards,
                        Nucip:)

                        mrjjM 1 Reply Last reply
                        0
                        • MucipM Mucip

                          Hi @mrjj ,
                          Ofcourse. Why not? I may prepare some template with Inkscape. No problem...
                          Well, How???..

                          Regards,
                          Nucip:)

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #12

                          @Mucip
                          Hi
                          Was thinking on inkscape :)
                          You can get positions of SVG elements with
                          http://doc.qt.io/qt-5/qsvgrenderer.html#boundsOnElement
                          so its possible to load the SVG and find out where placeholders are and then
                          first draw SVG template , then draw the text in place holders positions.
                          and then save it all as pdf.
                          SVG looks good in all resolutions.

                          Please notice that Inkscape kinda flips the y coordinates, so google that as
                          it fooled me a bit.

                          MucipM 1 Reply Last reply
                          1
                          • mrjjM mrjj

                            @Mucip
                            Hi
                            Was thinking on inkscape :)
                            You can get positions of SVG elements with
                            http://doc.qt.io/qt-5/qsvgrenderer.html#boundsOnElement
                            so its possible to load the SVG and find out where placeholders are and then
                            first draw SVG template , then draw the text in place holders positions.
                            and then save it all as pdf.
                            SVG looks good in all resolutions.

                            Please notice that Inkscape kinda flips the y coordinates, so google that as
                            it fooled me a bit.

                            MucipM Offline
                            MucipM Offline
                            Mucip
                            wrote on last edited by
                            #13

                            Hi @mrjj ,
                            How can I prepare some template with text input?
                            As I understant from your post SVG elements need to be put on template and I don't know about this.
                            I will check google how to work with SVG elements.

                            By the way do you have sample SVG file or manual to do your suggestion?

                            Regards,
                            Mucip:)

                            mrjjM 1 Reply Last reply
                            0
                            • MucipM Offline
                              MucipM Offline
                              Mucip
                              wrote on last edited by
                              #14

                              Hi @bougti ,
                              I couldn't understand why I need this?...

                              Regards,
                              Mucip:)

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @Mucip It was a spam post.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                MucipM 1 Reply Last reply
                                1
                                • SGaistS SGaist

                                  @Mucip It was a spam post.

                                  MucipM Offline
                                  MucipM Offline
                                  Mucip
                                  wrote on last edited by
                                  #16

                                  Hi @SGaist
                                  What a strange guys?! :(
                                  I couldn't understand what is the benefit of this beheviour?

                                  Regards,
                                  Mucip:)

                                  1 Reply Last reply
                                  1
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    Trying to lure people going on their fishy website for who knows what.

                                    Some are tricky to detect.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    1
                                    • MucipM Mucip

                                      Hi @mrjj ,
                                      How can I prepare some template with text input?
                                      As I understant from your post SVG elements need to be put on template and I don't know about this.
                                      I will check google how to work with SVG elements.

                                      By the way do you have sample SVG file or manual to do your suggestion?

                                      Regards,
                                      Mucip:)

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      @Mucip said in Using existing pdf file?:

                                      • How can I prepare some template with text input?
                                        Draw it using inkscape.
                                        Each element of page has an ID. ( and you can change it to something more easy to read)
                                        So place a rect, where you want the USER text to be put.
                                        Set the ID of this rect to something that make sense. ( name of what text is for)
                                        Then from Qt, you can use http://doc.qt.io/qt-5/qsvgrenderer.html#boundsOnElement
                                        to find the place rect again and then draw the USER text there.
                                        So first draw the SVG template, then draw USER text at the ID locations and
                                        save it all as pdf.

                                      • As I understant from your post SVG elements need to be put on template and I don't know about this.
                                        Well the template is the SVG file and you just use a rect as place holder to where text goes.

                                      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