Results 1 to 5 of 5

Thread: Is Qt right for this job?

  1. #1
    Join Date
    Oct 2008
    Posts
    1
    Platforms
    Unix/X11 Windows

    Default Is Qt right for this job?

    I want to write a program to convert html files to pdfs that supports the linux and windows platforms. I may not have time to implement an html parser so I was wondering would it be possible to use a Qt widget to load the html file and then have Qt print it to pdf. I was thinking of QWebkit but maybe there are other options thanks.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is Qt right for this job?

    you can load html using QTextEdit, QTextBrowser, QWebView.

  3. #3
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is Qt right for this job?

    i don't know if using Qt you can print anything to PDF. But you can try using PDF convertors like Ghostscript etc...which are also cross-platform.

    So, use Qt's web widgets to display the HTML page and use Ghostscript etc... in the background to convert it to PDF.

  4. #4
    Join Date
    Aug 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is Qt right for this job?

    It's easy to print to a PDF file with Qt. I've used it with several components but not with webkit. But from what I look at the docs, it has a print function so you're good to go.
    Just create a printer object and set it's format to PDF. Here's a code sample:

    Qt Code:
    1. QWebView *webkit = new QWebView();
    2. QPrinter printer(QPrinter::HighResolution);
    3.  
    4. printer.setPageSize(QPrinter::A4);
    5. printer.setOutputFileName("cartao.pdf");
    6. printer.setOutputFormat(QPrinter::PdfFormat);
    7.  
    8. webkit->load(QUrl("http://www.qtcentre.org/forum/"));
    9. webkit->print(&printer);
    To copy to clipboard, switch view to plain text mode 
    That should get you going.

    Qt for multi-platform is very good. And for this task you need, it gets the job done easy.

    Good luck!
    Last edited by jpn; 12th October 2008 at 14:38. Reason: missing [code] tags

  5. #5
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is Qt right for this job?

    Check out cutycapt.

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.