Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Combining Two PDF Files



  • Is there any way to combine two PDF file generated using QT?


  • Qt Champions 2019

    @ManiRon How did you generate them?



  • using Qprinter


  • Qt Champions 2019

    @ManiRon I don't think Qt provides anything for this.
    But can't you generate one PDF instead of generating two and then merging?



  • sorry. Ya but i am trying to add a header to the PDF using the HTML and then i want to print the text is there any way i can do this



  • My HTML Code :

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    .logo {
    width: 150px;
    height: 120px;

    }

    .logoHeader {
    height: 120px;
    vertical-align: middle;
    text-align: center;
    }

    .floatLeft { float: left; }

    .floatRight { float: right; }
    </style>
    </head>
    <body>

    <header>
    <img class="logo floatLeft" src="Logo.png" alt="Logo" />

    <img class="logo floatRight"  src="Data.gif" alt="Logo" />
    
    <h1 class="logoHeader">REPORT</h1>
    

    </header>

    </body>
    </html>



  • This is my QT Code :
    QFile styleFile( "widget.qss" );
    styleFile.open( QFile::ReadOnly );
    QString hex = QString::fromLatin1( styleFile.readAll() );
    styleFile.close();
    QTextDocument document;
    QTextDocument document1;
    QString data = ui->teData->toPlainText();
    document.setHtml(hex.append(data));
    QPrinter printer;
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setPaperSize(QPrinter::A4);
    printer.setOutputFileName("test.pdf");
    QPainter painter;
    painter.begin(&printer);
    painter.setBrush(Qt::transparent);
    painter.end();


Log in to reply