Results 1 to 6 of 6

Thread: 2 questions on QPrint + QImage + PDF

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: 2 questions on QPrint + QImage + PDF

    Quote Originally Posted by jpn View Post
    I suspect the problem is in "// Draw some text to image".
    Here is the smallest code which gives the problem:

    Qt Code:
    1. painter.save();
    2. painter.setPen(Qt::black);
    3. painter.setFont(Strings::titleFont());
    4. painter.drawText(QRect(5,5,200,43), Qt::AlignLeft, Strings::title);
    5. painter.restore();
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by jpn View Post
    Qt Code:
    1. QPrinter printer;
    2. printer.setOrientation(QPrinter::Portrait);
    3. printer.setOutputFileName("test.pdf");
    4. printer.setOutputFormat(QPrinter::PdfFormat);
    5.  
    6. QImage image1(730,1053,QImage::Format_ARGB32);
    7. QImage image2(730,1053,QImage::Format_ARGB32);
    8.  
    9. QPainter painter1;
    10. painter1.setRenderHint(QPainter::Antialiasing, true);
    11. painter1.begin(&image1);
    12. // Some drawings
    13.  
    14. QPainter painter2;
    15. painter2.setRenderHint(QPainter::Antialiasing, true);
    16. painter2.begin(&image2);
    17. // Some drawings
    18.  
    19. p.setRenderHint(QPainter::Antialiasing, true);
    20. p.begin(&printer);
    21. p.drawImage(0, 0, image1);
    22. printer.newPage();
    23. p.drawImage(0, 0, image2);
    24. p.end();
    To copy to clipboard, switch view to plain text mode 

    Am I right?
    Last edited by jiveaxe; 11th January 2008 at 17:41.
    Giuseppe CalÃ

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. QShared
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 11th October 2007, 12:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.