Results 1 to 2 of 2

Thread: how to generate a PDF file with qt?

  1. #1
    Join Date
    Feb 2009
    Location
    Shanghai.China
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default how to generate a PDF file with qt?

    In Linux OS, for example CentOS, I want to generate a PDF file to show my data.
    I did this by HTML, but the font in PDF file is bold and i can't set it to normal (not bold), and the words in the file look like not very clear.

    Is there another way to generate PDF file in Qt?

    btw: I hope the way is free, that is to say without pay.

    Any help will be appreciated.

  2. #2
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to generate a PDF file with qt?

    You have to use the QPrinter class to generate a pdf:
    Qt Code:
    1. Qprinter printer;
    2. printer.setOutputFileName(filename);
    3. printer.setOutputFormat(QPrinter::PdfFormat);
    To copy to clipboard, switch view to plain text mode 

    Have a look at void TextEdit::filePrintPdf() in http://doc.trolltech.com/4.2/demos-t...tedit-cpp.html .

    Concerning viewing of a pdf doc, Qt is not shipped with a viewer, so you might have to use a third parties library or embed adobe ActiveX control in your app.
    Last edited by toutarrive; 25th March 2010 at 07:47.

Similar Threads

  1. cannot generate exe file in haique
    By anishpaily in forum Qt Tools
    Replies: 6
    Last Post: 15th October 2008, 08:27
  2. Generate a form from an XML file.
    By cbarmpar in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 15:54
  3. how to generate debug file???
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 1st May 2008, 23:03
  4. make--dosn't generate an .exe file
    By Nora in forum Installation and Deployment
    Replies: 11
    Last Post: 12th November 2007, 01:26
  5. how can i generate .cpp file in QT 4.3.0
    By gamitkumar in forum General Programming
    Replies: 4
    Last Post: 3rd September 2007, 22:23

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.