Results 1 to 4 of 4

Thread: QPrinter generates empty page

  1. #1
    Join Date
    Aug 2006
    Location
    istanbul, turkey
    Posts
    42
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QPrinter generates empty page

    Hi,

    When i initialize QPrinter object with QPrintDialog (which enables user to select whose prefered printer) printer reports an error indicating it is an empty page. But when i choose a pdf or ps file from the same dialog, QPrinter successfully generates file. Printers are working as i'm able to print generated ps/pdf files. Error only comes when i want to print directly to printers with qt.

    My qt version is: qt 4.4.3

    code below does not work either:

    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QPrinter printer;
    9.  
    10. QPrintDialog *dialog = new QPrintDialog(&printer, NULL);
    11. dialog->setWindowTitle("Print Dialog");
    12. if (dialog->exec() == QDialog::Accepted) {
    13. QTextDocument doc( "abcd efg" );
    14. doc.print(&printer);
    15. }
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

    Hayati

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPrinter generates empty page

    You should do some error checking.
    Use these steps:
    1. Find the state of printer just before printing.
    Qt Code:
    1. QPrinter::printerState()
    To copy to clipboard, switch view to plain text mode 
    2. Check for general connectivity of printer with your machine. Try to print a test page from your machine.
    3. Use:
    Qt Code:
    1. QPrinter::isValid ()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2006
    Location
    istanbul, turkey
    Posts
    42
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPrinter generates empty page

    Quote Originally Posted by yogeshgokul View Post
    You should do some error checking.
    Use these steps:
    1. Find the state of printer just before printing.
    Qt Code:
    1. QPrinter::printerState()
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QPrinter::printerState()
    To copy to clipboard, switch view to plain text mode 
    is Idle so it's ok to send documents.
    Quote Originally Posted by yogeshgokul View Post
    2. Check for general connectivity of printer with your machine. Try to print a test page from your machine.
    I am able to print documents from the printer.
    Quote Originally Posted by yogeshgokul View Post
    3. Use:
    Qt Code:
    1. QPrinter::isValid ()
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QPrinter::isValid()
    To copy to clipboard, switch view to plain text mode 
    returns true.

    change log from qt 4.4.3 to 4.5.0 is below (QPrinter):
    - QPrinter
    * [232415] Fixed a problem that caused a an invalid QPrinter
    object to not update its validity after being passed into a
    QPrintDialog.
    * [215401] Fixed the size of the Executive paper format.
    * [202113] Improved speed when printing to a highres PostScript printer.
    * [195028] Trying to print to a non-existing file didn't update the validity
    of the QPrinter object correctly.
    * [134820] Support CUPS printer instances on Unix systems (Mac and X11).
    * [201875] Fixed a bug that caused the fill opacity of a brush to be used
    for the stroke in certain cases.
    * [222056] Fixed absolute letter spacing when printing.
    * [234135] Fixed a problem with custom margins for CUPS printers.

    does anybody have the same problem with me with the same qt version. i'm not willing to upgrade my qt version.

    I should mention that i'm using a network printer, but as i mentioned before i'm able to print documents from this printer.

  4. #4
    Join Date
    Aug 2006
    Location
    istanbul, turkey
    Posts
    42
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QPrinter generates empty page

    in addition,

    as i observed so far, i am able to send print jobs to printer (both from cups server and printer status dialog of operating system). but printer complains about empty page. so i suspect about something else other than QPrinter as it's valid and Qt successfully sends document to specified printer. But the problem is, file generated is empty!

Similar Threads

  1. QPrinter without page number
    By estanisgeyer in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2015, 13:19
  2. Replies: 1
    Last Post: 7th July 2009, 16:46
  3. Replies: 1
    Last Post: 5th July 2009, 10:10
  4. QPrinter: PDF files without page numbers
    By vcp in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2008, 19:59
  5. How can I put text on each page using QPrinter
    By davit in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2007, 12:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.