Results 1 to 10 of 10

Thread: High quality business papers

  1. #1
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default High quality business papers

    Hey @all,

    i've an example application were i want to print/save invoices. So i get the data from a database and write xml/xslt documents. After this I generate a html page. This page i load it into a QTextDocument and/or into a QWebView, but the quality is terrible. This generated documents a can't give to any customers. What can i do to generate high quality documents? I make use of libxml2 and libxslt.

    Thanks for any hints and tips.

    Best Regards
    NoRulez

  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: High quality business papers

    Qt Code:
    1. This page i load it into a QTextDocument an....
    To copy to clipboard, switch view to plain text mode 

    QTextDocument quality as chance from 50% to 95% on QT version 4.5
    try your self if you use window...
    load file .....

    1 - http://fop-miniscribus.googlecode.co...extEdit4.5.exe
    2 - http://fop-miniscribus.googlecode.co...extEdit4.1.exe

    unpack on path your like or default desktop

    open the demo.html or demo.odt file on application 2 check speed on open document,
    after open demo.html or demo.odt file on application 1 qt4.5 build and the same document open it so quickly and the are minimum 2 - 3 sec. difference to open same file...
    Performance are super on qt4.5.

    If you can transform document on xslt use document format XSL-FO
    http://en.wikipedia.org/wiki/XSL_Formatting_Objects
    http://xmlgraphics.apache.org/fop/

    After you having 1000 more option on document ... pdf bookmark and other...
    i write http://code.google.com/p/fop-miniscribus/ but QTextDocument can not display all formating instruction.
    I print direct source to apache fop.

    on QT4.5 you dont need gnome xslt have a look on
    http://englich.wordpress.com/category/qt/
    http://fop-miniscribus.googlecode.co...k/doc/Xsltqt5/

    Try your QTextDocument code on QT4.5 an tell me..

  3. #3
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: High quality business papers

    Thank you,

    i've tried TextEdit 4.5, but the Result is the same. The Problem is that i use CSS within my XSLT Document for example I use:
    Qt Code:
    1. .
    2. .
    3. .
    4. .tdTest {
    5. text-align: right;
    6. border-left:none;
    7. border-right:1pt solid;
    8. }
    9. </style>
    10. </head>
    11. .
    12. .
    13. .
    14. <body>
    15. <table>
    16. <tr>
    17. <td class="tdTest">Simple Test</td>
    18. </tr>
    19. </table>
    To copy to clipboard, switch view to plain text mode 

    I doesn't see the border line and the text isn't aligned to the right.
    if I use "<div align="right">Simple Test</div>" within the <td> tags the text ist aligned to the right.

    I will have a look at XSL-FO

    Sorry, i forgot my QT Version: Currently I'm using QT-commercial 4.4.2

    Best Regards
    NoRulez

  4. #4
    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: High quality business papers

    css must load separate:

    http://wiki.qtcentre.org/index.php?t...images_and_CSS
    doc->addResource( QTextDocument::StyleSheetResource, QUrl( "format.css" ), css );

    or write inline style xslt template

    Open pdf http://fop-miniscribus.googlecode.co...ktestwrite.pdf this is writteln by XSL-FO + qt miniscribus 2 beta

    http://code.google.com/p/fop-miniscribus/
    why beta? i wait 4.5 stable release and stable OpenDocument reader/writer

    Reference + sample:
    http://www.zvon.org/xxl/xslfoReferen...put/index.html

  5. #5
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: High quality business papers

    But XSL-FO is written in Java?
    Is there a C/C++ api like libxml2 or libxslt?

    In another post you say you can automate such things (Invoice, ...) with xsl-fo. Can you give me an example how i can call or convert xml and xsl documents with xsl-fo?

    http://www.qtforum.de/forum/viewtopic.php?t=5279 and
    http://www.qtcentre.org/forum/f-gene...rmat-8050.html

    I think the first URL is written from you or he have the same name as you.

    Best Regards
    NoRulez

  6. #6
    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: High quality business papers

    Quote Originally Posted by NoRulez View Post
    But XSL-FO is written in Java?
    NO¨¨
    XSL-FO is pure xml !

    the pdf - rtf - doc - tiff render engine is java fop http://xmlgraphics.apache.org/fop/ High quality business papers
    but you can render XSL-FO -> PDF on qt like MiniScribus version 1/2.. only parse xml to qtextdocument all lib are ready.

    this xml -> http://fop-miniscribus.googlecode.co...marksample2.fo
    is the base from -> http://fop-miniscribus.googlecode.co...ktestwrite.pdf

    this xml -> http://fop-miniscribus.googlecode.co...ibetigersvg.fo it include svg image tiger as vector direct on xml...

    Quote Originally Posted by NoRulez View Post
    Is there a C/C++ api like libxml2 or libxslt?
    QT 4.5 can convert libxslt remote or locale file search XSL-T and Qt on page
    http://labs.trolltech.com/blogs/2008/09/

    Qt Code:
    1. int main(int argc, char *argv[]) {
    2. QApplication a( argc, argv );
    3. qDebug() << "### init main void Extract, Transform ";
    4. QDateTime timer1( QDateTime::currentDateTime() );
    5. const QString localoutfile = "outresult.html";
    6. StreamBuf *buf = new StreamBuf();
    7. QXmlQuery xquery(QXmlQuery::XSLT20);
    8. xquery.setFocus(QUrl("http://fop-miniscribus.googlecode.com/svn/trunk/doc/Xsltqt5/data.xml"));
    9. xquery.setQuery(QUrl("http://fop-miniscribus.googlecode.com/svn/trunk/doc/Xsltqt5/style.xsl"));
    10. xquery.evaluateTo(buf->device());
    11. t.show();
    12. t.setPlainText ( const QString & text );
    13. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    14. return a.exec();
    15. };
    16.  
    17. //// read dir http://fop-miniscribus.googlecode.com/svn/trunk/doc/Xsltqt5/
    To copy to clipboard, switch view to plain text mode 


    Quote Originally Posted by NoRulez View Post
    In another post you say you can automate such things (Invoice, ...) with xsl-fo. Can you give me an example how i can call or convert xml and xsl documents with xsl-fo?
    I not need xslt to make simple invoice, only to make report or long mysql - query.. more as 2-3 pages.

    to make a simple invoice i write a file on MiniScribus http://code.google.com/p/fop-miniscribus/ version 1.3 which having only Floating elements i parse XML and i insert time , data , customers adress , and table ant end invoice application print or display file on Miniscribus or render direct to pdf ... is only a xml query or you can search and replace ##datetime## and other string key...
    In the new Miniscribus version 2 people can take OpenOffice document or pdf - rtf or wath else it need.... is only xml parse to fill data...

    I write only 5 or 6 template and you can write 1000 of invoice and barcode
    one sample is on http://fop-miniscribus.googlecode.co...sltqt5/tmp.fop
    it place layer exact y,x from document and his barcode to find on db the correct invoice by
    a hand barcode scanner ...

    To learn xsl-fo is more simple as html write a page on MiniScribus 1 or 2 and have a look on source xml...
    Other application based on qt is http://www.qt-apps.org/content/show....?content=82672 but at this time it can only write basic simple xsl-fo.

  7. #7
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: High quality business papers

    Heres what I do for HQ documents:

    1) I create a printer
    2) I use QPrinter::PdfFormat to make the printer print to PDF
    3) I make a QPainter with the QPrinter as the device to print to
    4) I then have programmed instructions to draw and type stuff with the QPainter on the printer,
    5) When I call painter.end(), it causes the PDF to be created in perfect quality.

    Although this method might be somewhat time consuming at first to set up, once you get the hang of it, you can make perfect documents that print on any printer exactly as you intend them to.

    Heres a very simple example code to make a pdf with some random lines and text (more of a test of how the page sizes work and how stuff fits) :
    Qt Code:
    1. void pdf::generatePdf() {
    2.  
    3. QPrinter printer; //create a printer
    4. printer.setOrientation(QPrinter::Portrait); //set the orientation of the paper
    5. printer.setOutputFormat(QPrinter::PdfFormat); //make that printer as a PDF
    6. printer.setOutputFileName("filename.pdf"); //set the PDF file name
    7. printer.setPaperSize(QPrinter::Letter); //set paper size that the PDF uses
    8. printer.setPageMargins (0.5, 0.5, 0.5, 0.5, QPrinter::Inch); //1/2 inch margins
    9. QPainter painter(&printer); //make a painter, which uses this printer,
    10.  
    11. //draw a blue round edged rectangle with the word "Hi" in it:
    12. painter.setPen(Qt::blue);
    13. painter.setFont(QFont("Arial", 30));
    14. QRectF r1(100, 200, 100, 100);
    15. painter.drawText(r1, Qt::AlignCenter, "Hi");
    16. painter.drawRoundedRect(r1, 15.0, 15.0);
    17.  
    18. //draw a black line from the upper left, to the lower right side of the page
    19. painter.setPen(Qt::black);
    20. QLineF line(0, 0, 576, 756);
    21. painter.drawLine(line);
    22.  
    23. //start a new page:
    24. printer.newPage();
    25.  
    26. //draw a red box that reads "hello!" in it:
    27. painter.setPen(Qt::red);
    28. painter.setFont(QFont("Arial", 30));
    29. QRectF r2(10, 30, 100, 100);
    30. painter.drawText(r2, Qt::AlignCenter, "Hello!");
    31. painter.drawRect(r2);
    32.  
    33. //draw a green dashed/dotted line in thick stroke, from upper right to lower left of page:
    34. QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
    35. painter.setPen(pen);
    36. QLineF line2(0, 756, 576, 0);
    37. painter.drawLine(line);
    38.  
    39. //end the painter causing the PDF to be generated as "filename.pdf":
    40. painter.end(); //done drawing, so save the PDF
    41.  
    42. }
    To copy to clipboard, switch view to plain text mode 
    you can then play around with more lines, positions, images, getting text from a database, etc which you can add using the painter. You can also print rich text documents to PDF like this, there is a text editor example that comes with Qt and within there is code to convert rich text documents to PDF if they are already in that format.
    Last edited by tpf80; 14th October 2008 at 09:00.

  8. #8
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: High quality business papers

    @tpf80: I don't want to draw the lines by my own, i would like to draw the lines with the finished html file. But I also read in the article that XSL-T won't be included in the QT Version 4.5.

    I also looked to KD Reports for that problem, but the german phone number doesn't work. Did you know where I can have more informations about the price and/or licensing?

    Regards

  9. #9
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: High quality business papers

    One way you could convert the HTML straight to PDF would be like this:

    Qt Code:
    1. QPrinter printer; //create a printer
    2. printer.setOrientation(QPrinter::Portrait); //set the orientation of the paper
    3. printer.setOutputFormat(QPrinter::PdfFormat); //make that printer as a PDF
    4. printer.setOutputFileName("filename.pdf"); //set the PDF file name
    5. QTextDocument *document = new QTextDocument();
    6. document->setDefaultStyleSheet(styleSheet); //the style sheet QString;
    7. document->setHtml(htmlContent); //the HTML QString;
    8. document->print(&printer);
    To copy to clipboard, switch view to plain text mode 

    Note that the stylesheet is loaded separately from the html. Here is a list of the tags which the QTextDocmument can understand: http://doc.trolltech.com/4.4/richtext-html-subset.html

  10. #10
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: High quality business papers

    Thanks,

    i will try it. Must the style sheet also contain the <style> and </style> tags?

    Regards

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.