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

Is it possible to make a pdf with different page size?



  • If the size of the page is same, then no problem, but I need the page size should be the size of Image(which is variable),
    @
    void DgJpgToPdf::convertToPdf( const QStringList& theImagePathList, const QString& theOutputFileName )
    {
    QPrinter printer;
    printer.setOrientation(QPrinter::Portrait);
    printer.setOutputFormat( QPrinter::PdfFormat );
    printer.setOutputFileName( theOutputFileName );
    QPainter painter;
    painter.begin( &printer );
    //printer.newPage();
    foreach( QString fileName, theImagePathList ){
    QImage imgObj( fileName );
    printer.setPaperSize( QSizeF(imgObj.width(), imgObj.height()), QPrinter::DevicePixel );
    painter.drawImage( 0, 0, imgObj );
    printer.newPage();
    }
    painter.end();
    }
    @

    its giving me a pdf with first page ok. but the next pages contains some distorted images.
    please help?


Log in to reply