Results 1 to 16 of 16

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

  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)

  14. #12
    Join Date
    Sep 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    If you want to print OpenDocument formats (only .odt, not .doc) via your application you can use KOffice's source codes. But this needs to done by a huge hacking of sources.

    Also for printing .doc files, you can use extra libraries like doc2pdf or doc2html (won't be stable because of Qt's Html Renderer) to print.

  15. #13
    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

    Quote Originally Posted by ocean View Post
    If you want to print OpenDocument formats (only .odt, not .doc) via your application you can use KOffice's source codes. But this needs to done by a huge hacking of sources.

    Also for printing .doc files, you can use extra libraries like doc2pdf or doc2html (won't be stable because of Qt's Html Renderer) to print.
    You know KOffice source? I read on a wiki kword that the porting from last testing is already QT4 compatible.... is this true?
    I use XSLT to convert OpenFormat odt or old swx to QTextDocument on my application http://www.qt-apps.org/content/show....?content=67552 and this App can handle BookMark pdf (QTreeItem Model) .
    But i am not happy to use QTextDocument if i draw 50 page i can take 1-2 coffe in this time by render all text . I can only write 5-6 page to QTextDocument to stay on acceptable time.


    I Install the new KDE 4.1 on my debian and i try his Kword its run ok .. and i find a bug ....
    what is place to submit Kword bug?

    Kword: If i copy text from one page and i continue to paste 20 time on page it crash.


    How i can begin to extract a virtual ..
    ScribeDocument a TextCursor and a AbstractDocLayout from Kword to draw text?
    Have you any idea?

    My target is to handle XSL-FO document which having many option to buil document or book if XSL-FO having pdf form generator it having the same option as Latex/tex.

  16. #14
    Join Date
    Aug 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Quote Originally Posted by patrik08 View Post
    You know KOffice source? I read on a wiki kword that the porting from last testing is already QT4 compatible.... is this true?
    KOffice2 is built using Qt4

    Quote Originally Posted by patrik08 View Post
    what is place to submit Kword bug?

    Kword: If i copy text from one page and i continue to paste 20 time on page it crash.
    I think it's at: https://bugs.kde.org/

    The other questions on you message I don't know. I'm not very familiar with KOffice/KWord code. Hopefully someone else in this forum can help you out.

  17. #15
    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

    Quote Originally Posted by wysota View Post
    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.
    You think after is possibel to read & write Open Document Format?

    I grab the snapshots qt4.5 from today i find only

    init QTextDocumentWriter

    -> QTextOdfWriter
    -> QZipWriter

    > QZipReader
    > OdfReader (fail not exist at this time)

    Ok QtextDocument and all child having a lot of change to style Open Document Format
    i can see difference on page
    http://code.google.com/p/fop-miniscr...e/detail?r=356
    i load first qt4.4 src/gui/text at end qt4.5

    I ask you its possibel to comming soon a Reader Open Document Format?
    I find only http://labs.trolltech.com/blogs/2008...cument-format/

  18. #16
    Join Date
    Aug 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Quote Originally Posted by patrik08 View Post
    You think after is possibel to read & write Open Document Format?
    ...
    I ask you its possibel to comming soon a Reader Open Document Format?
    I find only http://labs.trolltech.com/blogs/2008...cument-format/
    I asked that on the comments on the blog post you linked. Thiago Macieira (employee of Trolltech) responded saying that Qt 4.5 will only have a way to write ODF, not read. Makes zero sense to me (having a writer and not a reader), but it's their call. Maybe by looking at the code from QTextDocumentWriter one should be able to create a QTextDocumentReader.

Similar Threads

  1. Read binary file and convert to QString
    By jaca in forum Qt Programming
    Replies: 12
    Last Post: 14th June 2008, 00:05
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  3. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 19: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.