PDA

View Full Version : how to convert a xml + xsl to PDF in Qt4.4.3



richardander
10th January 2009, 10:11
Hi,

My program outputs xml file and xsl file. The xml can be displayed properly in web broswer. I would like to convert xml to PDF sliently without showing in web browser, is it possible to do it with Qt4.4.3?

If not, do you know any way or other version Qt to do it?

thank you!

jpn
10th January 2009, 10:21
Yes, it's possible. Take a look at QPrinter docs. Make sure to search for "PDF", there's an example how to print to a PDF file.

richardander
10th January 2009, 10:30
I can understand how to print to a PDF. the difficult part is how to render xml and xsl files and pass the result to QPrinter.

The webbrowser can do the rendering. Can any class in Qt4.4 or following version do this?

thank you!

jpn
10th January 2009, 10:35
You can use QTextDocument. There's a simple XML highlighter example in our wiki: XmlHighlighter.

EDIT: PS. Notice QTextDocument::print().

richardander
10th January 2009, 11:01
QTextDocument can only manipulate the text in XML file. What I want to do is convert the result of xml/xsl ( as what can be seen in a browser, with tables, images, etc) to a PDF. BTW, can qwebview load xml/xsl file and display it as other web browsers like iexplorer/firefox?

Thank you!