基于qt把ppt转换成pdf

void MainWindow::on_pushButton_2_clicked()
{
    QString fileName = "C:\\Users\\Administrator\\Desktop\\1112.pptx";
    QAxObject *_powerPointAxObj = new QAxObject("Powerpoint.Application", 0);
    if (!_powerPointAxObj)
    {
        _powerPointAxObj = new QAxObject("KWPP.Application", 0);
         if (!_powerPointAxObj)
         {
             return;
         }
    }
    _powerPointAxObj->dynamicCall("SetVisible(bool)", false);
    QAxObject *presentations = _powerPointAxObj->querySubObject("Presentations");
    QList paramList;
    paramList.push_back(QVariant(fileName));
    paramList.push_back(0);
    paramList.push_back(0);
    paramList.push_back(0);
    QAxObject *presentation = presentations->querySubObject("Open(const QString&,int,int,int)",paramList);
    if (presentation != nullptr)
    {
        paramList.clear();
        QString application_path = QApplication::applicationDirPath();
        application_path.replace("/", "\\");
        application_path += "\\ShowFile.pdf";
        paramList.push_back(application_path);
        paramList.push_back(32);
        paramList.push_back(0);
        presentation->dynamicCall("SaveAs(const QString&,int,int)", paramList);
        presentations->dynamicCall("Close()");  
        delete presentations;
    }
}

你可能感兴趣的:(基于qt把ppt转换成pdf)