Results 1 to 2 of 2

Thread: with pdf printer.newPage() fails everytime

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2013
    Location
    Wisconsin
    Posts
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default with pdf printer.newPage() fails everytime

    Trying to write a function that you pass a QStringList to, and a file name - creates a multiple page PDF - each string list holding HTML for that page.

    Here is my code always creates the last page as the only page with page 1 in the corner , new page returns false every time

    Qt Code:
    1. void pmdUtility::pmdMakePdf(QStringList oPages,QString qsFileName)
    2. {
    3. QPrinter printer;
    4. printer.setOrientation(QPrinter::Portrait);
    5. printer.setPaperSize(QPrinter::A4);
    6. printer.setResolution(300);
    7. printer.setFullPage(false);
    8. printer.setCopyCount(1);
    9. printer.setColorMode(QPrinter::Color);
    10.  
    11. printer.setOutputFormat(QPrinter::PdfFormat);
    12. printer.setOutputFileName(qsFileName);
    13. QRect Rect1(0.0,0.0,printer.width(),printer.height());
    14. foreach (QString qsPage, oPages)
    15. {
    16. printer.newPage();
    17.  
    18. QTextDocument document;
    19. document.setHtml(qsPage);
    20. document.print(&printer);
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2013
    Location
    Wisconsin
    Posts
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: with pdf printer.newPage() fails everytime

    You can put one HTML page into a QTextDocument - you need to tell the HTML to parse the pages

    <DIV style="page-break-after:always"></DIV>

Similar Threads

  1. Replies: 8
    Last Post: 21st December 2011, 17:11
  2. Replies: 0
    Last Post: 3rd August 2011, 18:22
  3. QTableWidgetItem setData crashes everytime.
    By Wing_Zero in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2010, 19:59
  4. update() works fine sometime but not everytime..!!
    By salmanmanekia in forum Qt Programming
    Replies: 19
    Last Post: 22nd August 2008, 09:11
  5. No printer installed..?
    By Cutey in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2007, 11:08

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.