PDA

View Full Version : How to Print a doc file (or binary file) to printer



rmagro
29th August 2008, 12:33
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

patrik08
29th August 2008, 13:50
read source from:
http://www.qt-apps.org/content/show.php/TextPrinter?content=62383
is a easy example inside ....

rmagro
29th August 2008, 14:04
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

rmagro
29th August 2008, 15:09
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:


QFile txtFileOut(txtFile);
txtFileOut.open(QFile::ReadOnly | QFile::Text);
QTextStream txtFileIn(&txtFileOut);
QString txtFileToQString(txtFileIn.readAll());
QTextDocument *document = new QTextDocument(txtFileToQString);

QPrinter printer;

QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;
document->print(&printer);


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

rmagro
29th August 2008, 15:54
any help ?

Thx

rmagro
29th August 2008, 16:14
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

rmagro
29th August 2008, 17:13
no one have idea?

rmagro
31st August 2008, 11:02
Hi everybody..Any of you could help with the question posted ?
Thank you

wysota
31st August 2008, 23:36
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).

rmagro
1st September 2008, 17:04
it means I can't use Qt Api to print a .odt file as well ?
Thx

wysota
1st September 2008, 18:27
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.

ocean
4th September 2008, 07:46
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.

patrik08
4th September 2008, 09:26
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.php/Fop+MiniScribus+XSL-Fo?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.

netuno
4th September 2008, 14:11
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



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.

patrik08
5th September 2008, 03:51
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-miniscribus/source/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/08/06/opendocument-format/

netuno
5th September 2008, 15:46
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/08/06/opendocument-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.