Results 1 to 10 of 10

Thread: High quality business papers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    196
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 6 Posts
    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

  2. #2
    Join Date
    May 2006
    Posts
    788
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    49
    Thanked 48 Times in 46 Posts

    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.

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

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    196
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 6 Posts
    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

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

    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

  6. #6
    Join Date
    Apr 2008
    Posts
    196
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 6 Posts
    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
  •  
Qt is a trademark of The Qt Company.