Hi all
I am working on a project where we need to produce documents (in a platform independent way) from data held withing the application.
Does anyone have any recomendations on how this can be achieved?
TIA
Graham
Printable View
Hi all
I am working on a project where we need to produce documents (in a platform independent way) from data held withing the application.
Does anyone have any recomendations on how this can be achieved?
TIA
Graham
Hi - thanks for replying
Forgive my ignorance, I am completely new to QT.
I am currently redesigning/rewriting an exiting MS application to use QT so we can take advantage of platform and language independence that QT offers.
Currently the application produces a simplistic plain text document, but our customers want a professional looking document- currently they use our data to produce a MS Word document.
How easy is it to produce a PDF document? (how does one do it)?
Is there an advantage to using something like ODF? (would our customers be able to read the document)
TIA
Graham
Well it depends what your customer want to do with the document. If don't want to change it, I would go for pdf, since then it is guaranteed, that it look everywhere the same and you can store the document a long time. If you want to change values then of course go for odf. But it sounds like your costumer only wants something to print out.
For pdf there are some examples, but effectively it is nothing else than painting (using QPainter) on a defined piece of paper where you have to positioning the elements. One nice thing is that you can also use a QTextDocument for more advanced text documents and print it directly using QTextDocument::print().
I don't know if you have found that: http://doc.trolltech.com/qq/qq27-odfwriter.html. It's an good article for starting. Even if it is for odt.
A good idea is to render the document into html and then print it to pdf from WebKit using means already mentioned by Lykurg.
Thanks everyone
Hi everyone
I used the code from the QT Quarterly suggested by Lykurg to produce a odt document.
However when I try to open with MS Word it refuses as it says that the file couild not be opened - 'the open office XML .. file could not be opened' the details tab gives 'the file is corrupt and could not be opened'
Any ideas?
Graham
MS Word can't open ODT files without a dedicated filter.
Hi wysota
What filter do I need?
Ask google for "word odf"... E.g. http://sourceforge.net/projects/odf-converter/
Thanks Lykurg
I have downloaded the odf-converter and can now open the generated odt file, however, the formating is all lost and does not look like the example given
any more ideas?
Graham
Do you require the document to be editable in Word or is it just something you would like to have?
The document should be editable in word and preferably on MAC and *nix
*should* or *has to*? If it has to be editable on all of those platforms then your only choice is RTF. Just know there is no direct support for it in Qt.
Hi
I am still playing with odt documents.
I have created a document within a QT application and am using OpenXML/ODF Translator Add-in for Office to convert it.
The document contains a table and an image.
When I open the document I see the plain text and the table, but the format I applied to the table is not visible (solid borders) and I see no image. Do you have any ide why this is?
Code for table
Code:
"Phone bill for %1\n").arg(client)); QTextTableFormat tableFormat; tableFormat.setBorderStyle( m_cursor.insertTable(1, 3,tableFormat);
Code for image
Code:
const int columnSize = 10; int width = values.count() * columnSize; int max = 0; foreach (int x, values) max = qMax(max, x); painter.fillRect(0, 0, image.width(), image.height(), Qt::red); // background for (int index = 0; index < values.count(); ++index) { // Adjust scale to our 100 pixel tall image: int height = values[index] * 100 / max; painter.fillRect(index * columnSize, image.height() - height, columnSize, height, Qt::black); } painter.end(); cursor.insertText(subtext); cursor.insertBlock(); cursor.insertImage(image);
TIA
Graham
In my opinion you are just wasting your time. You will never be able to preserve complete formatting this way. You will lose some first when you export the document from Qt (as the odt writer is not 100% compliant with OpenOffice's odf reader) and then you'll lose some again trying to convert to Word. If you are after displaying the document then use PDF. If you are after editing it, use RTF. If you are after editing it and don't mind buying additional software, use PDF and use Acrobat (or equivalent) to edit the document.