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. convert word doc to pdf using qt cpp
Forum Updated to NodeBB v4.3 + New Features

convert word doc to pdf using qt cpp

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 6 Posters 2.1k 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.
  • H Offline
    H Offline
    harsha123
    wrote on last edited by
    #9

    Ok, i try with that..
    thank you

    JonBJ 1 Reply Last reply
    0
    • H harsha123

      Ok, i try with that..
      thank you

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

      @harsha123
      I think/hope the following is claimed to work from https://forum.qt.io/topic/128464/export-pdf-file-from-excel-template-with-qt-and-qaxobject/12

      workbook->dynamicCall("ExportAsFixedFormat(int,QString,int,int,int)",0,pdfFile,0,0,bIgnorePrintAreas);

      Note how that declares and passes the parameters. That is for an Ecel workbook, does that work same for a Word document?

      UPDATE
      Or for Word https://forum.qt.io/topic/127801/saving-from-word-to-pdf/2 claims

          document->querySubObject("ExportAsFixedFormat(const QVariant&,const QVariant&,const QVariant&)",
                                   OutputFileName,
                                   ExportFormat,
                                   OpenAfterExport);
      

      does work, compare yours to that. That's all I know!

      1 Reply Last reply
      0
      • H Offline
        H Offline
        harsha123
        wrote on last edited by
        #11

        when i try check the return value of document->querySubObject("ExportAsFixedFormat(const QVariant&,const QVariant&,const QVariant&)",
        OutputFileName,
        ExportFormat,
        OpenAfterExport);
        I am getting QObject(0x0).

        for this
        QVariant doc_op=document->dynamicCall("ExportAsFixedFormat(int,QString,int,int,int)",0,pdfFile,0,0,bIgnorePrintAreas);
        I am getting QVariant(Invalid)

        can any one suggest , I am trying but it is not working please suggest if am missing some thing.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          harsha123
          wrote on last edited by
          #12

          Please suggest if i need to add anything regarding this https://stackoverflow.com/questions/42909112/saving-word-document-as-pdf
          in qt cpp , I dont understand how to include or how to proceed with this VBA script.

          JonBJ 1 Reply Last reply
          0
          • H harsha123

            Please suggest if i need to add anything regarding this https://stackoverflow.com/questions/42909112/saving-word-document-as-pdf
            in qt cpp , I dont understand how to include or how to proceed with this VBA script.

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

            @harsha123
            You cannot use use the code in your last stackoverflow reference because it is VBA script and only for use from MS VB or within Word.

            I cannot see why your previous code should not work given that the thread I pointed you to says that it does.

            I would give a go at the Excel print-to-PDF code from https://forum.qt.io/topic/128464/export-pdf-file-from-excel-template-with-qt-and-qaxobject/12 to see whether that does or does not work for you for Excel instead of Word.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              harsha123
              wrote on last edited by
              #14

              This ExportAsFixedFormat() is also failing for excel conversion also when checked the return type getting Like QVariant(Invalid).

              QAxBase::dynamicCallHelper: ExportAsFixedFormat(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant): No such property in [unknown]
              Candidates are:
              EnableAutoFilter
              EnableCalculation
              EnableOutlining
              EnablePivotTable
              EnableSelection

              I need to add anything in. pro other that please check and tell...

              QT += core gui
              QT += core gui axcontainer
              QT += widgets axcontainer
              QT +=printsupport
              QT += axcontainer
              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

              TARGET = ms_Word_application
              TEMPLATE = app

              SOURCES += main.cpp
              mainwindow.cpp

              HEADERS += mainwindow.h

              FORMS += mainwindow.ui

              Please suggest

              JonBJ 1 Reply Last reply
              0
              • H harsha123

                This ExportAsFixedFormat() is also failing for excel conversion also when checked the return type getting Like QVariant(Invalid).

                QAxBase::dynamicCallHelper: ExportAsFixedFormat(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant): No such property in [unknown]
                Candidates are:
                EnableAutoFilter
                EnableCalculation
                EnableOutlining
                EnablePivotTable
                EnableSelection

                I need to add anything in. pro other that please check and tell...

                QT += core gui
                QT += core gui axcontainer
                QT += widgets axcontainer
                QT +=printsupport
                QT += axcontainer
                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                TARGET = ms_Word_application
                TEMPLATE = app

                SOURCES += main.cpp
                mainwindow.cpp

                HEADERS += mainwindow.h

                FORMS += mainwindow.ui

                Please suggest

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

                @harsha123
                Looks OK, except no point keep adding the same QT += module repeatedly.

                https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.exportasfixedformat says:

                An error occurs if the PDF add-in is not currently installed.

                I don't know that would cause your error message, but have you at least verified you can do the export to PDF what way from within your Excel/Word? Can you pick a different value for your ExportFormat to see whether non-PDF works? I think Word has a SaveAs method for PDF instead of Export, look up examples, does it work that way?

                You will have to figure how yourself, but if you take a VBA script example instead I think you can put it into a Word VBA script/macro inside Word and test running it from there. That needs to work....

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  harsha123
                  wrote on last edited by
                  #16

                  That means i need to install any specific plugins for the conversion to be if so please mention the plugins to install.

                  JonBJ 1 Reply Last reply
                  0
                  • H harsha123

                    That means i need to install any specific plugins for the conversion to be if so please mention the plugins to install.

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

                    @harsha123
                    Like I told you, what I have typed is all I know. I don't even have Qt for Windows.

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      harsha123
                      wrote on last edited by
                      #18

                      Thank u its working this code is working this problem is because of not having pulgings only finally it is resolved.

                      1 Reply Last reply
                      0

                      • Login

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