Results 1 to 16 of 16

Thread: How to Print a doc file (or binary file) to printer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to Print a doc file (or binary file) to printer

    Hi guys,

    I would like to send to printer a doc file, or any other binary file using Qt4,
    but i'm not ablet to get to a solution.
    Is there an easy way to do that ?

    Thank you very mutch in advance..

    Roby

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to Print a doc file (or binary file) to printer

    read source from:
    http://www.qt-apps.org/content/show....?content=62383
    is a easy example inside ....

  3. #3
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Print a doc file (or binary file) to printer

    I do not understand which is the part in that example code that should lead me to the solution for the problem I posted..
    I mean some of you knows the two or three lines of code to send to the default printer,
    a file which is in the file system?

    Thanks to all

  4. #4
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to send a doc file (or binary file) to printer

    Hi all,

    ABout this tematic, I would like to know if there is the possibilitiy to treat binary document the same way as text document..
    we, indeed know, that for txt file it is possible to write somethink like:
    Qt Code:
    1. QFile txtFileOut(txtFile);
    2. txtFileOut.open(QFile::ReadOnly | QFile::Text);
    3. QTextStream txtFileIn(&txtFileOut);
    4. QString txtFileToQString(txtFileIn.readAll());
    5. QTextDocument *document = new QTextDocument(txtFileToQString);
    6.  
    7. QPrinter printer;
    8.  
    9. QPrintDialog *dlg = new QPrintDialog(&printer, this);
    10. if (dlg->exec() != QDialog::Accepted)
    11. return;
    12. document->print(&printer);
    To copy to clipboard, switch view to plain text mode 

    is there some possibility to do the same for binary files (doc, pdf, etc..) ?
    Thank you very mutch for you kind reply.
    Roby

  5. #5
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: How to Print a doc file (or binary file) to printer

    any help ?

    Thx

  6. #6
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: How to Print a doc file (or binary file) to printer

    Guys

    The problem I posted I found was discussed in the past bu even at that time there was not solution..

    This mean it is not possibile to do that using Qt ????

    Please let me know

  7. #7
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: How to Print a doc file (or binary file) to printer

    no one have idea?

  8. #8
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Print a doc file (or binary file) to printer

    Hi everybody..Any of you could help with the question posted ?
    Thank you

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Print a doc file (or binary file) to printer

    Qt doesn't handle such things. If you want things that platform dependent, use platform dependent API. Just be aware there is no magic call that would be able to print any file format. For example for printing postscript or pdf files on KDE you can simply call "kprinter /path/to/file", but you won't be able to print MS Word documents like that, in that case you have to open the document in an appropriate application (like Word itself or Open Office) and call the application's print method manually (or using ActiveX on Windows).

    You can use QDesktopServices to open a document in an appropriate application, but this won't get it printed automatically (the application might not even support printing at all).

  10. The following user says thank you to wysota for this useful post:

    rmagro (1st September 2008)

  11. #10
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Print a doc file (or binary file) to printer

    it means I can't use Qt Api to print a .odt file as well ?
    Thx

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Print a doc file (or binary file) to printer

    As for Qt 4.4 that's correct. As far as I know Qt 4.5 will be able to handle the Open Document Format.

  13. The following user says thank you to wysota for this useful post:

    rmagro (2nd September 2008)

Similar Threads

  1. Read binary file and convert to QString
    By jaca in forum Qt Programming
    Replies: 12
    Last Post: 13th June 2008, 23:05
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10

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.