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. Is it possible to make a pdf with different page size?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 760 Views 1 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.
  • B Offline
    B Offline
    blue_sky
    wrote on last edited by
    #1

    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?

    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