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 3.0k 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.
  • M Mucip
    25 Jan 2019, 07:03

    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:)

    B Offline
    B Offline
    beecksche
    wrote on 25 Jan 2019, 07:40 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.

    M 1 Reply Last reply 25 Jan 2019, 07:44
    2
    • B beecksche
      25 Jan 2019, 07:40

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

      M Offline
      M Offline
      Mucip
      wrote on 25 Jan 2019, 07:44 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:)

      B 1 Reply Last reply 25 Jan 2019, 07:55
      0
      • M Mucip
        25 Jan 2019, 07:44

        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:)

        B Offline
        B Offline
        beecksche
        wrote on 25 Jan 2019, 07:55 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.

        M 1 Reply Last reply 25 Jan 2019, 08:00
        0
        • B beecksche
          25 Jan 2019, 07:55

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

          M Offline
          M Offline
          Mucip
          wrote on 25 Jan 2019, 08:00 last edited by
          #5

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

          Regards,
          Mucip:)

          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRonin
            wrote on 25 Jan 2019, 08:38 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

            M 1 Reply Last reply 25 Jan 2019, 08:40
            2
            • V VRonin
              25 Jan 2019, 08:38

              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

              M Offline
              M Offline
              Mucip
              wrote on 25 Jan 2019, 08:40 last edited by
              #7

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

              Regards,
              Mucip:)

              M 1 Reply Last reply 25 Jan 2019, 09:10
              0
              • M Mucip
                25 Jan 2019, 08:40

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

                Regards,
                Mucip:)

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 25 Jan 2019, 09:10 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.

                M 1 Reply Last reply 25 Jan 2019, 09:43
                2
                • M mrjj
                  25 Jan 2019, 09:10

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

                  M Offline
                  M Offline
                  Mucip
                  wrote on 25 Jan 2019, 09:43 last edited by
                  #9

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

                  Regards,
                  Mucip:)

                  M 1 Reply Last reply 25 Jan 2019, 09:56
                  0
                  • M Mucip
                    25 Jan 2019, 09:43

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

                    Regards,
                    Mucip:)

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 25 Jan 2019, 09:56 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 ?

                    M 1 Reply Last reply 25 Jan 2019, 10:00
                    1
                    • M mrjj
                      25 Jan 2019, 09:56

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

                      M Offline
                      M Offline
                      Mucip
                      wrote on 25 Jan 2019, 10:00 last edited by
                      #11

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

                      Regards,
                      Nucip:)

                      M 1 Reply Last reply 25 Jan 2019, 10:04
                      0
                      • M Mucip
                        25 Jan 2019, 10:00

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

                        Regards,
                        Nucip:)

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 25 Jan 2019, 10:04 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.

                        M 1 Reply Last reply 25 Jan 2019, 10:12
                        1
                        • M mrjj
                          25 Jan 2019, 10:04

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

                          M Offline
                          M Offline
                          Mucip
                          wrote on 25 Jan 2019, 10:12 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:)

                          M 1 Reply Last reply 27 Jan 2019, 02:02
                          0
                          • M Offline
                            M Offline
                            Mucip
                            wrote on 25 Jan 2019, 11:20 last edited by
                            #14

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

                            Regards,
                            Mucip:)

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 25 Jan 2019, 22:18 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

                              M 1 Reply Last reply 25 Jan 2019, 22:21
                              1
                              • S SGaist
                                25 Jan 2019, 22:18

                                @Mucip It was a spam post.

                                M Offline
                                M Offline
                                Mucip
                                wrote on 25 Jan 2019, 22:21 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
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 25 Jan 2019, 22:23 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
                                  • M Mucip
                                    25 Jan 2019, 10:12

                                    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:)

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 27 Jan 2019, 02:02 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

                                    11/18

                                    25 Jan 2019, 10:00

                                    • Login

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